Skip to content

Commit 934289d

Browse files
committed
fix: automate commit-to-publish workflow
Use googleapis/release-please-action and rubygems/release-gem actions to automate releasing and publishing new gem versions to rubygems.
1 parent 84c63eb commit 934289d

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: Release Gem
3+
description: |
4+
This workflow creates a new release on GitHub and publishes the gem to
5+
RubyGems.org.
6+
7+
The workflow uses the `googleapis/release-please-action` to handle the
8+
release creation process and the `rubygems/release-gem` action to publish
9+
the gem.
10+
11+
on:
12+
push:
13+
branches: ["main"]
14+
15+
workflow_dispatch:
16+
17+
jobs:
18+
release:
19+
runs-on: ubuntu-latest
20+
21+
environment:
22+
name: RubyGems
23+
url: https://rubygems.org/gems/create_github_release
24+
25+
permissions:
26+
contents: write
27+
pull-requests: write
28+
id-token: write
29+
30+
steps:
31+
- name: Checkout project
32+
uses: actions/checkout@v4
33+
34+
- name: Create release
35+
uses: googleapis/release-please-action@v4
36+
id: release
37+
with:
38+
token: ${{ secrets.AUTO_RELEASE_TOKEN }}
39+
config-file: release-please-config.json
40+
manifest-file: .release-please-manifest.json
41+
42+
- name: Setup ruby
43+
uses: ruby/setup-ruby@v1
44+
if: ${{ steps.release.outputs.release_created }}
45+
with:
46+
bundler-cache: true
47+
ruby-version: ruby
48+
49+
- name: Push to RubyGems.org
50+
uses: rubygems/release-gem@v1
51+
if: ${{ steps.release.outputs.release_created }}

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "2.1.2"
3+
}

Rakefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ rescue Bundler::BundlerError => e
2727
exit e.status_code
2828
end
2929

30+
# Make it so that calling `rake release` just calls `rake release:rubygems_push` to
31+
# avoid creating and pushing a new tag.
32+
33+
Rake::Task['release'].clear
34+
desc 'Customized release task to avoid creating a new tag'
35+
task release: 'release:rubygem_push'
36+
3037
CLEAN << 'pkg'
3138
CLOBBER << 'Gemfile.lock'
3239

release-please-config.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"bootstrap-sha": "5f3a18d74fb755d31cc4d3dfc9d18a6df4799945",
3+
"packages": {
4+
".": {
5+
"release-type": "ruby",
6+
"package-name": "create_github_release",
7+
"changelog-path": "CHANGELOG.md",
8+
"version-file": "lib/create_github_release/version.rb",
9+
"bump-minor-pre-major": true,
10+
"bump-patch-for-minor-pre-major": true,
11+
"draft": false,
12+
"prerelease": false,
13+
"include-component-in-tag": false
14+
}
15+
},
16+
"plugins": [
17+
{
18+
"type": "sentence-case"
19+
}
20+
],
21+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
22+
}

0 commit comments

Comments
 (0)