Skip to content

Commit a892358

Browse files
authored
chore: Provide a release-please action (googleapis#11139)
1 parent 459ffaa commit a892358

4 files changed

Lines changed: 94 additions & 42 deletions

File tree

.github/workflows/pr-labels.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release-Please
2+
on:
3+
schedule:
4+
- cron: '47 7 * * *'
5+
workflow_dispatch:
6+
inputs:
7+
gem:
8+
description: "Name of single gem to release. Leave blank to check all gems."
9+
required: false
10+
11+
jobs:
12+
release-please:
13+
if: ${{ github.repository == 'googleapis/google-cloud-ruby' }}
14+
runs-on: ubuntu-latest
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
17+
steps:
18+
- name: Checkout repo
19+
uses: actions/checkout@v2
20+
- name: Install Ruby 2.7
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: "2.7"
24+
- name: Install NodeJS 12.x
25+
uses: actions/setup-node@v1
26+
with:
27+
node-version: "12.x"
28+
- name: Install tools
29+
run: "gem install --no-document toys && npm install release-please"
30+
- name: execute
31+
run: "toys release-please ${{ github.event.inputs.gem }}"

.toys/release-please.rb

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright 2021 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
desc "Runs release-please."
18+
19+
flag :github_token, "--github-token=TOKEN", default: ENV["GITHUB_TOKEN"]
20+
flag :install
21+
remaining_args :gems, desc: "Release the specified gems. If no specific gem is provided, all gems are checked."
22+
23+
include :exec, e: true
24+
include :terminal, styled: true
25+
26+
def run
27+
Dir.chdir context_directory
28+
if install
29+
exec ["npm", "install", "release-please"]
30+
exit
31+
end
32+
if gems.empty?
33+
set :gems, Dir.glob("*/*.gemspec").map { |path| File.dirname path }
34+
end
35+
gems.each { |gem_name| release_please gem_name }
36+
end
37+
38+
def release_please gem_name
39+
version = gem_version gem_name
40+
puts "Running release-please for #{gem_name} from version #{version}", :bold
41+
cmd = [
42+
"npx", "release-please", "release-pr",
43+
"--package-name", gem_name,
44+
"--last-package-version", version,
45+
"--release-type", "ruby-yoshi",
46+
"--repo-url", "googleapis/google-cloud-ruby",
47+
"--bump-minor-pre-major"
48+
]
49+
cmd += ["--token", github_token] if github_token
50+
log_cmd = cmd.inspect
51+
log_cmd.sub! github_token, "****" if github_token
52+
exec cmd, log_cmd: log_cmd
53+
end
54+
55+
def gem_version gem_name
56+
func = proc do
57+
Dir.chdir gem_name do
58+
spec = Gem::Specification.load "#{gem_name}.gemspec"
59+
puts spec.version.to_s
60+
end
61+
end
62+
capture_proc(func).strip
63+
end

rakelib/kokoro/kokoro.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def continuous
5656
end
5757
local_docs_test if should_link_check?
5858
end
59-
release_please if @should_release && @updated
6059
end
6160

6261
def cloudrad
@@ -132,7 +131,6 @@ def nightly
132131
run "bundle exec rake ci:acceptance", 3600
133132
local_docs_test if should_link_check?
134133
end
135-
release_please if @should_release
136134
end
137135

138136
def post

0 commit comments

Comments
 (0)