Skip to content

ci(release): gate RubyGems publishing behind an environment and verify publish_tag - #132

Merged
mogita merged 4 commits into
GetStream:masterfrom
martinmitrevski:ci/gate-release-publishing
Nov 25, 2026
Merged

mogita merged 4 commits into
GetStream:masterfrom
martinmitrevski:ci/gate-release-publishing

Conversation

@martinmitrevski

@martinmitrevski martinmitrevski commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What

  • The publish job runs in a new rubygems environment.
  • publish_tag is checked out as refs/tags/<tag>, so a value that names a branch or a SHA no longer checks anything out.
  • A new step, run before any project code and before the OIDC token is minted, checks three things: publish_tag is exactly a tag (git show-ref --verify, so revision syntax such as v1.2.3~1 is rejected); the run comes from the default branch or an N.x branch; and the tag's commit is on that branch (git merge-base --is-ancestor). Before this, any tag could be published, including one pushed on a commit that was never reviewed.

Why

Security audit finding CI-03. Part of SEC-2515. The RubyGems OIDC publish job had no environment gate, and it checked out any publish_tag it was given.

Settings needed for this to take effect

A run from another branch uses that branch's copy of release.yml, so these settings, not the in-workflow checks, are what stop a modified copy:

  • rubygems environment: GitHub creates it with no protection on the first run. Add required reviewers, and set deployment branches to master and *.x. Protect *.x with a branch ruleset first (SEC-2513).
  • rubygems.org → getstream-ruby → Trusted Publisher: set the environment to rubygems. Once RubyGems has an environment set, it rejects tokens from any other environment.
  • Tag ruleset on refs/tags/v*. release-please creates the tags with this workflow's GITHUB_TOKEN, so the ruleset must let GitHub Actions through, or releases stop getting tagged. Letting GitHub Actions through also lets any workflow with contents: write create tags. Tagging with getstream-sdk-bot instead would let the ruleset trust only that app.

Merge order

  1. Merge this PR.
  2. Configure the rubygems environment as listed above.
  3. Before the next release, pin rubygems on the rubygems.org trusted publisher. Don't pin it before this PR merges: the current job runs without an environment, so a pinned publisher would reject its token.

Behaviour change

  • Once reviewers are set, every release waits for one approval before publishing.
  • Republishing a hotfix tag with publish_tag has to be dispatched from its N.x branch, not master.

Testing

  • actionlint 1.7.12 with shellcheck 0.11.0: no new findings.
  • Extracted the new step's script from the YAML and ran it against real history in this repository and the other server-side SDKs. Real release tags pass. A tag dispatched from a branch it isn't on fails. A branch name, a SHA, a tag that doesn't exist and a feature-branch dispatch all fail with a clear error.
  • Not run end to end, because that needs a real release.

🤖 Generated with Claude Code

martinmitrevski and others added 3 commits November 25, 2026 10:34
…y publish_tag

Run the publish job in the rubygems environment. Check out publish_tag
as refs/tags/<tag>, and publish it only if its commit is on the release
branch the run was dispatched from.

Part of SEC-2515.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g check

Review follow-up. Reject revision syntax such as v1.2.3~1, which
resolved to an untagged commit, and accept only the default branch or a
branch named N.x, since *.x also matched feature/foo.x.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The workflow triggers on any *.x branch, so a 4.1.x hotfix branch has
to pass this check too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mogita
mogita merged commit 399cc2b into GetStream:master Nov 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants