Skip to content

Commit 6f08acb

Browse files
authored
Merge pull request #199 from salesforcecli/ms/W-24666922-ovsx-trusted-publishing
fix(release): migrate Open VSX publishing to OIDC trusted publishing - W-24666922
2 parents 98e42a8 + 43df7ab commit 6f08acb

5 files changed

Lines changed: 124 additions & 64 deletions

File tree

‎.github/workflows/openvsx-publish-release-vsix.yml‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,28 @@ on:
1212
required: false
1313
default: false
1414
type: boolean
15-
secrets:
16-
IDEE_OVSX_PAT:
17-
description: Open VSX publishing token
18-
required: true
15+
vsix-name-pattern:
16+
description: Glob of downloaded VSIX file names to publish
17+
required: false
18+
default: '*.vsix'
19+
type: string
20+
exclude-web-vsix:
21+
description: Exclude *-web-* VSIXs from publishing
22+
required: false
23+
default: 'false'
24+
type: string
1925

2026
permissions:
2127
contents: read
2228

2329
jobs:
2430
publish:
2531
runs-on: ubuntu-latest
32+
permissions:
33+
contents: read
34+
# ovsx exchanges this job's OIDC ID token for a short-lived Open VSX publishing token
35+
# (--trusted-publishing below) -- without this, there is no token to exchange.
36+
id-token: write
2637
steps:
2738
- name: Download release VSIXs
2839
id: release
@@ -33,8 +44,9 @@ jobs:
3344
- name: Publish VSIXs
3445
env:
3546
DRY_RUN: ${{ inputs.dry-run }}
36-
IDEE_OVSX_PAT: ${{ secrets.IDEE_OVSX_PAT }}
3747
PRE_RELEASE: ${{ steps.release.outputs.pre-release }}
48+
VSIX_PATTERN: ${{ inputs.vsix-name-pattern }}
49+
EXCLUDE_WEB: ${{ inputs.exclude-web-vsix }}
3850
run: |
3951
# Open VSX can hang the same way as vsce; retry per VSIX.
4052
# --skip-duplicate makes a retry a no-op if the first attempt committed.
@@ -54,7 +66,7 @@ jobs:
5466
}
5567
5668
while IFS= read -r -d '' vsix; do
57-
args=("$vsix" -p "$IDEE_OVSX_PAT" --skip-duplicate)
69+
args=("$vsix" --trusted-publishing --skip-duplicate)
5870
pre_release_suffix=''
5971
if [ "$PRE_RELEASE" = true ]; then
6072
args+=(--pre-release)
@@ -70,4 +82,10 @@ jobs:
7082
echo "::error::Failed to publish $vsix after 3 attempts"
7183
exit 1
7284
fi
73-
done < <(find extensions -type f -name '*.vsix' -print0)
85+
done < <(
86+
if [ "$EXCLUDE_WEB" = "true" ]; then
87+
find extensions -type f -name "$VSIX_PATTERN" ! -iname '*-web-*' -print0
88+
else
89+
find extensions -type f -name "$VSIX_PATTERN" -print0
90+
fi
91+
)

