From 2def55f8b3932b75c3fe06d146bc9ad0692f0d21 Mon Sep 17 00:00:00 2001 From: Tommy Healy Date: Mon, 9 Nov 2026 11:11:53 +0100 Subject: [PATCH] Publish to npm with trusted publishing (OIDC) instead of NPM_TOKEN - Publish jobs run in the `release` environment and obtain a short-lived publish token via GitHub OIDC; NODE_AUTH_TOKEN removed. - Upgrade npm to >= 11.5.1 (required for trusted publishing). - Pack with pnpm (resolves workspace: deps), publish the tarball with npm (OIDC + automatic provenance). - Skip versions that are already published, matching the previous pnpm --filter publish behavior. - Add `repository` to both packages, required for provenance. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish.yml | 44 ++++++++++++++++++++++++++++++----- mcp/package.json | 5 ++++ package.json | 4 ++++ 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8085475..107047d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,5 +1,10 @@ name: Publish +# Publishing uses npm trusted publishing (OIDC): npm exchanges the job's GitHub +# OIDC token for a short-lived, package-scoped publish token. No npm token is stored. +# Each package on npmjs.com trusts this repo, this workflow file and the `release` +# environment, which is restricted to the main branch. + on: push: branches: [main] @@ -7,6 +12,7 @@ on: jobs: publish-sdk: runs-on: ubuntu-latest + environment: release permissions: contents: read @@ -25,6 +31,10 @@ jobs: cache: 'pnpm' registry-url: 'https://registry.npmjs.org' + # Trusted publishing requires npm >= 11.5.1; Node 20 ships npm 10. + - name: Upgrade npm + run: npm install -g npm@^11.5.1 + - name: Install dependencies run: pnpm install --frozen-lockfile @@ -32,12 +42,21 @@ jobs: run: pnpm run build - name: Publish SDK to npm - run: pnpm publish --access public --no-git-checks - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + name=$(node -p "require('./package.json').name") + version=$(node -p "require('./package.json').version") + # npm publish fails on an existing version, unlike pnpm's filtered publish, which skipped it. + if [ -n "$(npm view "$name@$version" version 2>/dev/null)" ]; then + echo "$name@$version is already published, skipping." + exit 0 + fi + # pnpm pack resolves workspace: protocol dependencies; npm publish uses OIDC and adds provenance. + pnpm pack --pack-destination "$RUNNER_TEMP/pack" + npm publish "$RUNNER_TEMP"/pack/*.tgz --access public publish-mcp: runs-on: ubuntu-latest + environment: release permissions: contents: read @@ -56,6 +75,10 @@ jobs: cache: 'pnpm' registry-url: 'https://registry.npmjs.org' + # Trusted publishing requires npm >= 11.5.1; Node 20 ships npm 10. + - name: Upgrade npm + run: npm install -g npm@^11.5.1 + - name: Install dependencies run: pnpm install --frozen-lockfile @@ -66,6 +89,15 @@ jobs: run: pnpm --filter @tinybirdco/devtools-mcp build - name: Publish MCP to npm - run: pnpm --filter @tinybirdco/devtools-mcp publish --access public --no-git-checks - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + working-directory: mcp + run: | + name=$(node -p "require('./package.json').name") + version=$(node -p "require('./package.json').version") + # npm publish fails on an existing version, unlike pnpm's filtered publish, which skipped it. + if [ -n "$(npm view "$name@$version" version 2>/dev/null)" ]; then + echo "$name@$version is already published, skipping." + exit 0 + fi + # pnpm pack rewrites "@tinybirdco/sdk": "workspace:*" to the real version. + pnpm pack --pack-destination "$RUNNER_TEMP/pack" + npm publish "$RUNNER_TEMP"/pack/*.tgz --access public diff --git a/mcp/package.json b/mcp/package.json index de7ad39..bc524e9 100644 --- a/mcp/package.json +++ b/mcp/package.json @@ -2,6 +2,11 @@ "name": "@tinybirdco/devtools-mcp", "version": "0.0.3", "description": "Tinybird DevTools MCP Server", + "repository": { + "type": "git", + "url": "git+https://github.com/tinybirdco/tinybird-sdk-typescript.git", + "directory": "mcp" + }, "type": "module", "main": "./dist/index.js", "bin": { diff --git a/package.json b/package.json index 05090a3..9ed8754 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,10 @@ "name": "@tinybirdco/sdk", "version": "0.0.84", "description": "TypeScript SDK for Tinybird Forward - define datasources and pipes as TypeScript", + "repository": { + "type": "git", + "url": "git+https://github.com/tinybirdco/tinybird-sdk-typescript.git" + }, "type": "module", "main": "./dist/index.js", "module": "./dist/index.js",