@@ -811,9 +811,21 @@ namespace :dotnet do
811
811
Rake ::Task [ 'dotnet:build' ] . invoke ( args )
812
812
Rake ::Task [ 'dotnet:zip_assets' ] . invoke ( args )
813
813
814
+ release_version = dotnet_version
815
+ api_key = ENV . fetch ( 'NUGET_API_KEY' , nil )
816
+ push_destination = 'https://api.nuget.org/v3/index.json'
817
+ if release_version . include? ( '-nightly' )
818
+ # Nightly builds are pushed to GitHub NuGet repository
819
+ # This commands will run in GitHub Actions
820
+ api_key = ENV . fetch ( 'GITHUB_TOKEN' , nil )
821
+ github_push_url = 'https://nuget.pkg.github.com/seleniumhq/index.json'
822
+ push_destination = 'github'
823
+ sh "dotnet nuget add source --username seleniumhq --password #{ api_key } --store-password-in-clear-text --name #{ push_destination } #{ github_push_url } "
824
+ end
825
+
814
826
[ "./bazel-bin/dotnet/src/webdriver/Selenium.WebDriver.#{ dotnet_version } .nupkg" ,
815
827
"./bazel-bin/dotnet/src/support/Selenium.Support.#{ dotnet_version } .nupkg" ] . each do |asset |
816
- sh "dotnet nuget push #{ asset } --api-key #{ ENV . fetch ( 'NUGET_API_KEY' , nil ) } --source https://api.nuget.org/v3/index.json "
828
+ sh "dotnet nuget push #{ asset } --api-key #{ api_key } --source #{ push_destination } "
817
829
end
818
830
end
819
831
@@ -854,14 +866,38 @@ namespace :dotnet do
854
866
855
867
desc 'Update .NET version'
856
868
task :version , [ :version ] do |_task , arguments |
869
+ bump_nightly = arguments [ :version ] === 'nightly'
857
870
old_version = dotnet_version
858
- new_version = updated_version ( old_version , arguments [ :version ] )
871
+ new_version = nil
872
+
873
+ # There are three cases we want to deal with:
874
+ # 1. Switching from a release build to a nightly one
875
+ # 2. Updating a nightly build for the next nightly build
876
+ # 3. Switching from nightlies to a release build.
877
+
878
+ if bump_nightly && old_version . include? ( '-nightly' )
879
+ # This is the case where we are updating a nightly build to the next nightly build.
880
+ # This change is usually done by the CI system and never committed.
881
+ # The "-nightlyYmdHM" is removed to add a new timestamp.
882
+ new_version = old_version . gsub ( /\- nightly\d +$/ , '' ) + "-nightly#{ Time . now . strftime ( "%Y%m%d%H%M" ) } "
883
+ elsif bump_nightly
884
+ # This is the case after a production release and the version number is configured
885
+ # to start doing nightly builds.
886
+ new_version = old_version + "-nightly#{ Time . now . strftime ( "%Y%m%d%H%M" ) } "
887
+ else
888
+ if old_version . include? ( '-nightly' )
889
+ new_version = old_version . gsub ( /\- nightly\d +$/ , '' )
890
+ else
891
+ new_version = updated_version ( old_version . gsub ( /\- nightly\d +$/ , '' ) , arguments [ :version ] )
892
+ new_version = new_version + "-nightly#{ Time . now . strftime ( "%Y%m%d%H%M" ) } "
893
+ end
894
+ end
859
895
860
896
file = 'dotnet/selenium-dotnet-version.bzl'
861
897
text = File . read ( file ) . gsub ( old_version , new_version )
862
898
File . open ( file , "w" ) { |f | f . puts text }
863
899
864
- Rake ::Task [ 'dotnet:changelog' ] . invoke
900
+ Rake ::Task [ 'dotnet:changelog' ] . invoke unless new_version . include? ( '-nightly' ) || bump_nightly
865
901
end
866
902
end
867
903
0 commit comments