|
3 | 3 | require 'English' |
4 | 4 | $LOAD_PATH.unshift File.expand_path('.') |
5 | 5 |
|
| 6 | +require 'base64' |
6 | 7 | require 'rake' |
| 8 | +require 'net/http' |
7 | 9 | require 'net/telnet' |
8 | 10 | require 'stringio' |
9 | 11 | require 'fileutils' |
@@ -982,6 +984,37 @@ namespace :java do |
982 | 984 |
|
983 | 985 | puts "Releasing Java artifacts to Maven repository at '#{ENV.fetch('MAVEN_REPO', nil)}'" |
984 | 986 | java_release_targets.each { |target| Bazel.execute('run', ['--config=release'], target) } |
| 987 | + |
| 988 | + Rake::Task['java:publish'].invoke unless nightly |
| 989 | + end |
| 990 | + |
| 991 | + desc 'Publish to sonatype' |
| 992 | + task :publish do |_task| |
| 993 | + read_m2_user_pass unless ENV['MAVEN_PASSWORD'] && ENV['MAVEN_USER'] |
| 994 | + user = ENV.fetch('MAVEN_USER') |
| 995 | + pass = ENV.fetch('MAVEN_PASSWORD') |
| 996 | + |
| 997 | + uri = URI('https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/org.seleniumhq') |
| 998 | + encoded = Base64.strict_encode64("#{user}:#{pass}") |
| 999 | + |
| 1000 | + puts 'Triggering validation POST to Central Portal...' |
| 1001 | + req = Net::HTTP::Post.new(uri) |
| 1002 | + req['Authorization'] = "Basic #{encoded}" |
| 1003 | + req['Accept'] = '*/*' |
| 1004 | + req['Content-Length'] = '0' |
| 1005 | + |
| 1006 | + res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, |
| 1007 | + open_timeout: 10, read_timeout: 60) do |http| |
| 1008 | + http.request(req) |
| 1009 | + end |
| 1010 | + |
| 1011 | + if res.is_a?(Net::HTTPSuccess) |
| 1012 | + puts "Manual upload triggered successfully (HTTP #{res.code})" |
| 1013 | + else |
| 1014 | + warn "Manual upload failed (HTTP #{res.code}): #{res.code} #{res.message}" |
| 1015 | + warn res.body if res.body && !res.body.empty? |
| 1016 | + exit(1) |
| 1017 | + end |
985 | 1018 | end |
986 | 1019 |
|
987 | 1020 | desc 'Install jars to local m2 directory' |
|
0 commit comments