Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Dec 14, 2023
0 parents commit 48512b9
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
55 changes: 55 additions & 0 deletions README.md
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
35 changes: 35 additions & 0 deletions action.yml
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

0 comments on commit 48512b9

Please sign in to comment.