From e2c57796604ddd5bb1bbbc5a01f8cd5e927ae35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20R=C3=B8rvik?= <11362831+asbis@users.noreply.github.com> Date: Wed, 23 Sep 2026 18:40:06 +0200 Subject: [PATCH 1/2] ci: publish to the Marketplace with Entra ID instead of a PAT VSCE_PAT expired in August and the Marketplace listing sat at 1.23.0 through six releases, because the failure only ever hit the last step, after npm had published. Azure DevOps also retires global PATs on 2026-12-01, so a renewed token only buys two months. The Marketplace upload moves to its own job in the `marketplace` environment, signs in with azure/login over GitHub OIDC, and publishes the VSIX the first job packaged with `vsce publish --azure-credential`. The separate job keeps the npm trusted publisher's OIDC claims unchanged. It checks publish rights before uploading, and --skip-duplicate makes a re-run pass the same way the npm step's skip does. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish.yml | 87 ++++++++++++++++++++++++++++------- CLAUDE.md | 8 ++-- 2 files changed, 76 insertions(+), 19 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d886a48..5cb2396 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -162,14 +162,14 @@ jobs: # an OIDC-capable npm on the Node 22 runner (ships npm 10.x). # # NOTE: no `continue-on-error` here — a failed npm publish MUST abort - # the workflow so the VSIX below never ships referencing a server - # version that wasn't actually released. + # the workflow so the `marketplace` job never ships a VSIX referencing + # a server version that wasn't actually released. # # But "already on the registry" is not a failure, it is the goal state. # Treating it as one is how v1.24.0 and v1.27.0 both ended with npm - # published and the Marketplace step never reached: the PAT below had - # expired, and re-running afterwards died here on a version that had - # succeeded the first time. The two channels have to be able to fail + # published and the Marketplace step never reached: the Marketplace PAT + # (since replaced by Entra ID) had expired, and re-running afterwards + # died here on a version that had succeeded the first time. The two channels have to be able to fail # independently, or one broken credential silently strands the other. run: | set -euo pipefail @@ -190,15 +190,70 @@ jobs: npm publish "$TGZ" --access public fi + - name: Package the VSIX + # Packaged here, published by the `marketplace` job below. The split is + # about credentials: that job runs in the `marketplace` environment, + # which is what the Entra ID federated credential trusts. Keeping THIS + # job out of any environment leaves the OIDC claims that npm's trusted + # publisher checks exactly as they were. + run: cd packages/extension && npx -y @vscode/vsce package --out "$GITHUB_WORKSPACE/shapeitup-vscode.vsix" + + - uses: actions/upload-artifact@v7 + with: + name: vsix + path: shapeitup-vscode.vsix + if-no-files-found: error + + marketplace: + needs: publish + runs-on: ubuntu-latest + # Auth is Microsoft Entra ID, not a PAT. Azure DevOps PATs expire (a year + # by default), and when one lapsed the listing sat at 1.23.0 for six + # releases; global PATs are retired outright on 2026-12-01. Here GitHub's + # OIDC token is exchanged for an Entra token for the app registration + # "ShapeItUp Marketplace publisher (GitHub Actions)" in the Standardmappe + # tenant. Its federated credential trusts exactly this subject: + # repo:asbis/ShapeItUp:environment:marketplace + # Rename the environment and the sign-in fails with AADSTS700213. + environment: marketplace + permissions: + id-token: write + contents: read + steps: + - uses: actions/download-artifact@v8 + with: + name: vsix + + - uses: actions/setup-node@v6 + with: + node-version: 22 + + - name: Sign in to Microsoft Entra ID + # The app has no Azure subscription, only a seat on the Marketplace + # publisher, hence allow-no-subscriptions. The IDs are environment + # variables, not secrets: they identify the app, they don't unlock it. + uses: azure/login@v3 + with: + client-id: ${{ vars.AZURE_CLIENT_ID }} + tenant-id: ${{ vars.AZURE_TENANT_ID }} + allow-no-subscriptions: true + + - name: Show the identity the Marketplace sees + # This ID (not the app's client ID) is what the publisher's Members + # list takes: marketplace.visualstudio.com/manage/publishers/shapeitup, + # role Contributor. Printed on every run so a lost membership is a + # copy-paste away from fixed. + continue-on-error: true + run: | + az rest -u https://app.vssps.visualstudio.com/_apis/profile/profiles/me \ + --resource 499b84ac-1321-427f-aa17-267ca6975798 \ + --query "{id: id, displayName: displayName}" -o json + + - name: Check publish rights + # Fails before any upload, with a message that names the problem. + run: npx -y @vscode/vsce verify-pat --azure-credential shapeitup + - name: Publish to VS Marketplace - # The PAT is an Azure DevOps token and they EXPIRE — a year by default. - # When it lapses this step is the only thing that fails, and because - # npm has already published by then the release looks half-done rather - # than broken. The listing sat four versions behind before anyone - # noticed. If this step fails with "Personal Access Token used has - # expired", mint a new one at https://aka.ms/vscodepat and update the - # VSCE_PAT repository secret; the npm step above is idempotent, so - # re-running the same release afterwards will get here. - run: cd packages/extension && npx @vscode/vsce publish - env: - VSCE_PAT: ${{ secrets.VSCE_PAT }} + # --skip-duplicate for the same reason the npm step skips: a version + # that is already listed is the goal state, so a re-run must pass. + run: npx -y @vscode/vsce publish --packagePath shapeitup-vscode.vsix --azure-credential --skip-duplicate diff --git a/CLAUDE.md b/CLAUDE.md index 97eeed1..34aff4b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -213,10 +213,12 @@ Registered globally in `~/.claude/settings.json`. Viewer-related tools: - **GitHub**: https://github.com/asbis/ShapeItUp - **VS Marketplace**: Published as `shapeitup.shapeitup-vscode` - **npm**: `@shapeitup/mcp-server` — consumed by marketplace users via `npx -y @shapeitup/mcp-server` (the canonical install shape for Claude Code / Cursor / Desktop / Gemini). -- **Auto-deploy**: `.github/workflows/publish.yml` triggers on GitHub release creation (and `workflow_dispatch`). It builds/tests, then (a) publishes `@shapeitup/mcp-server` to npm and (b) `vsce publish` to the Marketplace. -- **npm auth = OIDC trusted publishing (no token).** The npm publish step runs `npm publish ` on `npm@latest` (needs ≥11.5.1) against the tarball `pnpm pack` produced, authenticating via OIDC — the job declares `permissions: id-token: write` and a Trusted Publisher (`asbis/ShapeItUp` + `publish.yml`) is configured on npmjs.com. There is **no `NPM_TOKEN` secret** (deleted 2026-06-30). Do NOT re-add `registry-url` to setup-node or a `NODE_AUTH_TOKEN` env — either blocks the OIDC path. `pnpm publish` can't do OIDC (it hits `ENEEDAUTH`), which is why the step uses `npm`. Marketplace still uses the `VSCE_PAT` secret. Full rationale: `~/.claude` memory `project_npm_oidc_publishing`. +- **Auto-deploy**: `.github/workflows/publish.yml` triggers on GitHub release creation (and `workflow_dispatch`). Job `publish` builds/tests, publishes `@shapeitup/mcp-server` to npm and packages the VSIX; job `marketplace` then uploads that VSIX to the Marketplace. +- **npm auth = OIDC trusted publishing (no token).** The npm publish step runs `npm publish ` on `npm@latest` (needs ≥11.5.1) against the tarball `pnpm pack` produced, authenticating via OIDC — the job declares `permissions: id-token: write` and a Trusted Publisher (`asbis/ShapeItUp` + `publish.yml`) is configured on npmjs.com. There is **no `NPM_TOKEN` secret** (deleted 2026-06-30). Do NOT re-add `registry-url` to setup-node or a `NODE_AUTH_TOKEN` env — either blocks the OIDC path. `pnpm publish` can't do OIDC (it hits `ENEEDAUTH`), which is why the step uses `npm`. Full rationale: `~/.claude` memory `project_npm_oidc_publishing`. - **To release**: bump versions (see below), commit, push, then either `gh release create v0.x.x` OR `gh workflow run publish.yml --ref master` (dispatch skips the tag-verify step and publishes whatever version is in `package.json`). -- **`VSCE_PAT` expires (Azure DevOps PATs last a year by default) and its failure is silent-ish.** It is the LAST step, so npm has already published when it fails and the release reads as half-done rather than broken. v1.24.0 and v1.27.0 both failed this way and the Marketplace listing sat at 1.23.0 (8 Jul 2026) for four versions. Fix: mint a new PAT at https://aka.ms/vscodepat (Marketplace → Manage scope), update the `VSCE_PAT` repo secret, then re-run the failed release — the npm step skips an already-published version, so the re-run reaches the Marketplace step. Check `npx @vscode/vsce show shapeitup.shapeitup-vscode` after any release; npm and the Marketplace can drift apart without anything saying so. +- **Marketplace auth = Microsoft Entra ID (no token).** The `marketplace` job runs in the GitHub environment `marketplace`, signs in with `azure/login` (OIDC, `allow-no-subscriptions`) and runs `vsce publish --azure-credential`. The identity is the app registration "ShapeItUp Marketplace publisher (GitHub Actions)" in the `Standardmappe` tenant; its federated credential trusts exactly `repo:asbis/ShapeItUp:environment:marketplace`, and its client/tenant IDs are the environment variables `AZURE_CLIENT_ID` / `AZURE_TENANT_ID`. It sits on the `shapeitup` publisher as a Contributor — the ID the Members list takes is printed by the job's "Show the identity the Marketplace sees" step. The job is separate from `publish` on purpose: an environment changes the job's OIDC claims, and the npm trusted publisher must keep seeing the ones it was configured with. +- **Why not a PAT.** `VSCE_PAT` expired silently: it was the LAST step, so npm had already published and every release read as half-done rather than broken. The listing sat at 1.23.0 (8 Jul 2026) through six releases, 1.24.0 → 1.29.5. Azure DevOps also retires global PATs on 2026-12-01. Do not go back. +- **Re-runs are safe on both channels.** The npm step skips a version already on the registry and the Marketplace step passes `--skip-duplicate`, so re-running a half-failed release only redoes what's missing. Still check `npx @vscode/vsce show shapeitup.shapeitup-vscode` after any release; npm and the Marketplace can drift apart without anything saying so. ### Any change under `packages/mcp-server/` MUST bump its own version From 2cdc2d92481eb578bcd0d295101927e27db555f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20R=C3=B8rvik?= <11362831+asbis@users.noreply.github.com> Date: Wed, 23 Sep 2026 18:43:26 +0200 Subject: [PATCH 2/2] ci: read the Marketplace identity from connectionData A service principal has no Azure DevOps profile, so profiles/me answers VSS011031. connectionData returns the same ID for any signed-in identity. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5cb2396..ee2305e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -242,12 +242,14 @@ jobs: # This ID (not the app's client ID) is what the publisher's Members # list takes: marketplace.visualstudio.com/manage/publishers/shapeitup, # role Contributor. Printed on every run so a lost membership is a - # copy-paste away from fixed. + # copy-paste away from fixed. It is connectionData, not the + # profiles/me call Microsoft's docs show: a service principal has no + # profile, and that call answers VSS011031. continue-on-error: true run: | - az rest -u https://app.vssps.visualstudio.com/_apis/profile/profiles/me \ + az rest -u https://app.vssps.visualstudio.com/_apis/connectionData \ --resource 499b84ac-1321-427f-aa17-267ca6975798 \ - --query "{id: id, displayName: displayName}" -o json + --query "authenticatedUser.{id: id, name: providerDisplayName}" -o json - name: Check publish rights # Fails before any upload, with a message that names the problem.