@@ -496,7 +496,7 @@ namespace :node do
496496 end
497497
498498 task :'dry-run' do
499- Bazel . execute ( 'run' , [ '--stamp' ] , '//javascript/node/selenium-webdriver:selenium-webdriver.pack ' )
499+ Bazel . execute ( 'run' , [ '--stamp' ] , '//javascript/node/selenium-webdriver:selenium-webdriver.publish -- --dry-run=true ' )
500500 end
501501
502502 desc 'Release Node npm package'
@@ -520,16 +520,43 @@ namespace :node do
520520
521521 desc 'Update Node version'
522522 task :version , [ :version ] do |_task , arguments |
523+ bump_nightly = arguments [ :version ] === 'nightly'
523524 old_version = node_version
524- new_version = updated_version ( old_version , arguments [ :version ] )
525+ new_version = nil
526+
527+ # There are three cases we want to deal with:
528+ # 1. Switching from a release build to a nightly one
529+ # 2. Updating a nightly build for the next nightly build
530+ # 3. Switching from nightlies to a release build.
531+
532+ if bump_nightly && old_version . include? ( '-nightly' )
533+ # This is the case where we are updating a nightly build to the next nightly build.
534+ # This change is usually done by the CI system and never committed.
535+ # The "-nightlyYmdHM" is removed to add a new timestamp.
536+ new_version = old_version . gsub ( /\- nightly\d +$/ , '' ) + "-nightly#{ Time . now . strftime ( "%Y%m%d%H%M" ) } "
537+ elsif bump_nightly
538+ # This is the case after a production release and the version number is configured
539+ # to start doing nightly builds.
540+ new_version = old_version + "-nightly#{ Time . now . strftime ( "%Y%m%d%H%M" ) } "
541+ else
542+ if old_version . include? ( '-nightly' )
543+ # From a nightly build to a release build.
544+ new_version = old_version . gsub ( /\- nightly\d +$/ , '' )
545+ else
546+ # From a release build to a nightly build. We use npm version for this.
547+ new_version = updated_version ( old_version . gsub ( /\- nightly\d +$/ , '' ) , arguments [ :version ] )
548+ new_version = new_version + "-nightly#{ Time . now . strftime ( "%Y%m%d%H%M" ) } "
549+ end
550+ end
525551
526552 [ 'javascript/node/selenium-webdriver/package.json' ,
527- 'package-lock.json' ] . each do |file |
553+ 'package-lock.json' ,
554+ 'javascript/node/selenium-webdriver/BUILD.bazel' ] . each do |file |
528555 text = File . read ( file ) . gsub ( old_version , new_version )
529556 File . open ( file , "w" ) { |f | f . puts text }
530557 end
531558
532- Rake ::Task [ 'node:changelog' ] . invoke
559+ Rake ::Task [ 'node:changelog' ] . invoke unless new_version . include? ( '-nightly' ) || bump_nightly
533560 end
534561end
535562
0 commit comments