Skip to content

Commit d16a68d

Browse files
fix(ci): release the VS Code extension only when its version changes (#808)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent ecad49e commit d16a68d

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

.github/workflows/release-vscode-extension.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,39 @@ jobs:
3333
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3434
with:
3535
ref: ${{ github.sha }}
36+
# The parent commit too, to read the version this push replaced.
37+
fetch-depth: 2
3638

3739
- id: v
3840
env:
3941
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
EVENT_NAME: ${{ github.event_name }}
4043
run: |
44+
set -euo pipefail
4145
VERSION=$(node -p "require('./vscode-extension/package.json').version")
4246
if [[ "$VERSION" == *-* || "$VERSION" == *+* ]]; then
4347
echo "::error::vscode-extension version $VERSION is not strict SemVer MAJOR.MINOR.PATCH."
4448
exit 1
4549
fi
50+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
51+
52+
# A release is a version change, and nothing else. This workflow wakes
53+
# on any edit to the manifest, which also carries the icon, the
54+
# commands and the settings schema — so an unrelated edit would
55+
# otherwise ship whatever version happened to be sitting there.
56+
# Publishing a version the manifest already held is `workflow_dispatch`,
57+
# chosen deliberately.
58+
if [ "$EVENT_NAME" = "push" ]; then
59+
BEFORE=$(git show "${GITHUB_SHA}^:vscode-extension/package.json" 2>/dev/null \
60+
| node -p "JSON.parse(require('fs').readFileSync(0, 'utf8')).version" 2>/dev/null || echo "")
61+
if [ "$BEFORE" = "$VERSION" ]; then
62+
echo "::notice::vscode-extension stays at $VERSION — the manifest changed, the version did not. Nothing to release."
63+
echo "publish=false" >> "$GITHUB_OUTPUT"
64+
echo "release=false" >> "$GITHUB_OUTPUT"
65+
exit 0
66+
fi
67+
fi
68+
4669
MKT=$(curl -s -X POST https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery \
4770
-H "Content-Type: application/json" -H "Accept: application/json;api-version=7.2-preview.1" \
4871
-d '{"filters":[{"criteria":[{"filterType":7,"value":"tumaet.apollon-vscode"}]}],"flags":914}' \
@@ -58,7 +81,6 @@ jobs:
5881
else
5982
echo "release=true" >> "$GITHUB_OUTPUT"
6083
fi
61-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
6284
6385
build:
6486
name: Build VSIX
@@ -135,6 +157,15 @@ jobs:
135157
permissions:
136158
contents: read
137159
steps:
160+
# `.nvmrc` is the one source for the Node version, and this job has no
161+
# working tree to read it from. `checkout` cleans the directory, so it has
162+
# to precede the artifact download rather than follow it.
163+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
164+
with:
165+
ref: ${{ github.sha }}
166+
sparse-checkout: .nvmrc
167+
sparse-checkout-cone-mode: false
168+
138169
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
139170
with:
140171
name: vsix
@@ -204,7 +235,13 @@ jobs:
204235
git tag "$TAG" "$GITHUB_SHA"
205236
git push origin "refs/tags/$TAG"
206237
fi
207-
VSIX=$(ls *.vsix | head -n1)
238+
shopt -s nullglob
239+
files=( ./*.vsix )
240+
if [[ ${#files[@]} -ne 1 ]]; then
241+
echo "::error::Expected exactly 1 VSIX to attach, found ${#files[@]}: ${files[*]}"
242+
exit 1
243+
fi
244+
VSIX="${files[0]}"
208245
gh release create "$TAG" \
209246
--title "$TAG" \
210247
--target "$GITHUB_SHA" \

vscode-extension/CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ GitHub Releases at <https://github.com/ls1intum/Apollon/releases> (tag prefix `a
66

77
## [Unreleased]
88

9-
First Marketplace release pending. See the linked release workflow for the package state.
9+
`1.0.0` is pending, and will be the first release cut by the `Release VS Code Extension`
10+
workflow. It is not the extension's first Marketplace listing: `tumaet.apollon-vscode`
11+
has been published since 2024-11-18, last at `0.0.17`.
12+
13+
Upgrading from `0.0.17` leaves one trace behind. That version wrote
14+
`"files.associations": { "*.apollon": "json" }` into global user settings on every
15+
activation. Nothing writes it now, and nothing removes it either — `.apollon` files still
16+
open in the Apollon editor, but reopening one as text shows it as JSON rather than under
17+
this extension's own `apollon` language and file icon. Deleting that line from settings
18+
restores both.
1019

1120
[Unreleased]: https://github.com/ls1intum/Apollon/compare/main...HEAD

0 commit comments

Comments
 (0)