Skip to content

Automate gem release and publishing workflow #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: Release Gem
description: |
This workflow creates a new release on GitHub and publishes the gem to
RubyGems.org.

The workflow uses the `googleapis/release-please-action` to handle the
release creation process and the `rubygems/release-gem` action to publish
the gem.

on:
push:
branches: ["main"]

workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest

environment:
name: RubyGems
url: https://rubygems.org/gems/create_github_release

permissions:
contents: write
pull-requests: write
id-token: write

steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Create release
uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.AUTO_RELEASE_TOKEN }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

- name: Setup ruby
uses: ruby/setup-ruby@v1
if: ${{ steps.release.outputs.release_created }}
with:
bundler-cache: true
ruby-version: ruby

- name: Push to RubyGems.org
uses: rubygems/release-gem@v1
if: ${{ steps.release.outputs.release_created }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "2.1.2"
}
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ rescue Bundler::BundlerError => e
exit e.status_code
end

# Make it so that calling `rake release` just calls `rake release:rubygems_push` to
# avoid creating and pushing a new tag.

Rake::Task['release'].clear
desc 'Customized release task to avoid creating a new tag'
task release: 'release:rubygem_push'

CLEAN << 'pkg'
CLOBBER << 'Gemfile.lock'

Expand Down
22 changes: 22 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"bootstrap-sha": "5f3a18d74fb755d31cc4d3dfc9d18a6df4799945",
"packages": {
".": {
"release-type": "ruby",
"package-name": "create_github_release",
"changelog-path": "CHANGELOG.md",
"version-file": "lib/create_github_release/version.rb",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"draft": false,
"prerelease": false,
"include-component-in-tag": false
}
},
"plugins": [
{
"type": "sentence-case"
}
],
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}