chore: publish to googleapis.dev on release (#242)
This commit is contained in:
parent
6be995d29a
commit
a6082d158b
|
@ -60,7 +60,7 @@ 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"
|
||||
value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/release"
|
||||
}
|
||||
|
||||
env_vars: {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "googleauth",
|
||||
"language": "ruby",
|
||||
"distribution-name": "googleauth"
|
||||
}
|
|
@ -5,6 +5,7 @@ AllCops:
|
|||
Exclude:
|
||||
- "spec/**/*"
|
||||
- "Rakefile"
|
||||
- "rakelib/**/*"
|
||||
Metrics/ClassLength:
|
||||
Max: 110
|
||||
Exclude:
|
||||
|
|
19
Rakefile
19
Rakefile
|
@ -13,7 +13,7 @@ task :release_gem, :tag do |_t, args|
|
|||
raise "You must provide a tag to release." if tag.nil?
|
||||
|
||||
# Verify the tag format "vVERSION"
|
||||
m = tag.match(/google-auth-library-ruby\/v(?<version>\S*)/)
|
||||
m = tag.match /v(?<version>\S*)/
|
||||
raise "Tag #{tag} does not match the expected format." if m.nil?
|
||||
|
||||
version = m[:version]
|
||||
|
@ -35,16 +35,23 @@ task :release_gem, :tag do |_t, args|
|
|||
end
|
||||
|
||||
path_to_be_pushed = "pkg/googleauth-#{version}.gem"
|
||||
gem_was_published = nil
|
||||
if File.file? path_to_be_pushed
|
||||
begin
|
||||
::Gems.push File.new(path_to_be_pushed)
|
||||
response = ::Gems.push File.new(path_to_be_pushed)
|
||||
puts response
|
||||
raise unless response.include? "Successfully registered gem:"
|
||||
gem_was_published = true
|
||||
puts "Successfully built and pushed googleauth for version #{version}"
|
||||
rescue StandardError => e
|
||||
gem_was_published = false
|
||||
puts "Error while releasing googleauth version #{version}: #{e.message}"
|
||||
end
|
||||
else
|
||||
raise "Cannot build googleauth for version #{version}"
|
||||
end
|
||||
|
||||
Rake::Task["kokoro:publish_docs"].invoke if gem_was_published
|
||||
end
|
||||
|
||||
namespace :kokoro do
|
||||
|
@ -76,7 +83,13 @@ namespace :kokoro do
|
|||
.first.split("(").last.split(")").first || "0.1.0"
|
||||
end
|
||||
Rake::Task["kokoro:load_env_vars"].invoke
|
||||
Rake::Task["release_gem"].invoke "google-auth-library-ruby/v#{version}"
|
||||
Rake::Task["release_gem"].invoke "v#{version}"
|
||||
end
|
||||
|
||||
task :publish_docs do
|
||||
require_relative "rakelib/devsite_builder.rb"
|
||||
|
||||
DevsiteBuilder.new(__dir__).publish
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -33,4 +33,5 @@ Gem::Specification.new do |gem|
|
|||
gem.add_dependency "multi_json", "~> 1.11"
|
||||
gem.add_dependency "os", ">= 0.9", "< 2.0"
|
||||
gem.add_dependency "signet", "~> 0.12"
|
||||
gem.add_development_dependency "yard", "~> 0.9"
|
||||
end
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
require "pathname"
|
||||
|
||||
require_relative "repo_metadata.rb"
|
||||
|
||||
class DevsiteBuilder
|
||||
def initialize master_dir = "."
|
||||
@master_dir = Pathname.new master_dir
|
||||
@output_dir = "doc"
|
||||
@metadata = RepoMetadata.from_source "#{master_dir}/.repo-metadata.json"
|
||||
end
|
||||
|
||||
def build
|
||||
FileUtils.remove_dir @output_dir if Dir.exist? @output_dir
|
||||
markup = "--markup markdown"
|
||||
|
||||
Dir.chdir @master_dir do
|
||||
cmds = ["-o #{@output_dir}", markup]
|
||||
cmd "yard --verbose #{cmds.join ' '}"
|
||||
end
|
||||
@metadata.build @master_dir + @output_dir
|
||||
end
|
||||
|
||||
def upload
|
||||
Dir.chdir @output_dir do
|
||||
opts = [
|
||||
"--credentials=#{ENV['KOKORO_KEYSTORE_DIR']}/73713_docuploader_service_account",
|
||||
"--staging-bucket=#{ENV.fetch 'STAGING_BUCKET', 'docs-staging'}",
|
||||
"--metadata-file=./docs.metadata"
|
||||
]
|
||||
cmd "python3 -m docuploader upload . #{opts.join ' '}"
|
||||
end
|
||||
end
|
||||
|
||||
def publish
|
||||
build
|
||||
upload
|
||||
end
|
||||
|
||||
def cmd line
|
||||
puts line
|
||||
output = `#{line}`
|
||||
puts output
|
||||
output
|
||||
end
|
||||
end
|
|
@ -0,0 +1,59 @@
|
|||
require "json"
|
||||
|
||||
class RepoMetadata
|
||||
attr_reader :data
|
||||
|
||||
def initialize data
|
||||
@data = data
|
||||
normalize_data!
|
||||
end
|
||||
|
||||
def allowed_fields
|
||||
[
|
||||
"name", "version", "language", "distribution-name",
|
||||
"product-page", "github-repository", "issue-tracker"
|
||||
]
|
||||
end
|
||||
|
||||
def build output_directory
|
||||
fields = @data.to_a.map { |kv| "--#{kv[0]} #{kv[1]}" }
|
||||
Dir.chdir output_directory do
|
||||
cmd "python3 -m docuploader create-metadata #{fields.join ' '}"
|
||||
end
|
||||
end
|
||||
|
||||
def normalize_data!
|
||||
require_relative "../lib/googleauth/version.rb"
|
||||
|
||||
@data.delete_if { |k, _| !allowed_fields.include?(k) }
|
||||
@data["version"] = Google::Auth::VERSION
|
||||
end
|
||||
|
||||
def [] key
|
||||
data[key]
|
||||
end
|
||||
|
||||
def []= key, value
|
||||
@data[key] = value
|
||||
end
|
||||
|
||||
def cmd line
|
||||
puts line
|
||||
output = `#{line}`
|
||||
puts output
|
||||
output
|
||||
end
|
||||
|
||||
def self.from_source source
|
||||
if source.is_a? RepoMetadata
|
||||
data = source.data
|
||||
elsif source.is_a? Hash
|
||||
data = source
|
||||
elsif File.file? source
|
||||
data = JSON.parse File.read(source)
|
||||
else
|
||||
raise "Source must be a path, hash, or RepoMetadata instance"
|
||||
end
|
||||
RepoMetadata.new data
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue