Skip to content

ci(release): run publish and upload in a release environment and verify publish_tag - #149

Merged
mogita merged 4 commits into
mainfrom
ci/gate-release-publishing
Nov 25, 2026
Merged

mogita merged 4 commits into
mainfrom
ci/gate-release-publishing

Conversation

@martinmitrevski

@martinmitrevski martinmitrevski commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What

  • publish (signing key, Maven Central credentials) and upload (R2 credentials) run in a new release environment. Those secrets can then move out of org scope into that 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 findings CI-02 and CI-03. Part of SEC-2514 and SEC-2515. Nine long-lived org secrets reach this repository with no environment gate, so any workflow on any branch can read them. The publish job also checked out any publish_tag it was given.

Settings needed for this to take effect (in this order)

  1. Merge this PR. If the secrets move first, releases break until it merges.
  2. Create the release environment: add required reviewers, and set deployment branches to main and *.x. Protect *.x with a branch ruleset first.
  3. Add the release environment secrets: GPG_KEY_CONTENTS, SIGNING_KEY_ID, SIGNING_PASSWORD, OSSRH_USERNAME, OSSRH_PASSWORD, STREAM_REPO_ACCESS_KEY_ID, STREAM_REPO_SECRET_ACCESS_KEY, STREAM_REPO_BUCKET, STREAM_REPO_ENDPOINT. Org secret values can't be read back, so the values have to come from whoever owns these credentials.
  4. Remove stream-sdk-java from repository access on those nine org secrets.
  5. Tag ruleset on refs/tags/[0-9]* (this repository's tags have no v). release-please creates them with this workflow's GITHUB_TOKEN, so the ruleset must let GitHub Actions through.

Behaviour change

  • Once reviewers are set, a release waits for two approvals, one for publish and then one for upload, because GitHub checks reviewers per job. If that's too much, upload could use a second environment that has the branch rule but no reviewers.
  • Republishing a hotfix tag with publish_tag has to be dispatched from its N.x branch.

Not in this PR

Moving the R2 upload to OIDC, which the audit also recommends. It needs support in GetStream/stream-build-conventions-android's publish-to-stream-repo action.

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.

Notes

#146 changes the setup-gradle step in the same job. The changes don't overlap.

🤖 Generated with Claude Code


Note

High Risk
Touches the release signing and artifact publish path; misconfiguration of the new environment or branch rules could block releases or leave secrets exposed until follow-up settings are applied.

Overview
Publish and upload jobs now target a dedicated release GitHub Environment so signing, Maven Central, and R2 secrets can live only there instead of org/repo secrets readable from any workflow branch.

Checkout for publishing uses refs/tags/<tag> with full history, and a new Verify the tag is on this release branch step runs before Gradle: the workflow must be on main or an N.x branch, publish_tag must be a real tag (not branch/SHA/revision syntax), and that tag’s commit must be an ancestor of the branch head—blocking publish of arbitrary or unreviewed tags via workflow_dispatch.

Reviewed by Cursor Bugbot for commit c3b5e8c. Bugbot is set up for automated code reviews on this repo. Configure here.

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

Run the jobs that use the signing, Maven Central and R2 credentials in
the release environment, so those secrets can move out of org scope.
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-2514, 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 316fa49 into main Nov 25, 2026
11 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