ci(publish): tag-driven npm publish with OIDC trusted publishing#24
Merged
Conversation
Replaces the existing publish workflow with a tag-driven flow that: - Triggers on push of a `v*` tag (primary) or `workflow_dispatch` with a custom dist-tag (escape hatch). - Verifies the pushed tag matches the version field in all three publishable package.json files (fail-fast if they drift). - Runs `pnpm -r build` and `pnpm exec vitest --run` before publishing so a broken artifact never reaches the registry. - Infers the npm dist-tag from the version suffix: -alpha. → alpha, -beta. → beta, -rc./next. → next, plain → latest. - Publishes all three packages in dependency order (core, then transport-websocket, then react) so the registry resolves @tabmesh/core before its dependents are fetched. - Uses npm OIDC trusted publishing (id-token: write + setup-node with registry-url) and the --provenance flag. No NPM_TOKEN secret needed; the GitHub Actions OIDC token is exchanged for a short-lived publish credential at the registry. Also adds `scripts/release.mjs` — a small helper that bumps all three package.json versions in lockstep, updates the peer-dependency on @tabmesh/core in the two dependents to match exactly (no caret — pre-1.0 versions are deliberately strict), and creates the matching git tag locally. The user pushes the tag when they're ready. Sample release flow: node scripts/release.mjs 0.1.0-alpha.0 git push origin main --tags # workflow runs, all three packages publish under @Alpha Setup required before the first publish (one-time, on npm side): 1. Create the `tabmesh` org on npmjs.com. 2. For each of @tabmesh/{core,react,transport-websocket}: Settings → Publishing access → Add trusted publisher Repository: CodeThicket/tabmesh Workflow file: publish.yml Environment: (empty)
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.
Summary
Step 10 of the release sequence. Replaces the existing release-trigger NPM_TOKEN workflow with the tag-driven OIDC trusted publishing flow we agreed on during the grilling pass.
What changes
`.github/workflows/publish.yml` (rewrite)
`scripts/release.mjs` (new)
Helper that bumps all three `package.json` versions in lockstep, pins the `@tabmesh/core` peer-dep in the two dependents to the exact target version, commits, and creates the local tag.
Sample flow:
```bash
node scripts/release.mjs 0.1.0-alpha.0
git push origin main --tags
workflow runs, all three publish under @Alpha
```
Setup required before the first publish (one-time, npm-side, you do this)
Test plan