Skip to content

Commit fd17af1

Browse files
authored
Merge pull request #36 from iamriajul/fix/npm-oidc-publishing
ci: use npm trusted publishing
2 parents 952de32 + b2cb53f commit fd17af1

5 files changed

Lines changed: 57 additions & 20 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,16 @@ on:
1010
description: "Existing release tag or ref to publish from (for example v1.2.3-20260408120000)"
1111
required: true
1212
type: string
13-
npm_tag:
14-
description: "npm dist-tag to publish under"
15-
required: false
16-
default: "latest"
17-
type: string
1813

1914
permissions:
2015
contents: read
16+
id-token: write
2117

2218
jobs:
2319
publish:
2420
runs-on: ubuntu-latest
2521
env:
26-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
22+
NPM_PUBLISH_AUTH: oidc
2723
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
2824
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
2925
R2_ENDPOINT: ${{ vars.R2_ENDPOINT }}
@@ -43,9 +39,13 @@ jobs:
4339
- name: Set up Node.js
4440
uses: actions/setup-node@v4
4541
with:
46-
node-version: "22"
42+
node-version: "24"
4743
registry-url: "https://registry.npmjs.org"
4844

45+
- name: Update npm for trusted publishing
46+
shell: bash
47+
run: npm install -g npm@latest
48+
4949
- name: Set up Rust
5050
uses: dtolnay/rust-toolchain@stable
5151

@@ -86,7 +86,6 @@ jobs:
8686
8787
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
8888
raw_ref="${{ inputs.git_ref }}"
89-
npm_tag="${{ inputs.npm_tag }}"
9089
else
9190
raw_ref="${GITHUB_REF_NAME}"
9291
fi
@@ -101,9 +100,7 @@ jobs:
101100
102101
version="${ref_name#v}"
103102
104-
if [ "${GITHUB_EVENT_NAME}" != "workflow_dispatch" ]; then
105-
npm_tag="latest"
106-
fi
103+
npm_tag="latest"
107104
108105
if [ -z "$version" ]; then
109106
echo "Release version is empty"

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ Nightly release automation expects repository secrets:
120120
- `NIGHTLY_RELEASE_PUSH_TOKEN`: PAT/fine-grained token with `contents:write` to push commits + tags (tag pushes trigger release workflows)
121121
- `DISCORD_WEBHOOK_URL`: Discord webhook used for patch-failure alerts
122122

123+
NPM release automation uses npm trusted publishing / OIDC for `.github/workflows/publish-npm.yml`; no `NPM_TOKEN` is required in Actions. `scripts/publish-npm.sh` still supports `NPM_PUBLISH_AUTH=token` for local fallback.
124+
123125
**Gitignore** (do not modify): `values-production.yaml`, `*-secrets.yaml`, `*-secret.yaml`, `.env*`
124126

125127
## Commit Conventions

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ Nightly release automation expects repository secrets:
120120
- `NIGHTLY_RELEASE_PUSH_TOKEN`: PAT/fine-grained token with `contents:write` to push commits + tags (tag pushes trigger release workflows)
121121
- `DISCORD_WEBHOOK_URL`: Discord webhook used for patch-failure alerts
122122

123+
NPM release automation uses npm trusted publishing / OIDC for `.github/workflows/publish-npm.yml`; no `NPM_TOKEN` is required in Actions. `scripts/publish-npm.sh` still supports `NPM_PUBLISH_AUTH=token` for local fallback.
124+
123125
**Gitignore** (do not modify): `values-production.yaml`, `*-secrets.yaml`, `*-secret.yaml`, `.env*`
124126

125127
## Commit Conventions

RELEASE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ Artifacts:
3535
- automatic tag publishes use the npm `latest` dist-tag
3636

3737
Required secrets and variables:
38-
- `NPM_TOKEN`
3938
- `R2_ACCESS_KEY_ID`
4039
- `R2_SECRET_ACCESS_KEY`
4140
- `R2_ENDPOINT`
4241
- `R2_BUCKET`
4342
- `R2_PUBLIC_URL`
4443
- `VITE_PUBLIC_REACT_VIRTUOSO_LICENSE_KEY`
4544

45+
NPM publishes through trusted publishing / OIDC in GitHub Actions. `scripts/publish-npm.sh` still supports `NPM_PUBLISH_AUTH=token` with `NPM_TOKEN` for local fallback.
46+
4647
## Manual Flow
4748

4849
1. Update the tracked upstream ref with `scripts/update-vibe-kanban.sh`.

