Repository navigation
Publish @docsy/theme via npm trusted publishing (OIDC) - #2708
Merged
chalin merged 22 commits intoAug 9, 2026
Merged
Conversation
- Adds a tag-triggered publish workflow: OIDC auth (id-token: write, no npm token), install-free job (pack contract and publish need only Node/npm built-ins), tag-vs-version and npm-floor guards, prerelease tags -> next - Maintainer notes: CI publish becomes the primary stable flow; the login-publish-logout window stays as the manual fallback and prerelease path
- Gates the publish job on an npm-publish environment (required reviewers; bound in the npmjs trusted-publisher registration): OIDC alone proves workflow identity, not release authorization, and v* tags have no ruleset - Documents prerelease-tag behavior in step 15; scopes the manual flow to untagged prereleases and CI fallback - package-manager-cache off explicitly; pack-contract assert message no longer overclaims an allowlist; caches the publish-workflow link (probe- produced entry, keeps the link-check tree-pristine guard green)
- Moves the inline workflow guards to scripts/publish-guards.mjs with colocated tests (red-first-proven) wired into test:tooling; the npm floor now derives from the engines manifest (single home) alongside the OIDC constant, since an install-free job never exercises engine-strict - Narrows the trigger to stable vX.Y.Z tags and adds a stable-version guard, aligning the mechanism with the prereleases-stay-manual policy; drops the now-unreachable dist-tag branch - Requires provenance explicitly (NPM_CONFIG_PROVENANCE): intent visible in the workflow and loud failure if attestation is unavailable, per the publish-workflow survey (otel-js pattern)
…mver - Publishes with explicit CLI flags (tag, provenance, access, registry), which outrank manifest publishConfig; the guards additionally pin publishConfig to its reviewed shape, so the manifest cannot silently redirect the registry, drop provenance, or move the dist-tag - Notes that the next re-point needs its own auth window: OIDC covers only the publish, so a token-free machine cannot dist-tag as previously written - Rejects npm-invalid stable-looking versions (leading zeros, unsafe or overlong components) in the guards, with red-first tests
- Step 15: the trigger-restriction fact moves into the manual-publishes bullet (its one home); the untagged qualifier stopped discriminating once the trigger went stable-only - Publish-step comment: drops the publishConfig rationale restated from the guard
- Forces --ignore-scripts=false on the publish command and documents it for manual publishes: the theme prepack materializes LICENSE, so a script-disabling config layer ships a malformed artifact - Adds the effective-config guard naming that cause (red-first; the missing-LICENSE pack-contract failure it preempts is correct but cryptic); samples config at the workspace root, where npm resolves it even for member publishes (npm config get rejects workspace cwds, found live)
- Guards gain an install-free check (node_modules absent) and a workflow contract (no install commands, allowlisted SHA-pinned actions only, exact permissions, required invariants), run at edit time via test:tooling and again in the publish job, covering tags on commits that skipped PR CI; the mutation tests prove each check fires - Workflow header documents the single-job decision: lifecycle-on is safe only while install-free, and the stricter no-OIDC-pack/tarball-publish split stays a documented revisit option
- pack (no OIDC grant) guards, checks the contract, and builds the tarball with theme lifecycle on; publish (id-token: write, npm-publish environment) downloads and publishes it -- a tarball publish runs no lifecycle, so the token-holding job executes no repo code by construction (actions/toolkit precedent) - Deletes the workflow-contract checker, its mutation tests, and the install-free and ignore-scripts guards: the structural split replaces the policed coupling they existed to enforce - Approval moves after the checks: the environment gate now fronts only the publish job
chalin
force-pushed
the
chalin-m24-trusted-publishing-2026-0808
branch
from
August 9, 2026 13:38
d8ec73d to
682a638
Compare
- Step 15 gains a pre-approval runbook (the environment gate is only as good as what the approver inspects) and a stable-fallback command mirroring the workflow flags, with the no-provenance caveat; manual bullet narrows to prereleases - Workflow header stops claiming the publish job executes no repo code (checkout is present for .nvmrc; the accurate claim is no lifecycle)
… fix - Serializes publish runs (concurrency group) and adds a latest-monotonicity check to the approval runbook: individually valid tags approved out of order would regress the latest dist-tag - Pins the @docsy scope registry on every manual command: a local @docsy:registry mapping outranks even --registry (pickRegistry), so unpinned commands could publish to or verify the wrong registry silently; narrows the workflow comment that overclaimed flags beat any config layer - checkGuards validates the theme version through parseVersion, closing the safe-integer and overlength bypass of the regex-only check (red-first)
- One always-on project-level pin replaces the per-command --@docsy:registry flags: project config outranks the user level, where a redirecting scope mapping would live (probed live: with the pin, a hostile userconfig mapping loses); manual commands in step 15 simplify back - CI publish is unaffected either way: its cwd is outside the checkout
Review round: the cwd fact is about the workflow and already lives in its publish-step comment; the pin comment keeps only its own scope constraint
chalin
marked this pull request as ready for review
August 9, 2026 16:35
- Pack job rejects tags on unmerged commits (ancestor of main or release, full-history checkout): the guards check the tag content for internal consistency only, so a writer-pushed tag on unreviewed history previously reached the approval gate with everything green - Publish job re-runs the guards post-approval with --registry: a candidate whose numeric core is below the registry latest fails instead of relying on approval order (prerelease-safe compare; red-first tests) - Publish job carries its own repository guard, kept redundant with pack via needs
- Cuts checks the machine owns at approval time (pack green is structural: the prompt only exists after needs: pack; tag/version and registry order are guard-owned) down to the two human checks: commit is the tip of BASE with the expected tag actor, and the run is this workflow (another one could reference the same environment)
- Workflow header and runbook state the on-push reality: the definition travels with the tag, so the checks bind against mistakes and the tag ruleset + approval bound malice; for an unexpected tag the runs green checks are untrustworthy - Runbook first check reworded to the tag-time invariant: tip-of-BASE at approval time false-rejects legitimate releases when unrelated merges land after tagging, training approvers to rationalize
- Narrows the ancestry check to main (owner decision): one protected branch is the whole trust surface, and a release-branch patch flow now needs a deliberate workflow widening instead of silently trusting an unprotected branch - Maintainer notes step 15 states the constraint at the flow it affects
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.
vX.Y.Ztag runs a two-job pipeline; prereleases stay manual.pack(no OIDC grant, install-free): tag-on-main ancestry check, guards, pack contract, tarball build.publish(gated on thenpm-publishenvironment, 15-minute timeout): re-runs the guards against the registry, then publishes the tarball through trusted publishing, so no npm token exists anywhere and no lifecycle script runs with the OIDC grant.scripts/publish-guards.mjs, tested, wired intotest:tooling): fail before an immutable mispublish, onmain's history (release tags come frommainonly; arelease-branch patch flow needs a deliberate widening first)publishConfiglatest(publish job).npmrc: pins the@docsyscope registry for manual commands (a user-level scope mapping outranks--registry).npm-publishenvironment (required reviewers, self-review prevented, admin bypass off) — GitHub auto-creates a bare, unprotected environment on first workflow reference otherwise.v*tag creation to maintainers; confirmmain's protection stays.publish.yaml, environmentnpm-publish, allowed actionsnpm publishonly; the form requires the workflow file to exist on the repo).