|
1 | | -# Publishing setup (Microsoft Entra ID, no PAT) |
| 1 | +# Publishing setup (Marketplace PAT) |
2 | 2 |
|
3 | | -This repo publishes to the VS Code Marketplace from GitHub Actions using |
4 | | -**Microsoft Entra ID workload identity federation (OIDC)** — there is no |
5 | | -long-lived Personal Access Token stored anywhere. (Global Azure DevOps PATs are |
6 | | -retired on December 1, 2026.) |
| 3 | +This repo publishes to the VS Code Marketplace from GitHub Actions using a |
| 4 | +**Marketplace Personal Access Token (PAT)** stored as the `VSCE_PAT` repo |
| 5 | +secret. `vsce publish --pat` uses it to authenticate. |
| 6 | + |
| 7 | +> A previous iteration used Microsoft Entra ID / OIDC workload identity |
| 8 | +> federation. That path requires adding a service principal as a member of the |
| 9 | +> publisher, which is not supported when the publisher is owned by a personal |
| 10 | +> Microsoft account. The PAT flow below works regardless. |
7 | 11 |
|
8 | 12 | How it works at release time: |
9 | 13 |
|
10 | 14 | 1. The version PR merges to `main`. |
11 | | -2. `.github/workflows/release.yml` runs `azure/login@v2` with OIDC, which |
12 | | - exchanges a GitHub-issued token for a short-lived Microsoft Entra token. |
13 | | -3. `vsce publish --azure-credential` uses that token to publish. |
| 15 | +2. `.github/workflows/release.yml` runs the changesets action, which calls |
| 16 | + `pnpm run release:ci`. |
| 17 | +3. `release-ci.mjs` packages the extension and runs `vsce publish --pat`, |
| 18 | + reading the token from `VSCE_PAT` (or `AZURE_PAT` as a fallback). |
14 | 19 |
|
15 | 20 | You only do the setup below **once**. |
16 | 21 |
|
17 | 22 | --- |
18 | 23 |
|
19 | | -## Prerequisites |
20 | | - |
21 | | -- An Azure subscription + Entra (Azure AD) tenant (a free Azure account is |
22 | | - fine). Sign in: <https://portal.azure.com>. |
23 | | -- The `blinkk` publisher created at |
24 | | - <https://marketplace.visualstudio.com/manage> (publisher ID must equal |
25 | | - `"publisher": "blinkk"` in `package.json`). |
26 | | -- Azure CLI installed locally (`brew install azure-cli`) and `az login` done, |
27 | | - **or** use the Azure Portal equivalents. |
28 | | -- `gh` authenticated for setting the repo variables. |
29 | | - |
30 | | ---- |
31 | | - |
32 | | -## 1. Create an Entra app registration |
33 | | - |
34 | | -```bash |
35 | | -az ad app create --display-name "vscode-agent-platform-connector-publisher" |
36 | | -``` |
37 | | - |
38 | | -Note the `appId` (this is the **client ID**) from the output. Then create a |
39 | | -service principal for it: |
40 | | - |
41 | | -```bash |
42 | | -APP_ID="<appId from above>" |
43 | | -az ad sp create --id "$APP_ID" |
44 | | -``` |
45 | | - |
46 | | -Get your tenant ID: |
47 | | - |
48 | | -```bash |
49 | | -az account show --query tenantId -o tsv |
50 | | -``` |
51 | | - |
52 | | -## 2. Add a federated credential for this GitHub repo |
53 | | - |
54 | | -This is what lets GitHub Actions authenticate as the app without a secret. |
55 | | -Create a file `federated.json`: |
56 | | - |
57 | | -```json |
58 | | -{ |
59 | | - "name": "github-release-main", |
60 | | - "issuer": "https://token.actions.githubusercontent.com", |
61 | | - "subject": "repo:blinkk/vscode-agent-platform-connector:ref:refs/heads/main", |
62 | | - "description": "GitHub Actions release workflow on main", |
63 | | - "audiences": ["api://AzureADTokenExchange"] |
64 | | -} |
65 | | -``` |
66 | | - |
67 | | -```bash |
68 | | -az ad app federated-credential create --id "$APP_ID" --parameters federated.json |
69 | | -``` |
70 | | - |
71 | | -> The `subject` must exactly match the workflow's trigger. `ref:refs/heads/main` |
72 | | -> covers pushes to `main` (which is where the publish step runs). If you later |
73 | | -> publish from tags or environments, add additional federated credentials with |
74 | | -> the matching subject (e.g. `repo:OWNER/REPO:environment:production`). |
75 | | -
|
76 | | -## 3. Authorize the identity in the Marketplace publisher |
77 | | - |
78 | | -The Entra identity must be a member of the `blinkk` publisher with |
79 | | -**Contributor**. |
80 | | - |
81 | | -1. Go to <https://marketplace.visualstudio.com/manage/publishers/blinkk>. |
82 | | -2. Open the **Members** (or **Security**) tab → **Add**. |
83 | | -3. Add the app registration (search by its display name / client ID) and assign |
84 | | - the **Contributor** role. |
85 | | - |
86 | | -> If the Marketplace UI only lets you add users (not app registrations |
87 | | -> directly), add the app's **service principal**; some tenants surface it by the |
88 | | -> display name set in step 1. |
89 | | -
|
90 | | -## 4. Set the GitHub repo variables |
91 | | - |
92 | | -These are **variables**, not secrets — they are identifiers, not credentials: |
| 24 | +## 1. Create a Marketplace PAT |
93 | 25 |
|
94 | | -```bash |
95 | | -gh variable set AZURE_CLIENT_ID --repo blinkk/vscode-agent-platform-connector --body "$APP_ID" |
96 | | -gh variable set AZURE_TENANT_ID --repo blinkk/vscode-agent-platform-connector --body "$(az account show --query tenantId -o tsv)" |
97 | | -``` |
98 | | - |
99 | | -## 5. (Optional) Open VSX |
100 | | - |
101 | | -Open VSX is not part of Entra ID and still uses a token. Create one at |
102 | | -<https://open-vsx.org> (Settings → Access Tokens) and add it as a secret: |
| 26 | +1. Sign in to 1. Sign in to 1. Sign in to 1. Sign in to 1. Sign in to 1. Sign in to 1. Sign in to 1. Sigin1. Sign in to 1. Sign in to 1-> **New 1. Sign in to 1. Sign in to 1. Sign in to 1. Sign in to 1. Sign in to 1. Se1. Sign in to 1. Sign in to 1. Sign in to 1. Sign in to 1. Sign in to 1. 1. Sign in to 1. Sign in to 1. Sign in to 1. Sign intore the PAT as a GitHub repo secret |
103 | 27 |
|
104 | 28 | ```bash |
105 | | -gh secret set OVSX_PAT --repo blinkk/vscode-agent-platform-connector |
106 | | -``` |
107 | | - |
108 | | -If `OVSX_PAT` is unset, CI simply skips the Open VSX publish. |
109 | | - |
110 | | ---- |
111 | | - |
112 | | -## Test the release flow |
| 29 | +gh secret set VSCE_PAT --repogh secret set VSCE_PAT --repogh secret set VSCE_PAT --repogh secret set VSC## 3gh secret set VSCE_PAT --repogh secret set VSCE_PAT --repogh secret set VSCEpegh secret set VSCE_PAT --repogh secret set VSCE_PAT --reecrgh secret set VSCE_PAT -et OVSXgh secret set VSCE_PAT --repogh-platgh secret set VSCE_PAT --repogh secret set VSCE_PAT --repogh secret set V. |
| 30 | +gh secret set VSCE_PAT -e flow |
113 | 31 |
|
114 | 32 | 1. Make a change + `pnpm changeset` + commit + push to `main`. |
115 | 33 | 2. CI opens a **"Version Packages"** PR. |
116 | | -3. Merge it. CI bumps the version, then publishes to the Marketplace via OIDC. |
| 34 | +3. Merge it. CI bumps the version,3. Merge it. CI bumps the version,3.ia 3.e PAT. |
117 | 35 | 4. Confirm at |
118 | 36 | <https://marketplace.visualstudio.com/items?itemName=blinkk.vscode-agent-platform-connector>. |
119 | 37 |
|
120 | 38 | ## Manual publish (fallback) |
121 | 39 |
|
| 40 | +Export the PAT (or put it in a gitignored `.env` as `VSCE_PAT` / `AZURE_PAT`), |
| 41 | +then run the publish script: |
| 42 | + |
122 | 43 | ```bash |
123 | | -az login |
124 | | -pnpm version # if there are pending changesets |
125 | | -pnpm release # vsce publish --azure-credential |
126 | | -pnpm release:ovsx # optional, needs OVSX_PAT in env |
| 44 | +export VSCE_PAT=... # or AZURE_PAT |
| 45 | +node ./scripts/release-ci.mjs |
127 | 46 | ``` |
128 | 47 |
|
129 | 48 | ## Troubleshooting |
130 | 49 |
|
131 | | -- **`AADSTS70021: No matching federated identity record found`** — the |
132 | | - `subject` in the federated credential doesn't match the workflow context. |
133 | | - Verify it is exactly `repo:blinkk/vscode-agent-platform-connector:ref:refs/heads/main`. |
134 | | -- **403/401 from the Marketplace** — the app registration isn't a Contributor |
135 | | - member of the `blinkk` publisher, or the publisher ID doesn't match |
136 | | - `package.json`. |
137 | | -- **`azure/login` skipped** — `AZURE_CLIENT_ID` repo variable is empty (the |
138 | | - `if: vars.AZURE_CLIENT_ID != ''` guard); set it per step 4. |
| 50 | +- **`InvalidAccessException: The requested operation is not allowed`** - the PAT |
| 51 | + lacks the **Marketplace > Manage** scope, or the account is not a member of the |
| 52 | + `blinkk` publisher. |
| 53 | +- **`.env files should not be packaged`** - ensure `.env` is listed in |
| 54 | + `.vscodeignore` (it is). Never commit `.env`; it is gitignored. |
0 commit comments