You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ci(web-sdk): publish the sdk with npm trusted publishing - #2061
The web-sdk publish for v0.122.1 failed with "Not authenticated with npm". The NPM_TOKEN secret was last updated on Aug 21. npm caps tokens that can publish at 90 days, so it most likely expired around Nov 19. The same failure happened in August.
This PR moves the @raystack/frontier publish to npm trusted publishing. GitHub Actions proves who it is to npm with a short lived OIDC token, so there is no npm token to expire or leak. npm also adds a provenance statement to each release on its own, because both the repo and the package are public.
Publishing fails until the setup below is done. Follow the steps in order.
Setup, in this order
1. A GitHub admin sets up the repo (before merge)
In repo Settings, then Environments, create an environment named npm-publish.
Required reviewers: one or two release maintainers. Turn on "Prevent self-review".
Deployment branches and tags: choose "Selected branches and tags", and add only the tag pattern v*.
Turn off "Allow administrators to bypass configured protection rules".
In repo Settings, then Rules, then Rulesets, add a tag ruleset.
Target: refs/tags/v*
Restrict creations, updates and deletions.
Bypass list: release maintainers only.
2. Merge this PR
3. The npm package owner adds the trusted publisher
This needs a user with admin rights on @raystack/frontier (today that is ravisuhag or osfreak).
Log in to npmjs.com with 2FA. Open the @raystack/frontier package, then Settings, then Trusted publishing.
Add a GitHub Actions publisher with these values. They are case sensitive, and npm does not check them on save.
Organization or user: raystack
Repository: frontier
Workflow filename: web-sdk.yml (the file name only)
Environment name: npm-publish
Allowed actions: tick npm publish only. Leave npm dist-tag unticked. New publishers allow only npm stage publish by default, and this workflow runs npm publish, so the box must be ticked.
Save. A 2 day timer starts now. An unused setup expires after 2 days, and an expired or wrong setup cannot be edited. You must delete it and add it again.
4. Push the next tag within 2 days
A maintainer pushes the next tag from main, for example v0.122.2 or v0.123.0. A reviewer approves the npm-publish deployment when GitHub asks, within 7 days.
The npm-publish environment must exist with its rules before the first tag runs. If it does not, GitHub creates it on the fly with no protection at all.
How to check the first publish
The Publish job log shows npm publish with a provenance line and no auth error.
npm view @raystack/frontier dist-tags.latest shows the new version.
npm view @raystack/frontier@<version> dist.attestations shows a provenance URL.
The npm package page shows the provenance badge, linked to the commit and to web-sdk.yml.
If the publish fails, delete the trusted publisher on npm, fix the cause, and add it again.
Hardening after the first good publish
On npm, under Settings, then Publishing access, choose "Require two-factor authentication and disallow tokens". Trusted publishing keeps working with this on.
Remove any personal npm tokens that can publish this package.
Do not revoke the org NPM_TOKEN secret yet. apsara and proton still use it. Revoke it on npm and delete the GitHub org secret only after both have moved to trusted publishing.
Optional: set the repo's default workflow permissions to read, and require SHA pinned actions.
What changed
The workflow now has two jobs.
Build (read only, no OIDC):
Checks out the tag that started the run, without keeping git credentials. Before, it always built main, so a re-run could publish newer code under an older version number.
Installs with pnpm i --frozen-lockfile, builds, and sets the version from the tag.
Fails if the package version does not match the tag. A tag like vtest stops here.
Packs the SDK with npm pack and uploads the tarball as an artifact. It also works out the npm dist-tag. The artifact is kept for 7 days, so the deployment approval has time to happen.
Uses Node 24.22.2, which ships npm 11.19.1. Trusted publishing needs npm 11.5.1 or newer. Nothing is installed from the registry.
Prints the npm version, downloads the tarball, and runs npm publish <tarball> --tag <dist-tag>. There is no checkout, no install and no build here, so no dependency code runs next to the OIDC token.
Other changes:
Every action is pinned to a full commit SHA, with its version in the step name. checkout moved from v3 to v7.0.1. pnpm/action-setup is on v5.0.0, because v6 needs pnpm 11 and this repo uses pnpm 10.
The setup-node package cache is off.
The unused GITHUB_TOKEN is gone.
A concurrency group per tag means the same tag can never publish twice at once. A run waiting for approval can not be cancelled by another tag or by a manual run from a branch.
The job only runs on v tags. A manual run from a tag still works. A manual run from a branch is skipped.
web/sdk/package.json gets a repository field. npm requires it to match the GitHub repo for trusted publishing and provenance.
Why release-it is no longer used in CI
To keep the OIDC token away from dependency code, the publish job only has the tarball. release-it needs the git checkout, node_modules and its own npm checks. Those would have to run in the publish job again. In CI, release-it only did two things: run npm publish, and pick the dist-tag. Its git steps and GitHub release were already off.
The new web/sdk/scripts/dist-tag.js picks the dist-tag the same way release-it does:
A stable version gets latest.
A prerelease gets its prerelease id. For example 0.123.0-rc.1 gets rc.
A prerelease with a number as its id, like 1.0.0-1, gets next. release-it would have guessed from tags already on npm, which today could pick an old test tag.
A prerelease id that npm would read as a version range, like x, also gets next, because npm rejects such dist-tags.
The version still comes from the tag through bump-version. The local release and release:dry scripts and .release-it.json are back to what they were on main.
How it was checked
actionlint on web-sdk.yml: clean.
Ran the build side by hand on a copy of web/sdk:
With a v0.122.2 tag, the version bump and the version check pass.
npm pack writes raystack-frontier-0.122.2.tgz, and the tarball has the repository field.
The dist-tag script prints latest.
A vtest tag fails the version check.
npm publish <tarball> --tag latest --dry-run with npm 11.19.1 prints "Publishing to https://registry.npmjs.org/ with tag latest and public access".
A real publish can only be tested after the setup above, with the next tag.
Notes
v0.122.1 is still missing on npm. Its tag runs the old workflow file. It needs either a fresh token or shipping the fix in the next version.
A stable patch on an older release line would still move latest. release-it behaved the same way.
actions/checkout@v3 and the tag pinned actions in the other workflows are not changed here.
The release:ci script is no longer used by CI. It is left as it was on main and can be removed later.
Dependabot may bump the pinned SHAs without updating the versions in the step names. Update the names along with those bumps.
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Chores
SDK package releases now follow version tags. Stable versions use the latest distribution tag, while prereleases use a tag based on their prerelease identifier.
Packages are checked against their version tag before publication, helping ensure the published version matches the release.
SDK package metadata now includes its repository location and directory.
The workflow now separates version-tag builds and package creation from npm publication. Package metadata identifies the repository, and a script derives the npm distribution tag from the SDK version.
Changes: SDK release
Layer / File(s)
Summary
Configure and validate tagged builds .github/workflows/web-sdk.yml
The build job runs for version-tag refs. It uses a frozen install and checks that the package version matches the tag. Actions use pinned revisions, and checkout does not persist credentials.
Create the package artifact web/sdk/package.json, web/sdk/scripts/dist-tag.js, .github/workflows/web-sdk.yml
The package metadata specifies the repository and package directory. The script maps stable versions to latest and selects a prerelease tag or next. The build packs and uploads the tarball with version and tag outputs.
Publish the package .github/workflows/web-sdk.yml
A separate job downloads the tarball and publishes it with the build’s version and tag. The job uses the npm-publish environment and OIDC permission.
This change moves SDK publishing to npm trusted publishing with a separate build job and publish job. No concrete defect was found. A GitHub admin and an npm package admin must finish the environment and publisher setup before the first tag run can publish.
Pre-merge checks: 2
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 47b4259 and e7b2253.
Files selected for processing: 3
.github/workflows/web-sdk.yml
web/sdk/package.json
web/sdk/scripts/dist-tag.js
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
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
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.
Why
The web-sdk publish for v0.122.1 failed with "Not authenticated with npm". The
NPM_TOKENsecret was last updated on Aug 21. npm caps tokens that can publish at 90 days, so it most likely expired around Nov 19. The same failure happened in August.This PR moves the
@raystack/frontierpublish to npm trusted publishing. GitHub Actions proves who it is to npm with a short lived OIDC token, so there is no npm token to expire or leak. npm also adds a provenance statement to each release on its own, because both the repo and the package are public.Publishing fails until the setup below is done. Follow the steps in order.
Setup, in this order
1. A GitHub admin sets up the repo (before merge)
npm-publish.v*.refs/tags/v*2. Merge this PR
3. The npm package owner adds the trusted publisher
This needs a user with admin rights on
@raystack/frontier(today that is ravisuhag or osfreak).@raystack/frontierpackage, then Settings, then Trusted publishing.raystackfrontierweb-sdk.yml(the file name only)npm-publishnpm publishonly. Leavenpm dist-tagunticked. New publishers allow onlynpm stage publishby default, and this workflow runsnpm publish, so the box must be ticked.4. Push the next tag within 2 days
A maintainer pushes the next tag from main, for example
v0.122.2orv0.123.0. A reviewer approves thenpm-publishdeployment when GitHub asks, within 7 days.The
npm-publishenvironment must exist with its rules before the first tag runs. If it does not, GitHub creates it on the fly with no protection at all.How to check the first publish
npm publishwith a provenance line and no auth error.npm view @raystack/frontier dist-tags.latestshows the new version.npm view @raystack/frontier@<version> dist.attestationsshows a provenance URL.web-sdk.yml.If the publish fails, delete the trusted publisher on npm, fix the cause, and add it again.
Hardening after the first good publish
NPM_TOKENsecret yet. apsara and proton still use it. Revoke it on npm and delete the GitHub org secret only after both have moved to trusted publishing.What changed
The workflow now has two jobs.
Build (read only, no OIDC):
main, so a re-run could publish newer code under an older version number.pnpm i --frozen-lockfile, builds, and sets the version from the tag.vteststops here.npm packand uploads the tarball as an artifact. It also works out the npm dist-tag. The artifact is kept for 7 days, so the deployment approval has time to happen.Publish (environment
npm-publish,id-token: write):npm publish <tarball> --tag <dist-tag>. There is no checkout, no install and no build here, so no dependency code runs next to the OIDC token.Other changes:
GITHUB_TOKENis gone.vtags. A manual run from a tag still works. A manual run from a branch is skipped.web/sdk/package.jsongets arepositoryfield. npm requires it to match the GitHub repo for trusted publishing and provenance.Why release-it is no longer used in CI
To keep the OIDC token away from dependency code, the publish job only has the tarball. release-it needs the git checkout,
node_modulesand its own npm checks. Those would have to run in the publish job again. In CI, release-it only did two things: runnpm publish, and pick the dist-tag. Its git steps and GitHub release were already off.The new
web/sdk/scripts/dist-tag.jspicks the dist-tag the same way release-it does:latest.0.123.0-rc.1getsrc.1.0.0-1, getsnext. release-it would have guessed from tags already on npm, which today could pick an old test tag.x, also getsnext, because npm rejects such dist-tags.The version still comes from the tag through
bump-version. The localreleaseandrelease:dryscripts and.release-it.jsonare back to what they were on main.How it was checked
web-sdk.yml: clean.web/sdk:v0.122.2tag, the version bump and the version check pass.npm packwritesraystack-frontier-0.122.2.tgz, and the tarball has therepositoryfield.latest.vtesttag fails the version check.npm publish <tarball> --tag latest --dry-runwith npm 11.19.1 prints "Publishing to https://registry.npmjs.org/ with tag latest and public access".Notes
latest. release-it behaved the same way.actions/checkout@v3and the tag pinned actions in the other workflows are not changed here.release:ciscript is no longer used by CI. It is left as it was on main and can be removed later.