diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d886a48..ee2305e 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,72 @@ 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. 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/connectionData \ + --resource 499b84ac-1321-427f-aa17-267ca6975798 \ + --query "authenticatedUser.{id: id, name: providerDisplayName}" -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