‎.github/workflows/vscode-manual-publish.yml‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ name: Manual Publish VS Code Extension
55
# - A nightly GitHub Release (version-tag path — normal workflow)
66
# - A branch CI build artifact (source-run-id path — out-of-band, bypass mandatory)
77
#
8+
# This workflow does NOT publish Open VSX itself -- its `publish` job's ovsx leg is a
9+
# deliberate no-op (see that job's comment). See "Open VSX Trusted Publishing" in this repo's
10+
# README for why, and dispatch your own Open VSX publish after this workflow succeeds.
11+
#
812
# Usage from consuming repository:
913
# jobs:
1014
# manual-publish:
@@ -22,7 +26,7 @@ name: Manual Publish VS Code Extension
2226
# secrets: inherit
2327
#
2428
# Requirements - calling repository must have:
25-
# - Secrets: IDEE_GH_TOKEN, VSCE_PERSONAL_ACCESS_TOKEN, IDEE_OVSX_PAT
29+
# - Secrets: IDEE_GH_TOKEN, VSCE_PERSONAL_ACCESS_TOKEN
2630
# - For CBWeb: MARKETPLACE_DEPLOY_TOKEN and MARKETPLACE_URL variable
2731
# - The package manager and lockfile inputs must match the caller repository.
2832
# - The shared actions in this repository are resolved from the workflow branch.
@@ -317,6 +321,14 @@ jobs:
317321
echo "ERROR: source-run-id path requires skip-quality-checks=true (branch CI profiles differ from main)."
318322
exit 1
319323
fi
324+
# Open VSX publishing is tag-based (the caller dispatches publishOpenVSXTrusted.yml
325+
# with a release tag -- see this workflow's header) and there is no GitHub Release,
326+
# and therefore no tag, for a branch CI run artifact. Failing loudly here beats the
327+
# alternative of silently never publishing to Open VSX for this combination.
328+
if [ "$REGISTRIES" = "ovsx" ] || [ "$REGISTRIES" = "all" ]; then
329+
echo "ERROR: source-run-id has no GitHub Release for Open VSX's tag-based trusted-publishing dispatch to target. Use registries=vsce for this path."
330+
exit 1
331+
fi
320332
fi
321333
322334
# Bypass requires confirmation (case-insensitive)
@@ -794,7 +806,17 @@ jobs:
794806
fi
795807
echo "VSIX_PATH=$VSIX_FILE" >> $GITHUB_ENV
796808
809+
# Open VSX is NOT published here -- see this file's header. The caller dispatches
810+
# publishOpenVSXTrusted.yml itself afterward instead, so this leg of the matrix (still
811+
# present when registries is ovsx/all, so the job's own success/skip status -- and every
812+
# downstream needs.publish.result == 'success' check -- stays exactly as it was) is a
813+
# deliberate no-op rather than a removed step.
814+
- name: Open VSX is published by the caller, not here
815+
if: matrix.publish-tool == 'ovsx'
816+
run: echo "Skipping -- the caller dispatches publishOpenVSXTrusted.yml for Open VSX. See this file's header comment."
817+
797818
- name: Publish to ${{ matrix.registry }}
819+
if: matrix.publish-tool != 'ovsx'
798820
uses: salesforcecli/github-workflows/.github/actions/publish-vsix@main
799821
with:
800822
vsix-path: ${{ env.VSIX_PATH }}
@@ -803,7 +825,6 @@ jobs:
803825
dry-run: ${{ inputs.dry-run || 'false' }}
804826
env:
805827
VSCE_PERSONAL_ACCESS_TOKEN: ${{ secrets.VSCE_PERSONAL_ACCESS_TOKEN }}
806-
OVSX_PAT: ${{ secrets.IDEE_OVSX_PAT }}
807828

808829
publish-to-cbweb-marketplace:
809830
name: Publish to CBWeb Internal Marketplace

‎.github/workflows/vscode-promote-prerelease.yml‎

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Promote Nightly to Pre-release
22

3-
# Publishes a nightly build to pre-release on VS Code Marketplace and Open VSX.
3+
# Publishes a nightly build to pre-release on the VS Code Marketplace. Open VSX is NOT published
4+
# from here. See "Open VSX Trusted Publishing" in this repo's README for why, and use this
5+
# workflow's `release-tag` output to dispatch your own Open VSX publish afterward.
46
#
57
# NOTE: Callers should use vscode-find-nightly-candidate.yml and check-ci-status action
68
# BEFORE calling this workflow to implement their own gate-check logic.
@@ -36,9 +38,9 @@ name: Promote Nightly to Pre-release
3638
# Requirements - calling repository must have:
3739
# - Nightly tags matching *-nightly.* (e.g., v1.2.3-nightly.20260629)
3840
# - GitHub releases for each nightly tag with VSIX file(s) attached
39-
# - Secrets: IDEE_GH_TOKEN, VSCE_PERSONAL_ACCESS_TOKEN, IDEE_OVSX_PAT
41+
# - Secrets: IDEE_GH_TOKEN, VSCE_PERSONAL_ACCESS_TOKEN
4042
#
41-
# Workflow: downloads VSIX → publishes to both marketplaces → creates tracking tag
43+
# Workflow: downloads VSIX → publishes to VS Code Marketplace → creates tracking tag
4244

