You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cb35e9b
Browse filesBrowse the repository at this point in the historyBrowse files
Check RubyGems Trusted Publishing before every release
Add RubyGemsCredentials#check!, which performs the real OIDC token
request and exchange, verifies push_rubygem scope, and reports the
matched repository, workflow, and environment claims without exporting
the short-lived credential. Rejected exchanges now name those claims.
A Workflow::Preflight runner and release:workflow:preflight task run
the check, skipping it for non-RubyGems destinations. Both Actions
interfaces run it after context capture, before validation, edits, or
publication, so a missing publisher or id-token permission fails
before anything is pushed or published. The reusable workflow's
dry-run input runs only the preflight in the release environment; the
self-release caller passes it through.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Gr21hZDQo5axDMuFgzL6s
-[#82](https://github.com/dblock/ruby-gem-release/pull/82): Create the default package and Git temporary directories only when release data is first used, so loading a workflow leaves none behind - [@dblock](https://github.com/dblock).
8
8
-[#83](https://github.com/dblock/ruby-gem-release/pull/83): Name Intridea subsections with `sections:`, dropping sections without notes from a release and starting every Next section with all of them - [@dblock](https://github.com/dblock).
9
+
-[#85](https://github.com/dblock/ruby-gem-release/pull/85): Verify RubyGems Trusted Publishing before every release with a `release:workflow:preflight` task, add a `dry-run` workflow input that runs only that check, and name the token claims in rejected exchanges - [@dblock](https://github.com/dblock).
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,8 @@ gh api --method PUT repos/{owner}/{repo}/environments/release
70
70
71
71
For a new gem, open the [pending trusted publishers page](https://rubygems.org/profile/oidc/pending_trusted_publishers). For an existing gem, open your existing gem's **Trusted publishers** page (e.g. `https://rubygems.org/gems/example/trusted_publishers`). Create a [trusted publisher](https://guides.rubygems.org/trusted-publishing/#using-reusable-workflows). Set the repository fields to your gem's repository, the workflow filename to `release.yml`, and the environment to `release`. Set the separate workflow repository fields to `dblock` and `ruby-gem-release`; these identify the reusable workflow RubyGems verifies in the OIDC token.
72
72
73
+
To verify this setup without releasing, dispatch a [dry run](docs/actions/release.md#dry-run).
74
+
73
75
Collaborators with write access can dispatch releases after this setup, without repository admin access or their own RubyGems credentials. Creating the environment alone does not restrict publication. Configure [required maintainer approval and deployment branches](RELEASING.md#maintainer-approved-publication) to control who approves publication.
Copy file name to clipboardExpand all lines: RELEASING.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ bundle exec rake build
40
40
41
41
The manual **Release** caller is [`.github/workflows/publish.yml`](.github/workflows/publish.yml). Merges and schedules do not publish. It uses Ruby 4.0, the root Rakefile, and `America/New_York` for release dates and Git timestamp offsets.
42
42
43
-
Verify the existing RubyGems trusted publisher before dispatch. The caller passes the non-secret `RUBYGEMS_OWNER_ID` repository variable when set; this identifies an account, not an API key. Pending publishers need it for first publication.
43
+
Verify the existing RubyGems trusted publisher before dispatch with a [dry run](docs/actions/release.md#dry-run), which exchanges credentials without releasing: `gh workflow run publish.yml --ref master -f dry-run=true`. The caller passes the non-secret `RUBYGEMS_OWNER_ID` repository variable when set; this identifies an account, not an API key. Pending publishers need it for first publication.
44
44
45
45
Only after explicit authorization, successful validation, and confirmed setup:
Copy file name to clipboardExpand all lines: docs/actions/action.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,8 @@ Register a RubyGems trusted publisher for the calling repository, its own workfl
68
68
69
69
For maintainer-only publication, protect the caller job's `release` environment using [Maintainer-Approved Publication](../../RELEASING.md#maintainer-approved-publication). Other repository writers can dispatch, but publication waits for a designated maintainer to approve. Environments do not restrict who can dispatch, and an environment without protection rules does not restrict release access.
70
70
71
+
The action checks [release prerequisites](release.md#release-prerequisites), including the trusted publisher, after context capture and before validation, edits, or publication. To check without releasing, run `bundle exec rake release:workflow:preflight` in a job of the same workflow file, in the `release` environment, with `id-token: write`. RubyGems matches the workflow file and environment, so a check from another workflow or environment does not prove the release job's configuration. The composite action has no dry-run input.
72
+
71
73
For first publication, register a pending trusted publisher and supply its numeric account ID through `rubygems-owner`. Later publications can omit that input. The default `release:publish` task authenticates through the configured destination before invoking its publication callback; no separate YAML authentication step is needed. The RubyGems destination uses the [Ruby credentials helper](../workflow/ruby_gems_credentials.md) without a stored API key. It exports environment variables and does not create or modify `~/.gem/credentials`. Command overrides that bypass the task must own authentication as well as publication.
Copy file name to clipboardExpand all lines: docs/actions/release.md
+48-18Lines changed: 48 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,27 +8,57 @@ For a step-based interface with caller-owned job settings, see the [Composite Ac
8
8
9
9
Set these under the calling job's `with:` mapping. Only `ruby-version` is required.
10
10
11
-
| Input | Type | Default | Behavior |
12
-
| --- | --- | --- | --- |
13
-
|`ruby-version`| String | Required | Ruby version used for validation and building. |
14
-
|`version`| String | Empty | Selected numeric `MAJOR.MINOR.PATCH` release version, without leading zeros. Overrides the checked-in version in standard preparation. |
15
-
|`gemspec`| String | Empty | Specification path, defaulting to the only root gemspec. Missing or ambiguous specifications fail. |
16
-
|`rubygems-owner`| String | Empty | Numeric RubyGems account ID required for a new gem's pending trusted publisher to create it. |
17
-
|`timezone`| String |`UTC`| Installed timezone identifier for the release calendar date and Git timestamp offsets. |
18
-
|`prepare-artifacts`| String | Empty | Trusted command preparing explicitly selected input archives after setup, before capture. |
|`validate`| String |`bundle exec rake release:validate`| Check release preconditions before edits; exit nonzero on failure. |
21
-
|`prepare`| String |`bundle exec rake release:prepare`| Prepare release files before version resolution and testing. |
22
-
|`test`| String |`bundle exec rake`| Test prepared release files before publication. |
23
-
|`publish`| String |`bundle exec rake release:publish`| Commit, build, tag, publish to RubyGems, push atomically, and create a GitHub Release through the configured callback. |
24
-
|`bump`| String |`bundle exec rake release:bump`| Prepare, commit, and push the next development iteration through the configured callback. |
25
-
|`success`| String |`bundle exec rake release:success`| Run after publication and the next development iteration succeed. |
26
-
|`failure`| String |`bundle exec rake release:failure`| Run after a release job failure, after Ruby setup. |
27
-
|`git-user-name`| String |`github-actions[bot]`| Checkout-local author name for release and next development iteration commits. |
28
-
|`git-user-email`| String |`github-actions[bot]@users.noreply.github.com`| Checkout-local author email for release and next development iteration commits. |
11
+
| Input | Type | Default | Behavior |
12
+
| --- | --- | --- | --- |
13
+
|`ruby-version`| String | Required | Ruby version used for validation and building. |
14
+
|`version`| String | Empty | Selected numeric `MAJOR.MINOR.PATCH` release version, without leading zeros. Overrides the checked-in version in standard preparation. |
15
+
|`gemspec`| String | Empty | Specification path, defaulting to the only root gemspec. Missing or ambiguous specifications fail. |
16
+
|`rubygems-owner`| String | Empty | Numeric RubyGems account ID required for a new gem's pending trusted publisher to create it. |
17
+
|`timezone`| String |`UTC`| Installed timezone identifier for the release calendar date and Git timestamp offsets. |
18
+
|`prepare-artifacts`| String | Empty | Trusted command preparing explicitly selected input archives after setup, before capture. |
|`validate`| String |`bundle exec rake release:validate`| Check release preconditions before edits; exit nonzero on failure. |
21
+
|`prepare`| String |`bundle exec rake release:prepare`| Prepare release files before version resolution and testing. |
22
+
|`test`| String |`bundle exec rake`| Test prepared release files before publication. |
23
+
|`publish`| String |`bundle exec rake release:publish`| Commit, build, tag, publish to RubyGems, push atomically, and create a GitHub Release through the configured callback. |
24
+
|`bump`| String |`bundle exec rake release:bump`| Prepare, commit, and push the next development iteration through the configured callback. |
25
+
|`success`| String |`bundle exec rake release:success`| Run after publication and the next development iteration succeed. |
26
+
|`failure`| String |`bundle exec rake release:failure`| Run after a release job failure, after Ruby setup. |
27
+
|`git-user-name`| String |`github-actions[bot]`| Checkout-local author name for release and next development iteration commits. |
28
+
|`git-user-email`| String |`github-actions[bot]@users.noreply.github.com`| Checkout-local author email for release and next development iteration commits. |
29
+
|`dry-run`| Boolean |`false`| Check release prerequisites, such as RubyGems Trusted Publishing, without editing files, pushing, or publishing. See [Dry Run](#dry-run). |
29
30
30
31
Identity values must be nonempty and contain no line breaks. They change commit attribution, not authentication or push permissions.
31
32
33
+
### Release Prerequisites
34
+
35
+
Every release runs `bundle exec rake release:workflow:preflight` after context capture, before validation, edits, or publication, so missing permissions fail before anything is pushed or published. The preflight requests the job's OIDC token and exchanges it at RubyGems exactly as publication does, passing `rubygems-owner` when set. Success proves that the caller granted `id-token: write` and that a trusted publisher matches the repository, workflow, and environment in the token. The job reports those claims and the credential's scopes; on failure, the error names the claims RubyGems rejected. The exchanged credential is masked, expires after 15 minutes, and is never exported or used; publication performs its own exchange. RubyGems does not report which gems a publisher is attached to, so the preflight cannot confirm that the publisher belongs to this gem, or that RubyGems would accept the package.
36
+
37
+
### Dry Run
38
+
39
+
Set `dry-run: true` to run only the release prerequisites. A separate `preflight` job runs instead of the `release` job, in the same `release` environment, so required reviewers still approve it. It checks out the caller without persisted credentials, installs the bundle, and runs the same [prerequisite checks](#release-prerequisites). It never edits files, commits, tags, pushes, builds, or publishes.
40
+
41
+
To dispatch dry runs, add a boolean input to the caller and pass it through:
42
+
43
+
```yaml
44
+
on:
45
+
workflow_dispatch:
46
+
inputs:
47
+
dry-run:
48
+
description: Check release prerequisites without releasing.
Then run `gh workflow run release.yml -f dry-run=true`.
61
+
32
62
### Release Validation
33
63
34
64
Validation runs after context capture, before preparation edits. Empty pending notes fail unless the selected release already has a changelog heading, allowing repetition. Malformed content also fails. With no changelog, validation passes. Custom changelog objects implement `pending?` and `released?(version)` or supply a `validate:` callback.
Copy file name to clipboardExpand all lines: docs/tasks.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,4 +62,6 @@ The [Detailed Usage example](usage.md#custom-callbacks) commits, builds, tags, p
62
62
63
63
## Workflow Credentials
64
64
65
+
`release:workflow:preflight` checks release prerequisites without editing files, pushing, or publishing. With a RubyGems destination it verifies Trusted Publishing through [`Workflow::RubyGemsCredentials#check!`](workflow/ruby_gems_credentials.md#check) with optional `RUBYGEMS_OWNER_ID`; other destinations skip that check. Both Actions interfaces run it in every release after context capture, and the reusable workflow runs only it for [dry runs](actions/release.md#dry-run).
66
+
65
67
`release:workflow:credentials` directly invokes [`Workflow::RubyGemsCredentials`](workflow/ruby_gems_credentials.md) with optional `RUBYGEMS_OWNER_ID`. It remains available for custom RubyGems commands, but neither Actions interface calls a separate authentication task. Normal authentication belongs to `release:publish` through the configured destination.
0 commit comments