Skip to content

Commit 48512b9

Browse files
committed
Initial commit
0 parents  commit 48512b9

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Release Gem GitHub Action
2+
3+
This action allows you to automate releasing your gems to RubyGems.org.
4+
5+
## Usage
6+
7+
### Trusted Publishing
8+
9+
This example jumps right into RubyGems.org's current reccomended best practice.
10+
11+
This action supports RubyGems.org's [trusted publishing] implementation,
12+
which allows authenticating to RubyGems.org without manually configuring secrets.
13+
To perform [trusted publishing] with this action, your projects publisher must already be
14+
[configured on RubyGems.org].
15+
16+
To enter the trusted publishing flow, configure this action's job with the
17+
`id-token: write` permission.
18+
19+
```yaml
20+
# .github/workflows/push_gem.yml
21+
jobs:
22+
push:
23+
name: Push gem to RubyGems.org
24+
runs-on: ubuntu-latest
25+
26+
permissions:
27+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
28+
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
29+
30+
steps:
31+
# Set up
32+
- uses: actions/checkout@v4
33+
- name: Set up Ruby
34+
uses: ruby/setup-ruby@v1
35+
with:
36+
bundler-cache: true
37+
ruby-version: ruby
38+
39+
# Release
40+
- uses: rubygems/release-gem@v1
41+
```
42+
43+
### Requirements
44+
45+
For now, this action makes several assumptions about your project:
46+
47+
1. Your workflow checks out the repository & configures a working Ruby environment
48+
2. Your project uses [bundler] to manage dependencies
49+
3. Your project has the [bundler release tasks] configured
50+
4. Your gem has [trusted publishing] [configured on RubyGems.org]
51+
52+
[bundler]: https://bundler.io
53+
[bundler release tasks]: https://bundler.io/guides/creating_gem.html#releasing-the-gem
54+
[configured on RubyGems.org]: https://guides.rubygems.org/trusted-publishing/adding-a-publisher/
55+
[trusted publishing]: https://guides.rubygems.org/trusted-publishing

action.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "Release Gem"
2+
description: "Upload gems to RubyGems.org"
3+
inputs:
4+
await-release:
5+
description: "Whether to poll for the release to be available on RubyGems.org"
6+
required: false
7+
default: "true"
8+
setup-trusted-publisher:
9+
description: "Whether to setup the trusted publisher for the gem"
10+
required: false
11+
default: "true"
12+
outputs: {}
13+
branding:
14+
color: "red"
15+
icon: "upload-cloud"
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Set remote URL
20+
run: |
21+
# Attribute commits to the last committer on HEAD
22+
git config --global user.email "$(git log -1 --pretty=format:'%ae')"
23+
git config --global user.name "$(git log -1 --pretty=format:'%an')"
24+
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY"
25+
shell: bash
26+
- name: Configure trusted publishing credentials
27+
if: ${{ inputs.setup-trusted-publisher }}
28+
uses: rubygems/[email protected]
29+
- name: Run release rake task
30+
run: bundle exec rake release
31+
shell: bash
32+
- name: Wait for release to propagate
33+
if: ${{ inputs.await-release }}
34+
run: gem exec rubygems-await pkg/*.gem
35+
shell: bash

0 commit comments

Comments
 (0)