Skip to content

Commit 642fa95

Browse files
committed
CI: publish to the VS Marketplace by trusted publishing (OIDC)
The publish job signs in to Microsoft Entra with the job's OIDC token (azure/login, a federated credential on an identity that is a member of the publisher) and runs vsce publish --azure-credential: no stored token. Open VSX keeps a token until its CLI supports trusted publishing. The job runs in the release environment. Fixes the Open VSX step's if, which could not see a step-level env. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWP4zNW5bnup8XRB8md
1 parent 38c1e3e commit 642fa95

2 files changed

Lines changed: 38 additions & 10 deletions

File tree

‎.github/workflows/editor.yml‎

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# The editor tools (spec/11 CP-8e): build the crate natively and as WebAssembly, run the language server's LSP tests on
22
# both the server and the extension's bundle, and package the VS Code extension (one .vsix for every platform).
3-
# A tag `vscode-v<version>` also publishes it to the VS Marketplace (secret VSCE_PAT) and Open VSX (secret OVSX_PAT).
3+
# A tag `vscode-v<version>` also publishes it: to the VS Marketplace by trusted publishing (OIDC, variables
4+
# AZURE_CLIENT_ID and AZURE_TENANT_ID) and to Open VSX (secret OVSX_PAT), from the `release` environment.
45
name: editor
56

67
on:
@@ -55,20 +56,33 @@ jobs:
5556
if: startsWith(github.ref, 'refs/tags/vscode-v')
5657
needs: build
5758
runs-on: ubuntu-latest
59+
# trusted publishing: no long-lived token for the Marketplace; the job's OIDC token signs it in to Microsoft Entra
60+
# through a federated credential on a managed identity that is a member of the publisher (tooling/vscode-rx/README.md)
61+
environment: release
62+
permissions:
63+
id-token: write
64+
contents: read
65+
env:
66+
OVSX_PAT: ${{ secrets.OVSX_PAT }} # job-wide, so that a step's `if` can see whether it is set
5867
steps:
5968
- uses: actions/download-artifact@v4
6069
with:
6170
name: vsix
6271
- uses: actions/setup-node@v5
6372
with:
6473
node-version: 22
74+
- name: Sign in to Microsoft Entra (OIDC)
75+
if: vars.AZURE_CLIENT_ID != ''
76+
uses: azure/login@v2
77+
with:
78+
client-id: ${{ vars.AZURE_CLIENT_ID }}
79+
tenant-id: ${{ vars.AZURE_TENANT_ID }}
80+
allow-no-subscriptions: true
6581
- name: VS Marketplace
66-
if: env.VSCE_PAT != ''
67-
env:
68-
VSCE_PAT: ${{ secrets.VSCE_PAT }}
69-
run: npx --yes @vscode/vsce publish --packagePath *.vsix
82+
if: vars.AZURE_CLIENT_ID != ''
83+
run: npx --yes @vscode/vsce publish --azure-credential --packagePath *.vsix
84+
# Open VSX has no trusted publishing in its CLI yet (eclipse-openvsx/openvsx#1980 is server-side only): a token
85+
# until it does
7086
- name: Open VSX
7187
if: env.OVSX_PAT != ''
72-
env:
73-
OVSX_PAT: ${{ secrets.OVSX_PAT }}
7488
run: npx --yes ovsx publish *.vsix -p "$OVSX_PAT"

‎tooling/vscode-rx/README.md‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,22 @@ per request instead of the WebAssembly build) or TypeScript.
5151

5252
The repository's `editor` workflow (`.github/workflows/editor.yml`) builds and
5353
tests the extension on every change to `compiler/` or `tooling/`. A tag
54-
`vscode-v<version>` (matching `version` in `package.json`) also publishes it:
55-
to the VS Marketplace when the repository has the secret `VSCE_PAT` (a token of
56-
the `reactivescript` publisher), and to Open VSX when it has `OVSX_PAT`.
54+
`vscode-v<version>` (matching `version` in `package.json`) also publishes it,
55+
from the `release` environment:
56+
57+
- **VS Marketplace, by trusted publishing** (no stored token). Once: create
58+
the `reactivescript` publisher; in Azure, create a user-assigned managed
59+
identity (or an app registration) with a federated credential for GitHub
60+
Actions, issuer `https://token.actions.githubusercontent.com`, subject
61+
`repo:ryansolid/reactivescript:environment:release`; add that identity to
62+
the publisher as a Contributor; set the repository variables
63+
`AZURE_CLIENT_ID` and `AZURE_TENANT_ID`. The job signs in with `azure/login`
64+
and runs `vsce publish --azure-credential`.
65+
- **Open VSX, by token** for now: its trusted publishing is server-side work
66+
in progress (eclipse-openvsx/openvsx#1980) with no CLI support yet. Set the
67+
secret `OVSX_PAT` on the `release` environment; switch when `ovsx` can
68+
exchange the job's OIDC token.
69+
70+
Either step is skipped while its variable or secret is unset.
5771

5872
Other editors: see [`../rx-language-server`](../rx-language-server#editors).

0 commit comments

Comments
 (0)