scripts/publish-npm.sh

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,30 @@ require_cmd rustc
301301
require_cmd zip
302302
require_cmd aws
303303

304-
require_env NPM_TOKEN
304+
NPM_PUBLISH_AUTH="${NPM_PUBLISH_AUTH:-}"
305+
if [ -z "${NPM_PUBLISH_AUTH}" ]; then
306+
if [ -n "${NPM_TOKEN:-}" ]; then
307+
NPM_PUBLISH_AUTH="token"
308+
else
309+
NPM_PUBLISH_AUTH="oidc"
310+
fi
311+
fi
312+
313+
case "${NPM_PUBLISH_AUTH}" in
314+
token)
315+
require_env NPM_TOKEN
316+
;;
317+
oidc)
318+
if [ "${GITHUB_ACTIONS:-}" = "true" ] &&
319+
{ [ -z "${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-}" ] || [ -z "${ACTIONS_ID_TOKEN_REQUEST_URL:-}" ]; }; then
320+
die "NPM_PUBLISH_AUTH=oidc requires GitHub Actions id-token: write permission"
321+
fi
322+
;;
323+
*)
324+
die "NPM_PUBLISH_AUTH must be 'oidc' or 'token'"
325+
;;
326+
esac
327+
305328
require_env R2_ACCESS_KEY_ID
306329
require_env R2_SECRET_ACCESS_KEY
307330
require_env R2_ENDPOINT
@@ -376,9 +399,9 @@ ${NODE_CMD} -e "
376399
const pkg = JSON.parse(fs.readFileSync(path, 'utf8'));
377400
pkg.name = 'vibe-kanban-team';
378401
pkg.version = '${VERSION}';
379-
pkg.publishConfig = { access: 'public' };
402+
pkg.publishConfig = { access: 'public', registry: 'https://registry.npmjs.org' };
380403
pkg.author = 'iamriajul';
381-
pkg.repository = { type: 'git', url: 'https://github.com/iamriajul/vibe-kanban-team' };
404+
pkg.repository = { type: 'git', url: 'git+https://github.com/iamriajul/vibe-kanban-team.git' };
382405
fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\\n');
383406
"
384407

@@ -641,15 +664,27 @@ echo "Removing local dist artifacts before npm publish..."
641664
rm -rf "${VIBE_DIR}/npx-cli/dist"
642665

643666
echo "Publishing to npm..."
644-
NPMRC_BAK="${TMP_DIR}/.npmrc"
645-
umask 077
646-
printf "//registry.npmjs.org/:_authToken=%s\n" "${NPM_TOKEN}" > "${NPMRC_BAK}"
667+
NPM_ARGS=()
668+
669+
if [ "${NPM_PUBLISH_AUTH}" = "token" ]; then
670+
NPMRC_BAK="${TMP_DIR}/.npmrc"
671+
umask 077
672+
printf "//registry.npmjs.org/:_authToken=%s\n" "${NPM_TOKEN}" > "${NPMRC_BAK}"
673+
NPM_ARGS=(--userconfig "${NPMRC_BAK}")
674+
else
675+
echo "Using npm trusted publishing (OIDC)."
676+
# setup-node writes a token-based .npmrc when registry-url is configured.
677+
# In OIDC mode, keep npm from falling back to stale token auth.
678+
unset NODE_AUTH_TOKEN
679+
unset NPM_CONFIG_USERCONFIG
680+
unset npm_config_userconfig
681+
fi
647682

648-
if (cd "${VIBE_DIR}/npx-cli" && npm --userconfig "${NPMRC_BAK}" view "vibe-kanban-team@${VERSION}" version >/dev/null 2>&1); then
683+
if (cd "${VIBE_DIR}/npx-cli" && npm "${NPM_ARGS[@]}" view "vibe-kanban-team@${VERSION}" version >/dev/null 2>&1); then
649684
echo "npm version ${VERSION} already exists; skipping publish."
650685
else
651686
echo "Publishing to npm with dist-tag: ${NPM_TAG}"
652-
(cd "${VIBE_DIR}/npx-cli" && npm --userconfig "${NPMRC_BAK}" publish --ignore-scripts --access public --tag "${NPM_TAG}")
687+
(cd "${VIBE_DIR}/npx-cli" && npm "${NPM_ARGS[@]}" publish --ignore-scripts --access public --tag "${NPM_TAG}")
653688
fi
654689

655690
echo "Publish complete."

0 commit comments

Comments
 (0)