Skip to content

Publish @docsy/theme via npm trusted publishing (OIDC) - #2708

Merged
chalin merged 22 commits into
docsy:mainfrom
chalin:chalin-m24-trusted-publishing-2026-0808
Aug 9, 2026
Merged

chalin merged 22 commits into
docsy:mainfrom
chalin:chalin-m24-trusted-publishing-2026-0808

Conversation

@chalin

@chalin chalin commented Aug 8, 2026 •

Copy link
Copy Markdown
Collaborator
  • Publish workflow (new, tag-triggered): a stable vX.Y.Z tag 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 the npm-publish environment, 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.
  • Guards (scripts/publish-guards.mjs, tested, wired into test:tooling): fail before an immutable mispublish, on
    • a tag off main's history (release tags come from main only; a release-branch patch flow needs a deliberate widening first)
    • a tag/stamped-version mismatch
    • a non-stable or npm-invalid version
    • npm below the OIDC floor
    • an unreviewed publishConfig
    • a candidate below the registry's current latest (publish job)
  • Maintainer notes step 15: reworked around the CI flow; start review there (pre-approval runbook, dist-tag auth window, manual prerelease and fallback commands, the main-only constraint).
  • Root .npmrc: pins the @docsy scope registry for manual commands (a user-level scope mapping outranks --registry).
  • One-time maintainer setup — hard prerequisites, not suggestions: the in-repo guards bind against mistakes only (on tag pushes the workflow definition travels with the tag), so these controls are what bound malice. No release tag until all are done.
    • Before merge: create the protected npm-publish environment (required reviewers, self-review prevented, admin bypass off) — GitHub auto-creates a bare, unprotected environment on first workflow reference otherwise.
    • Before merge: a ruleset restricting v* tag creation to maintainers; confirm main's protection stays.
    • After merge: register the npmjs trusted publisher (workflow publish.yaml, environment npm-publish, allowed actions npm publish only; the form requires the workflow file to exist on the repo).
  • Preview: maintainer notes § Publishing a release

chalin added 9 commits August 9, 2026 09:35
- 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
chalin force-pushed the chalin-m24-trusted-publishing-2026-0808 branch from d8ec73d to 682a638 Compare August 9, 2026 13:38
chalin added 5 commits August 9, 2026 10:07
- 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
chalin marked this pull request as ready for review August 9, 2026 16:35
chalin added 5 commits August 9, 2026 13:06
- 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
@chalin chalin added this to the 0.17.0 milestone Aug 9, 2026
chalin added 3 commits August 9, 2026 14:03
- 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
@chalin
chalin merged commit 4af20a9 into docsy:main Aug 9, 2026
16 checks passed
@chalin
chalin deleted the chalin-m24-trusted-publishing-2026-0808 branch August 9, 2026 18:27
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.

1 participant