-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 48512b9
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Release Gem GitHub Action | ||
|
||
This action allows you to automate releasing your gems to RubyGems.org. | ||
|
||
## Usage | ||
|
||
### Trusted Publishing | ||
|
||
This example jumps right into RubyGems.org's current reccomended best practice. | ||
|
||
This action supports RubyGems.org's [trusted publishing] implementation, | ||
which allows authenticating to RubyGems.org without manually configuring secrets. | ||
To perform [trusted publishing] with this action, your projects publisher must already be | ||
[configured on RubyGems.org]. | ||
|
||
To enter the trusted publishing flow, configure this action's job with the | ||
`id-token: write` permission. | ||
|
||
```yaml | ||
# .github/workflows/push_gem.yml | ||
jobs: | ||
push: | ||
name: Push gem to RubyGems.org | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag | ||
|
||
steps: | ||
# Set up | ||
- uses: actions/checkout@v4 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
bundler-cache: true | ||
ruby-version: ruby | ||
|
||
# Release | ||
- uses: rubygems/release-gem@v1 | ||
``` | ||
### Requirements | ||
For now, this action makes several assumptions about your project: | ||
1. Your workflow checks out the repository & configures a working Ruby environment | ||
2. Your project uses [bundler] to manage dependencies | ||
3. Your project has the [bundler release tasks] configured | ||
4. Your gem has [trusted publishing] [configured on RubyGems.org] | ||
[bundler]: https://bundler.io | ||
[bundler release tasks]: https://bundler.io/guides/creating_gem.html#releasing-the-gem | ||
[configured on RubyGems.org]: https://guides.rubygems.org/trusted-publishing/adding-a-publisher/ | ||
[trusted publishing]: https://guides.rubygems.org/trusted-publishing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: "Release Gem" | ||
description: "Upload gems to RubyGems.org" | ||
inputs: | ||
await-release: | ||
description: "Whether to poll for the release to be available on RubyGems.org" | ||
required: false | ||
default: "true" | ||
setup-trusted-publisher: | ||
description: "Whether to setup the trusted publisher for the gem" | ||
required: false | ||
default: "true" | ||
outputs: {} | ||
branding: | ||
color: "red" | ||
icon: "upload-cloud" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set remote URL | ||
run: | | ||
# Attribute commits to the last committer on HEAD | ||
git config --global user.email "$(git log -1 --pretty=format:'%ae')" | ||
git config --global user.name "$(git log -1 --pretty=format:'%an')" | ||
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY" | ||
shell: bash | ||
- name: Configure trusted publishing credentials | ||
if: ${{ inputs.setup-trusted-publisher }} | ||
uses: rubygems/[email protected] | ||
- name: Run release rake task | ||
run: bundle exec rake release | ||
shell: bash | ||
- name: Wait for release to propagate | ||
if: ${{ inputs.await-release }} | ||
run: gem exec rubygems-await pkg/*.gem | ||
shell: bash |