Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ jobs:
registry-url: https://registry.npmjs.org
# npm 11.21 supports private dist-tag reads through trusted publishing.
- run: npm install --global npm@11.21.0
- name: Check trusted publisher access
- name: Check npm publishing access
run: npm dist-tag ls @dev.smartpricing/traceflow-sdk --json
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN || secrets.NO_TWOFA_NPM_TOKEN }}

# Kafka is needed only for its declarations; do not build its native addon.
- run: npm ci --ignore-scripts
Expand All @@ -64,11 +66,15 @@ jobs:
- name: Verify the npm archive
run: npm run test:package -- "$RUNNER_TEMP/traceflow-sdk.tgz"

- name: Publish to npm with trusted publishing
- name: Publish to npm
run: npm publish "$RUNNER_TEMP/traceflow-sdk.tgz" --tag latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN || secrets.NO_TWOFA_NPM_TOKEN }}

- name: Verify published latest version
# OIDC supports dist-tag, but npm view needs a separate read token for private packages.
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN || secrets.NO_TWOFA_NPM_TOKEN }}
run: |
node --input-type=module <<'NODE'
import assert from 'node:assert/strict';
Expand Down
14 changes: 11 additions & 3 deletions js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,15 @@ archive, then publishes that same archive. It verifies npm's `latest` tag after
publishing. The existing `release/X.Y.Z` flow is also supported: commit version
`X.Y.Z` before pushing. The workflow does not bump versions or merge branches.

### One-time npm setup
### npm authentication

The workflow uses `NPM_TOKEN` (organization or repository secret), falling back
to the legacy repository secret `NO_TWOFA_NPM_TOKEN`. Organization secrets must
allow access to this public repository; the "private repositories" policy does
not include it. Use a valid token with read/write permission for this package and permission to
publish non-interactively. Update the secret when the token expires or is revoked.

To remove the need to renew a publishing token, configure trusted publishing:

In the package's npm settings, add a **Trusted Publisher** for GitHub Actions:

Expand All @@ -221,8 +229,8 @@ In the package's npm settings, add a **Trusted Publisher** for GitHub Actions:
[Trusted publishing](https://docs.npmjs.com/trusted-publishers/) authenticates
through GitHub OIDC, so no npm write token or periodic token rotation is needed.
The workflow uses npm 11.21+ so it can verify private package tags through OIDC.
It does not change package visibility. The old `NO_TWOFA_NPM_TOKEN` secret is no
longer used.
It does not change package visibility. npm prefers OIDC when configured and can
fall back to the available npm token while trusted publishing is being set up.

To verify packaging locally, run from `js/`:

Expand Down
Loading