prepare for autorelease (#197)

This commit is contained in:
Graham Paye 2019-02-22 10:38:05 -08:00 committed by GitHub
parent d765472f35
commit 4831d41d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 147 additions and 24 deletions

View File

@ -28,9 +28,16 @@ function set_failed_status {
EXIT_STATUS=1
}
for version in "${RUBY_VERSIONS[@]}"; do
rbenv global "$version"
(bundle update && bundle exec rake) || set_failed_status
done
if [ "$JOB_TYPE" = "release" ]; then
git fetch --depth=10000
python3 -m pip install git+https://github.com/googleapis/releasetool
python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
(bundle update && bundle exec rake kokoro:release) || set_failed_status
else
for version in "${RUBY_VERSIONS[@]}"; do
rbenv global "$version"
(bundle update && bundle exec rake) || set_failed_status
done
fi
exit $EXIT_STATUS

48
.kokoro/release.cfg Normal file
View File

@ -0,0 +1,48 @@
# Format: //devtools/kokoro/config/proto/build.proto
# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}
# Fetch the token needed for reporting release status to GitHub
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73713
keyname: "yoshi-automation-github-key"
}
}
}
# Download resources for system tests (service account key, etc.)
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-ruby"
# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
# Use the trampoline script to run in docker.
build_file: "google-auth-library-ruby/.kokoro/trampoline.sh"
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/google-cloud-ruby/ruby-release"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/google-auth-library-ruby/.kokoro/build.sh"
}
env_vars: {
key: "JOB_TYPE"
value: "release"
}
env_vars: {
key: "OS"
value: "linux"
}

View File

@ -1,6 +1,7 @@
AllCops:
Exclude:
- "spec/**/*"
- "Rakefile"
Metrics/AbcSize:
Max: 25

View File

@ -13,3 +13,70 @@ desc 'Does rubocop lint and runs the specs'
task all: [:rubocop, :spec]
task default: :all
task :release, :tag do |t, args|
tag = args[:tag]
raise "You must provide a tag to release." if tag.nil?
# Verify the tag format "PACKAGE/vVERSION"
m = tag.match(/v(?<version>\S*)/)
raise "Tag #{tag} does not match the expected format." if m.nil?
version = m[:version]
raise "You must provide a version." if version.nil?
api_token = ENV["RUBYGEMS_API_TOKEN"]
require "gems"
::Gems.configure do |config|
config.key = api_token
end if api_token
Bundler.with_clean_env do
sh "rm -rf pkg"
sh "bundle update"
sh "bundle exec rake build"
end
path_to_be_pushed = "pkg/#{version}.gem"
if File.file? path_to_be_pushed
begin
::Gems.push(File.new path_to_be_pushed)
puts "Successfully built and pushed googleauth for version #{version}"
rescue => e
puts "Error while releasing googleauth version #{version}: #{e.message}"
end
else
raise "Cannot build googleauth for version #{version}"
end
end
namespace :kokoro do
task :load_env_vars do
service_account = "#{ENV["KOKORO_GFILE_DIR"]}/service-account.json"
ENV["GOOGLE_APPLICATION_CREDENTIALS"] = service_account
filename = "#{ENV["KOKORO_GFILE_DIR"]}/env_vars.json"
env_vars = JSON.parse(File.read(filename))
env_vars.each { |k, v| ENV[k] = v }
end
task :release do
version = "0.1.0"
Bundler.with_clean_env do
version = `bundle exec gem list`
.split("\n").select { |line| line.include? "googleauth" }
.first.split("(").last.split(")").first || "0.1.0"
end
Rake::Task["kokoro:load_env_vars"].invoke
Rake::Task["release"].invoke "v/#{version}"
end
end
def header str, token = "#"
line_length = str.length + 8
puts ""
puts token * line_length
puts "#{token * 3} #{str} #{token * 3}"
puts token * line_length
puts ""
end

View File

@ -4,32 +4,32 @@
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'googleauth/version'
Gem::Specification.new do |s|
s.name = 'googleauth'
s.version = Google::Auth::VERSION
s.authors = ['Tim Emiola']
s.email = 'temiola@google.com'
s.homepage = 'https://github.com/google/google-auth-library-ruby'
s.summary = 'Google Auth Library for Ruby'
s.license = 'Apache-2.0'
s.description = <<-DESCRIPTION
Gem::Specification.new do |gem|
gem.name = 'googleauth'
gem.version = Google::Auth::VERSION
gem.authors = ['Tim Emiola']
gem.email = 'temiola@google.com'
gem.homepage = 'https://github.com/google/google-auth-library-ruby'
gem.summary = 'Google Auth Library for Ruby'
gem.license = 'Apache-2.0'
gem.description = <<-DESCRIPTION
Allows simple authorization for accessing Google APIs.
Provide support for Application Default Credentials, as described at
https://developers.google.com/accounts/docs/application-default-credentials
DESCRIPTION
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- spec/*`.split("\n")
s.executables = `git ls-files -- bin/*.rb`.split("\n").map do |f|
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- spec/*`.split("\n")
gem.executables = `git ls-files -- bin/*.rb`.split("\n").map do |f|
File.basename(f)
end
s.require_paths = ['lib']
s.platform = Gem::Platform::RUBY
gem.require_paths = ['lib']
gem.platform = Gem::Platform::RUBY
s.add_dependency 'faraday', '~> 0.12'
s.add_dependency 'jwt', '>= 1.4', '< 3.0'
s.add_dependency 'memoist', '~> 0.16'
s.add_dependency 'multi_json', '~> 1.11'
s.add_dependency 'os', '>= 0.9', '< 2.0'
s.add_dependency 'signet', '~> 0.7'
gem.add_dependency 'faraday', '~> 0.12'
gem.add_dependency 'jwt', '>= 1.4', '< 3.0'
gem.add_dependency 'memoist', '~> 0.16'
gem.add_dependency 'multi_json', '~> 1.11'
gem.add_dependency 'os', '>= 0.9', '< 2.0'
gem.add_dependency 'signet', '~> 0.7'
end