4345
on:
4446
workflow_call:
@@ -120,14 +122,6 @@ permissions:
120122
jobs:
121123
publish:
122124
runs-on: ubuntu-latest
123-
strategy:
124-
fail-fast: false
125-
matrix:
126-
include:
127-
- registry: vsce
128-
publish-tool: vsce
129-
- registry: ovsx
130-
publish-tool: ovsx
131125
steps:
132126
- name: Checkout
133127
uses: actions/checkout@v6
@@ -151,15 +145,13 @@ jobs:
151145
--dir ./vsix-artifacts \
152146
--repo "${{ github.repository }}"
153147
154-
- name: Publish to ${{ matrix.registry }}
148+
- name: Publish to Visual Studio Marketplace
155149
env:
156150
NIGHTLY_TAG: ${{ inputs.release-tag }}
157151
VSIX_PATTERN: ${{ inputs.vsix-name-pattern || '*.vsix' }}
158152
EXCLUDE_WEB: ${{ inputs.exclude-web-vsix || 'false' }}
159-
PUBLISH_TOOL: ${{ matrix.publish-tool }}
160153
DRY_RUN: ${{ inputs.dry-run || 'false' }}
161154
VSCE_PERSONAL_ACCESS_TOKEN: ${{ secrets.VSCE_PERSONAL_ACCESS_TOKEN }}
162-
OVSX_PAT: ${{ secrets.IDEE_OVSX_PAT }}
163155
run: |
164156
set -uo pipefail
165157
@@ -177,20 +169,13 @@ jobs:
177169
exit 1
178170
fi
179171
180-
if [ "$PUBLISH_TOOL" = "ovsx" ]; then
181-
MARKETPLACE_NAME="Open VSX Registry"
182-
TOKEN="$OVSX_PAT"
183-
else
184-
MARKETPLACE_NAME="Visual Studio Marketplace"
185-
TOKEN="$VSCE_PERSONAL_ACCESS_TOKEN"
186-
fi
187-
172+
TOKEN="$VSCE_PERSONAL_ACCESS_TOKEN"
188173
if [ "$DRY_RUN" != "true" ] && [ -z "$TOKEN" ]; then
189-
echo "::error::Token for $PUBLISH_TOOL is not set"
174+
echo "::error::Token for vsce is not set"
190175
exit 1
191176
fi
192177
193-
echo "Publishing ${#VSIX_FILES[@]} VSIX(s) as pre-release to $MARKETPLACE_NAME:"
178+
echo "Publishing ${#VSIX_FILES[@]} VSIX(s) as pre-release to Visual Studio Marketplace:"
194179
printf ' %s\n' "${VSIX_FILES[@]}"
195180
196181
RUN_ID="${{ github.run_id }}"
@@ -199,7 +184,7 @@ jobs:
199184
FAILED=0
200185
201186
# Marketplace gallery requests can sit until typed-rest-client's 180s
202-
# socket timeout. vsce/ovsx have no timeout flag; retry per VSIX.
187+
# socket timeout. vsce has no timeout flag; retry per VSIX.
203188
# --skip-duplicate makes a retry a no-op if the first attempt committed.
204189
publish_with_retry() {
205190
local attempt
@@ -218,41 +203,32 @@ jobs:
218203
219204
for VSIX in "${VSIX_FILES[@]}"; do
220205
NAME=$(basename "$VSIX")
221-
echo "::group::$NAME → $MARKETPLACE_NAME"
206+
echo "::group::$NAME → Visual Studio Marketplace"
222207
223208
# Audit trail (mirrors the publish-vsix action's per-file record)
224209
HASH=$(sha256sum "$VSIX" 2>/dev/null | cut -d' ' -f1 || echo "unknown")
225-
echo "[AUDIT] actor=$ACTOR repo=$REPO run_id=$RUN_ID tool=$PUBLISH_TOOL file=$NAME hash=$HASH pre_release=true dry_run=$DRY_RUN"
210+
echo "[AUDIT] actor=$ACTOR repo=$REPO run_id=$RUN_ID tool=vsce file=$NAME hash=$HASH pre_release=true dry_run=$DRY_RUN"
226211
227212
if [ "$DRY_RUN" = "true" ]; then
228213
echo "🔍 DRY RUN - would publish $NAME (pre-release)"
229214
echo "::endgroup::"
230215
continue
231216
fi
232217
233-
if [ "$PUBLISH_TOOL" = "vsce" ]; then
234-
if VSCE_PAT="$TOKEN" publish_with_retry npx @vscode/vsce publish --packagePath "$VSIX" --skip-duplicate --pre-release; then
235-
echo "✅ Published $NAME to $MARKETPLACE_NAME"
236-
else
237-
echo "::error::Failed to publish $NAME to $MARKETPLACE_NAME"
238-
FAILED=1
239-
fi
218+
if VSCE_PAT="$TOKEN" publish_with_retry npx @vscode/vsce publish --packagePath "$VSIX" --skip-duplicate --pre-release; then
219+
echo "✅ Published $NAME to Visual Studio Marketplace"
240220
else
241-
if publish_with_retry npx ovsx publish "$VSIX" -p "$TOKEN" --skip-duplicate --pre-release; then
242-
echo "✅ Published $NAME to $MARKETPLACE_NAME"
243-
else
244-
echo "::error::Failed to publish $NAME to $MARKETPLACE_NAME"
245-
FAILED=1
246-
fi
221+
echo "::error::Failed to publish $NAME to Visual Studio Marketplace"
222+
FAILED=1
247223
fi
248224
echo "::endgroup::"
249225
done
250226
251227
if [ "$FAILED" -ne 0 ]; then
252-
echo "::error::One or more VSIX publishes failed for $PUBLISH_TOOL"
228+
echo "::error::One or more VSIX publishes failed for vsce"
253229
exit 1
254230
fi
255-
echo "✅ All ${#VSIX_FILES[@]} VSIX(s) processed for $MARKETPLACE_NAME"
231+
echo "✅ All ${#VSIX_FILES[@]} VSIX(s) processed for Visual Studio Marketplace"
256232
257233
tag-promoted:
258234
needs: publish

‎.github/workflows/vscode-promote-stable.yml‎

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Promote Pre-release to Stable
22

3-
# Reusable workflow for promoting a pre-release VS Code extension to stable.
3+
# Reusable workflow for promoting a pre-release VS Code extension to stable. Publishes to the VS
4+
# Code Marketplace only -- Open VSX is NOT published from here. See "Open VSX Trusted Publishing"
5+
# in this repo's README for why, and use this workflow's `release-tag` output to dispatch your
6+
# own Open VSX publish afterward.
47
#
58
# Usage from consuming repository:
69
# jobs:
@@ -15,20 +18,28 @@ name: Promote Pre-release to Stable
1518
# dry-run: 'false'
1619
# secrets: inherit
1720
#
21+
# publish-openvsx:
22+
# needs: promote
23+
# runs-on: ubuntu-latest
24+
# env:
25+
# GH_TOKEN: ${{ secrets.IDEE_GH_TOKEN }}
26+
# steps:
27+
# - run: gh workflow run publishOpenVSXTrusted.yml --repo "${{ github.repository }}" -f release-tag="${{ needs.promote.outputs.release-tag }}"
28+
#
1829
# Requirements - calling repository must have:
1930
# - marketplace-prerelease-* tracking tags
2031
# - Nightly tags matching v{version}-nightly.* pattern
2132
# - GitHub releases for each nightly tag with VSIX file(s) attached
2233
# - Passing CI checks on the nightly candidate commit
23-
# - Secrets: IDEE_GH_TOKEN, VSCE_PERSONAL_ACCESS_TOKEN, IDEE_OVSX_PAT
34+
# - Secrets: IDEE_GH_TOKEN, VSCE_PERSONAL_ACCESS_TOKEN
2435
# - The shared actions in this repository are resolved from the workflow branch.
2536
# - The package manager and lockfile inputs must match the caller repository.
2637
#
2738
# The caller supplies credentials and repository-specific paths; action implementations are
2839
# resolved from this repository so callers do not need duplicate composite actions.
2940
#
3041
# Workflow: finds latest pre-release → verifies quality gate → repackages VSIX
31-
# → publishes to both marketplaces → creates GitHub release → tags stable
42+
# → publishes to VS Code Marketplace → creates GitHub release → tags stable
3243
# → commits stable version back to main
3344

3445
on:
@@ -93,6 +104,10 @@ on:
93104
required: false
94105
default: 'npm ci'
95106
type: string
107+
outputs:
108+
release-tag:
109+
description: 'The stable GitHub release tag this run created (e.g. apex-language-server-extension-v1.2.3). Use this to dispatch your own Open VSX trusted-publishing workflow afterward -- see the header comment above.'
110+
value: ${{ jobs.create-github-release.outputs.release-tag }}
96111
workflow_dispatch:
97112
inputs:
98113
extension-name:
@@ -336,16 +351,13 @@ jobs:
336351
name: stable-vsix
337352
path: ${{ steps.repack.outputs.vsix-path }}
338353

354+
# Open VSX is NOT published from here -- see this file's header for why (trusted-publisher
355+
# match keys off workflow_ref, the run's initiating workflow, and allows only one registration
356+
# per extension, so it has to live in whichever single top-level workflow file the caller also
357+
# uses for its prerelease's Open VSX publish).
339358
publish:
340359
needs: [find-prerelease-candidate, repackage]
341360
runs-on: ubuntu-latest
342-
strategy:
343-
matrix:
344-
include:
345-
- registry: vsce
346-
publish-tool: vsce
347-
- registry: ovsx
348-
publish-tool: ovsx
349361
steps:
350362
- name: Checkout
351363
uses: actions/checkout@v6
@@ -379,20 +391,21 @@ jobs:
379391
fi
380392
echo "VSIX_PATH=$VSIX_FILE" >> $GITHUB_ENV
381393
382-
- name: Publish to ${{ matrix.registry }}
394+
- name: Publish to Visual Studio Marketplace
383395
uses: salesforcecli/github-workflows/.github/actions/publish-vsix@main
384396
with:
385397
vsix-path: ${{ env.VSIX_PATH }}
386-
publish-tool: ${{ matrix.publish-tool }}
398+
publish-tool: vsce
387399
pre-release: 'false'
388400
dry-run: ${{ inputs.dry-run || 'false' }}
389401
env:
390402
VSCE_PERSONAL_ACCESS_TOKEN: ${{ secrets.VSCE_PERSONAL_ACCESS_TOKEN }}
391-
OVSX_PAT: ${{ secrets.IDEE_OVSX_PAT }}
392403

393404
create-github-release:
394405
needs: [find-prerelease-candidate, repackage, publish]
395406
runs-on: ubuntu-latest
407+
outputs:
408+
release-tag: ${{ steps.release.outputs.release-tag }}
396409
steps:
397410
- name: Checkout
398411
uses: actions/checkout@v6
@@ -407,6 +420,7 @@ jobs:
407420
path: ./vsix-artifacts
408421

409422
- name: Create GitHub release for stable version
423+
id: release
410424
env:
411425
GH_TOKEN: ${{ secrets.IDEE_GH_TOKEN }}
412426
STABLE_VERSION: ${{ needs.find-prerelease-candidate.outputs.stable-version }}
@@ -427,6 +441,7 @@ jobs:
427441
# e.g., apex-language-server-extension-1.2.3.vsix -> apex-language-server-extension
428442
BASE_NAME=$(basename "$VSIX_FILE" .vsix | sed -E 's/-[0-9]+\.[0-9]+\.[0-9]+$//')
429443
RELEASE_TAG="${BASE_NAME}-v${STABLE_VERSION}"
444+
echo "release-tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
430445
RELEASE_TITLE="${BASE_NAME} v${STABLE_VERSION} (stable)"
431446
RELEASE_NOTES="## Stable Release v${STABLE_VERSION}
432447

0 commit comments

Comments
 (0)