Repository navigation
ci(prerelease): gate npm publish behind a protected environment - #295
Merged
Merged
Conversation
Split the workflow into a test job without id-token: write and a publish job that runs in the protected npm-prerelease environment. Pass the event name, dispatch input, ref name and channel tag through env: instead of interpolating them into run: blocks, and reject any tag outside alpha, beta and rc. Refs #286
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #286 (M22). Part of fells-code/seamless-auth-api#603, step 6.
What changed
.github/workflows/prerelease.ymlnow has two jobs.testruns withcontents: readonly. It works out the channel, checks for pending changesets, installs and runspnpm test. Code on a pusheddevorrelease/**branch no longer runs in a job that can mint an npm OIDC token.publishneedstest, runs only when changesets are pending, and runs in thenpm-prereleaseenvironment. It is the only job withid-token: write. With required reviewers on the environment, every prerelease publish waits for an approval.Injection hardening:
github.event_name,inputs.tag,github.ref_nameand the channel output reach the shell throughenv:and are quoted. No${{ }}expression is left inside arun:block.alpha,betaorrc, otherwise the job fails before any publish.persist-credentials: false.The other workflows were checked for the same pattern.
ci.yml,conformance.yml,manifest.ymlandrelease.ymlhave no${{ }}insiderun:blocks (only inenv:,with:,concurrencyand job names), so they are unchanged.release.ymlalso publishes withid-token: writeand no environment. That is outside M22 and is left for a follow-up.No changeset: this is a CI-only change with no package impact.
Required before merge
Checked read-only on 2026-11-20: the repo has no environments, its only ruleset (
dev) is disabled and targets no refs,release/**has no effective rules, anddevhas no branch protection. The npm trusted-publisher binding is not visible from GitHub.Without the environment below, GitHub creates
npm-prereleaseautomatically on the first run with no protection, so the gate does nothing until it is configured. These settings must exist before this merges:npm-prerelease(Settings, Environments):devandrelease/**.release/**(Settings, Rules, Rulesets), enforcement Active:refs/heads/release/**.@seamless-auth/core,@seamless-auth/express,@seamless-auth/fastifyand@seamless-auth/nextjs(npmjs.com, package Settings, Trusted publishing). The binding could not be read from GitHub, so check it before merge:npm-prereleaseor prerelease publishing fails.npm-prereleasewould also blockrelease.yml, which runs in no environment, so keep the environment field empty until stable releases get their own environment.prerelease.yml), not the job name, so renaming the job fromprereleasetopublishdoes not affect the binding.Checks
actionlint: clean.pnpm install --frozen-lockfile && pnpm test: all packages pass.