Skip to content

ci(web-sdk): publish the sdk with npm trusted publishing - #2061

Open
rohilsurana wants to merge 18 commits into
mainfrom
ci/npm-trusted-publishing
Open

rohilsurana wants to merge 18 commits into
mainfrom
ci/npm-trusted-publishing

Conversation

@rohilsurana

@rohilsurana rohilsurana commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Why

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)

  1. 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".
  2. 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).

  1. Log in to npmjs.com with 2FA. Open the @raystack/frontier package, then Settings, then Trusted publishing.
  2. 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.
  3. 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.

Publish (environment npm-publish, id-token: write):

  • 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.

@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
frontier Ready Ready Preview Nov 23, 2026 5:00pm UTC

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Suggested reviewers: rsbh, pyadav

Merge Risk: Minimal · up to e7b22

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: Passed 2

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

Recent review info

Run configuration

Commits

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.

@coveralls

coveralls commented Nov 23, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 45222806253

Coverage remained the same at 56.466%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 42493
Covered Lines: 23994
Line Coverage: 56.47%
Coverage Strength: 21.86 hits per line

💛 - Coveralls

This branch was successfully deployed

1 active deployment
Preview — e7b2253d Deployed Nov 23, 2026 by vercel[bot]
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.

2 participants