chore: Repurpose release task to release the gem

This commit is contained in:
Daniel Azuma 2020-10-27 11:28:52 -07:00 committed by GitHub
parent bbdc7dec2f
commit a0286c0589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 28 deletions

View File

@ -23,6 +23,7 @@ group :development do
gem 'logging', '~> 2.2'
gem 'opencensus', '~> 0.4'
gem 'httparty'
gem 'gems', '~> 1.2'
end
platforms :jruby do

View File

@ -79,10 +79,28 @@ namespace :kokoro do
end
task :release do
# Until code generation process is updated and release-please is set up, just publish docs
require_relative "rakelib/devsite/devsite_builder.rb"
Rake::Task["kokoro:publish_gem"].invoke
Rake::Task["kokoro:publish_docs"].invoke
end
DevsiteBuilder.new.publish_if_missing ENV["DOCS_BUILD_TAG"]
task :publish_gem do
require "gems"
load_env_vars if ENV["KOKORO_GFILE_DIR"]
api_token = ENV["RUBYGEMS_API_TOKEN"]
if api_token
::Gems.configure do |config|
config.key = api_token
end
end
rm_rf "pkg"
Rake::Task["build"].invoke
built_gem_path = Dir.glob("pkg/google-api-client-*.gem").last
response = ::Gems.push File.new path_to_be_pushed
puts response
raise "Failed to release gem" unless response.include? "Successfully registered gem:"
end
desc "Publish docs for the latest git tag"
@ -93,6 +111,16 @@ namespace :kokoro do
end
end
def load_env_vars
service_account = "#{ENV['KOKORO_GFILE_DIR']}/service-account.json"
raise "#{service_account} is not a file" unless File.file? service_account
ENV["GOOGLE_APPLICATION_CREDENTIALS"] = service_account
filename = "#{ENV['KOKORO_GFILE_DIR']}/ruby_env_vars.json"
raise "#{filename} is not a file" unless File.file? filename
env_vars = JSON.parse File.read(filename)
env_vars.each { |k, v| ENV[k] ||= v }
end
def header str, token = "#"
line_length = str.length + 8
puts

View File

@ -2,35 +2,35 @@ lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'google/apis/version'
Gem::Specification.new do |spec|
spec.name = 'google-api-client'
spec.version = Google::Apis::VERSION
spec.authors = ['Steven Bazyl', 'Tim Emiola', 'Sergio Gomes', 'Bob Aman']
spec.email = ['sbazyl@google.com']
spec.summary = 'Client for accessing Google APIs'
spec.homepage = 'https://github.com/google/google-api-ruby-client'
spec.license = 'Apache-2.0'
spec.metadata = {
Gem::Specification.new do |gem|
gem.name = 'google-api-client'
gem.version = Google::Apis::VERSION
gem.authors = ['Steven Bazyl', 'Tim Emiola', 'Sergio Gomes', 'Bob Aman']
gem.email = ['sbazyl@google.com']
gem.summary = 'Client for accessing Google APIs'
gem.homepage = 'https://github.com/google/google-api-ruby-client'
gem.license = 'Apache-2.0'
gem.metadata = {
"documentation_uri" => "https://googleapis.dev/ruby/google-api-client/v#{Google::Apis::VERSION}"
}
spec.files = `git ls-files -z`
.split("\x0")
.reject { |f| f.match(%r{^(spec|script)/|^api_names_out|synth\.metadata}) }
gem.files = `git ls-files -z`
.split("\x0")
.reject { |f| f.match(%r{^(spec|script)/|^api_names_out|synth\.metadata}) }
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = %w[lib generated]
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
gem.require_paths = %w[lib generated]
spec.required_ruby_version = '>= 2.4'
gem.required_ruby_version = '>= 2.4'
spec.add_runtime_dependency 'representable', '~> 3.0'
spec.add_runtime_dependency 'retriable', '>= 2.0', '< 4.0'
spec.add_runtime_dependency 'addressable', '~> 2.5', '>= 2.5.1'
spec.add_runtime_dependency 'mini_mime', '~> 1.0'
spec.add_runtime_dependency 'signet', '~> 0.12'
spec.add_runtime_dependency 'googleauth', '~> 0.9'
spec.add_runtime_dependency 'httpclient', '>= 2.8.1', '< 3.0'
spec.add_runtime_dependency 'rexml'
spec.add_development_dependency 'thor', '~> 0.19'
spec.add_development_dependency 'activesupport', '>= 4.2', '< 5.1'
gem.add_runtime_dependency 'representable', '~> 3.0'
gem.add_runtime_dependency 'retriable', '>= 2.0', '< 4.0'
gem.add_runtime_dependency 'addressable', '~> 2.5', '>= 2.5.1'
gem.add_runtime_dependency 'mini_mime', '~> 1.0'
gem.add_runtime_dependency 'signet', '~> 0.12'
gem.add_runtime_dependency 'googleauth', '~> 0.9'
gem.add_runtime_dependency 'httpclient', '>= 2.8.1', '< 3.0'
gem.add_runtime_dependency 'rexml'
gem.add_development_dependency 'thor', '~> 0.19'
gem.add_development_dependency 'activesupport', '>= 4.2', '< 5.1'
end