diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index cc92dd2ef5b83..d2be4c7bd50ee 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -46,6 +46,11 @@ on: required: false type: string default: '' + node-version: + description: Custom Node version to install + required: false + type: string + default: '' ruby-version: description: Custom Ruby version to use required: false @@ -72,6 +77,7 @@ jobs: SEL_M2_PASS: ${{ secrets.SEL_M2_PASS }} TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} SE_AVOID_STATS: true steps: - name: Checkout source tree @@ -103,6 +109,11 @@ jobs: with: java-version: ${{ inputs.java-version }} distribution: 'temurin' + - name: Setup Node + if: inputs.node-version != '' + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} - name: Setup Bazel with caching if: inputs.caching uses: bazel-contrib/setup-bazel@0.8.1 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e61c7b3492f40..1bddee4f61e2a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -20,6 +20,7 @@ on: - python - grid - dotnet + - javascript jobs: ruby: @@ -89,3 +90,21 @@ jobs: echo build --stamp >>.bazelrc.local ./go java-release-zip nightly-release-files: build/dist/*.* + + javascript: + if: (github.repository_owner == 'seleniumhq') && (inputs.language == 'javascript' || github.event_name == 'schedule') + name: DotNet + uses: ./.github/workflows/bazel.yml + with: + name: Nightly JavaScript Release + cache-key: javascript-nightly + node-version: '18.x' + run: | + sed -i 's|https://registry.npmjs.org/|https://npm.pkg.github.com|g' javascript/node/selenium-webdriver/package.json + sed -i 's|"name": "selenium-webdriver"|"name": "@seleniumhq/selenium-webdriver"|g' javascript/node/selenium-webdriver/package.json + echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc + echo "@seleniumhq:registry=https://npm.pkg.github.com" >> .npmrc + echo "always-auth=true" >> .npmrc + ./go "node:version[nightly]" + ./go node:release + secrets: inherit diff --git a/Rakefile b/Rakefile index b0c82dc58e310..587fdd518cd47 100644 --- a/Rakefile +++ b/Rakefile @@ -496,7 +496,7 @@ namespace :node do end task :'dry-run' do - Bazel.execute('run', ['--stamp'], '//javascript/node/selenium-webdriver:selenium-webdriver.pack') + Bazel.execute('run', ['--stamp'], '//javascript/node/selenium-webdriver:selenium-webdriver.publish -- --dry-run=true') end desc 'Release Node npm package' @@ -520,16 +520,43 @@ namespace :node do desc 'Update Node version' task :version, [:version] do |_task, arguments| + bump_nightly = arguments[:version] === 'nightly' old_version = node_version - new_version = updated_version(old_version, arguments[:version]) + new_version = nil + + # There are three cases we want to deal with: + # 1. Switching from a release build to a nightly one + # 2. Updating a nightly build for the next nightly build + # 3. Switching from nightlies to a release build. + + if bump_nightly && old_version.include?('-nightly') + # This is the case where we are updating a nightly build to the next nightly build. + # This change is usually done by the CI system and never committed. + # The "-nightlyYmdHM" is removed to add a new timestamp. + new_version = old_version.gsub(/\-nightly\d+$/, '') + "-nightly#{Time.now.strftime("%Y%m%d%H%M")}" + elsif bump_nightly + # This is the case after a production release and the version number is configured + # to start doing nightly builds. + new_version = old_version + "-nightly#{Time.now.strftime("%Y%m%d%H%M")}" + else + if old_version.include?('-nightly') + # From a nightly build to a release build. + new_version = old_version.gsub(/\-nightly\d+$/, '') + else + # From a release build to a nightly build. We use npm version for this. + new_version = updated_version(old_version.gsub(/\-nightly\d+$/, ''), arguments[:version]) + new_version = new_version + "-nightly#{Time.now.strftime("%Y%m%d%H%M")}" + end + end ['javascript/node/selenium-webdriver/package.json', - 'package-lock.json'].each do |file| + 'package-lock.json', + 'javascript/node/selenium-webdriver/BUILD.bazel'].each do |file| text = File.read(file).gsub(old_version, new_version) File.open(file, "w") { |f| f.puts text } end - Rake::Task['node:changelog'].invoke + Rake::Task['node:changelog'].invoke unless new_version.include?('-nightly') || bump_nightly end end diff --git a/javascript/node/selenium-webdriver/BUILD.bazel b/javascript/node/selenium-webdriver/BUILD.bazel index 97139fba7405f..15ad1553065a6 100644 --- a/javascript/node/selenium-webdriver/BUILD.bazel +++ b/javascript/node/selenium-webdriver/BUILD.bazel @@ -9,7 +9,7 @@ load("//javascript:defs.bzl", "mocha_test") npm_link_all_packages(name = "node_modules") -VERSION = "4.16.0" +VERSION = "4.20.0-nightly202404191827" BROWSER_VERSIONS = [ "v85", diff --git a/javascript/node/selenium-webdriver/package.json b/javascript/node/selenium-webdriver/package.json index ced55c0bb5e24..a67655565f154 100644 --- a/javascript/node/selenium-webdriver/package.json +++ b/javascript/node/selenium-webdriver/package.json @@ -1,6 +1,6 @@ { "name": "selenium-webdriver", - "version": "4.19.0", + "version": "4.20.0-nightly202404191827", "description": "The official WebDriver JavaScript bindings from the Selenium project", "license": "Apache-2.0", "keywords": [ @@ -54,5 +54,8 @@ "mocha": { "recursive": true, "timeout": 600000 + }, + "publishConfig": { + "registry": "https://registry.npmjs.org/" } } diff --git a/package-lock.json b/package-lock.json index 9e8a5e2a8f927..826a3f225c0a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1874,7 +1874,7 @@ "license": "ISC" }, "javascript/node/selenium-webdriver": { - "version": "4.19.0", + "version": "4.20.0-nightly202404191827", "license": "Apache-2.0", "dependencies": { "jszip": "^3.10.1",