Skip to content

Commit 07245bc

Browse files
committed
ci(release): gate the extension publish on a version-bump signal
1 parent b5fa6e9 commit 07245bc

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 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

@@ -134,15 +147,17 @@ jobs:
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
136149
# job is a no-op on releases that did not touch the extension. Extension-only
137-
# releases publish nothing to npm, so also run on release-PR merges.
150+
# releases publish nothing to npm, so the gate also covers a version bump.
138151
publish-vscode-extension:
139152
timeout-minutes: 45
140153
name: Publish VS Code extension
141154
needs: release
142155
if: >-
143156
needs.release.outputs.packages_published == 'true'
144-
|| startsWith(github.event.head_commit.message, 'ci: release packages')
157+
|| needs.release.outputs.extension_version_bumped == 'true'
145158
runs-on: ubuntu-latest
159+
permissions:
160+
contents: read
146161
steps:
147162
- name: Checkout
148163
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned from v6.0.2

0 commit comments

Comments
 (0)