Skip to content

Commit 813724a

Browse files
authored
ci(release): publish the VS Code extension on extension version bumps (#143)
Gates the extension publish job on npm publishes or a real extension version bump (diffed against the previous commit, replacing the commit-message-prefix check) and adds job-level least-privilege permissions. A pythinker changeset rides along to exercise the new path.
1 parent b04d937 commit 813724a

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
"pythinker": patch
3+
---
4+
Publish the extension with every release cycle.

.github/workflows/release.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
if: github.repository_owner == 'PyModel'
5454
outputs:
5555
packages_published: ${{ steps.changesets.outputs.published }}
56+
extension_version_bumped: ${{ steps.extension-version.outputs.bumped }}
5657
pythinker_native_release: ${{ steps.pythinker-release.outputs.should_publish }}
5758
pythinker_release_tag: ${{ steps.pythinker-release.outputs.tag }}
5859
permissions:
@@ -78,6 +79,18 @@ jobs:
7879
- name: Upgrade npm for Trusted Publishing
7980
run: npm install -g npm@11
8081

82+
# Machine-readable signal for the VS Code extension publish gate: the
83+
# release PR merge is a squash whose only meaningful delta for the
84+
# extension is the version field, so compare it against the previous
85+
# commit instead of trusting the commit-message prefix.
86+
- name: Detect extension version bump
87+
id: extension-version
88+
run: |
89+
prev=$(git show 'HEAD^:apps/vscode/package.json' | node -p 'JSON.parse(require("fs").readFileSync(0, "utf8")).version')
90+
curr=$(node -p 'require("./apps/vscode/package.json").version')
91+
if [ "$prev" = "$curr" ]; then bumped=false; else bumped=true; fi
92+
echo "bumped=$bumped" >> "$GITHUB_OUTPUT"
93+
8194
- name: Install dependencies
8295
run: pnpm install --frozen-lockfile
8396

@@ -133,13 +146,18 @@ jobs:
133146
# The VS Code extension is a private workspace package: changesets bumps its
134147
# version but never publishes it to npm, so it ships from here instead. Both
135148
# publish scripts skip packages that already exist in the registry, so this
136-
# job is a no-op on releases that did not touch the extension.
149+
# job is a no-op on releases that did not touch the extension. Extension-only
150+
# releases publish nothing to npm, so the gate also covers a version bump.
137151
publish-vscode-extension:
138152
timeout-minutes: 45
139153
name: Publish VS Code extension
140154
needs: release
141-
if: needs.release.outputs.packages_published == 'true'
155+
if: >-
156+
needs.release.outputs.packages_published == 'true'
157+
|| needs.release.outputs.extension_version_bumped == 'true'
142158
runs-on: ubuntu-latest
159+
permissions:
160+
contents: read
143161
steps:
144162
- name: Checkout
145163
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned from v6.0.2

0 commit comments

Comments
 (0)