Skip to content

Commit 9947a3c

Browse files
runningcodeclaude
andcommitted
ref(ci): Align snapshot versioning with release workflow
Instead of patching version files at build time via the override-version composite action, snapshots now follow the same pattern as releases: bump all version files upfront using bump-version.sh, commit to a temporary snapshot branch, and let build.yml build from correct source. This removes the fragile override-version action (called 5 times across different jobs with sed/awk/node), replaces the snapshot-version input with checkout-ref and is-snapshot, and adds a cleanup job to delete the temporary branch after publish. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9ae8e1d commit 9947a3c

3 files changed

Lines changed: 71 additions & 97 deletions

File tree

.github/actions/override-version/action.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ on:
99
skip-signing:
1010
type: boolean
1111
default: false
12-
snapshot-version:
12+
is-snapshot:
13+
type: boolean
14+
default: false
15+
checkout-ref:
1316
type: string
1417
default: ''
1518

@@ -40,13 +43,8 @@ jobs:
4043

4144
steps:
4245
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
43-
44-
- name: Override version
45-
if: ${{ inputs.snapshot-version != '' }}
46-
uses: ./.github/actions/override-version
4746
with:
48-
version: ${{ inputs.snapshot-version }}
49-
target: cargo
47+
ref: ${{ inputs.checkout-ref }}
5048

5149
- name: Add Rustup Target
5250
run: |
@@ -83,13 +81,8 @@ jobs:
8381

8482
steps:
8583
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
86-
87-
- name: Override version
88-
if: ${{ inputs.snapshot-version != '' }}
89-
uses: ./.github/actions/override-version
9084
with:
91-
version: ${{ inputs.snapshot-version }}
92-
target: cargo
85+
ref: ${{ inputs.checkout-ref }}
9386

9487
- name: Add Rustup Target
9588
run: rustup target add ${{ matrix.target }}
@@ -178,6 +171,8 @@ jobs:
178171
- name: Checkout repository
179172
if: ${{ !inputs.skip-signing }}
180173
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
174+
with:
175+
ref: ${{ inputs.checkout-ref }}
181176

182177
- name: Install `rcodesign`
183178
if: ${{ !inputs.skip-signing }}
@@ -247,13 +242,8 @@ jobs:
247242

248243
steps:
249244
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
250-
251-
- name: Override version
252-
if: ${{ inputs.snapshot-version != '' }}
253-
uses: ./.github/actions/override-version
254245
with:
255-
version: ${{ inputs.snapshot-version }}
256-
target: cargo
246+
ref: ${{ inputs.checkout-ref }}
257247

258248
# When rustup is updated, it tries to replace its binary, which on Windows is somehow locked.
259249
# This can result in the CI failure, see: https://github.com/rust-lang/rustup/issues/3029
@@ -286,6 +276,8 @@ jobs:
286276

287277
steps:
288278
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
279+
with:
280+
ref: ${{ inputs.checkout-ref }}
289281

290282
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # 6.2.0
291283
with:
@@ -294,13 +286,6 @@ jobs:
294286
- name: Install dependencies
295287
run: npm ci --ignore-scripts
296288

297-
- name: Override version
298-
if: ${{ inputs.snapshot-version != '' }}
299-
uses: ./.github/actions/override-version
300-
with:
301-
version: ${{ inputs.snapshot-version }}
302-
target: npm
303-
304289
- name: Download compiled binaries
305290
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
306291
with:
@@ -322,11 +307,13 @@ jobs:
322307
if-no-files-found: 'error'
323308

324309
python-base:
325-
if: ${{ !inputs.snapshot-version }}
310+
if: ${{ !inputs.is-snapshot }}
326311
name: python (base)
327312
runs-on: ubuntu-24.04
328313
steps:
329314
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
315+
with:
316+
ref: ${{ inputs.checkout-ref }}
330317
- name: Add Rustup Target
331318
run: rustup target add x86_64-unknown-linux-musl
332319
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # 6.2.0
@@ -340,12 +327,14 @@ jobs:
340327
if-no-files-found: 'error'
341328

342329
python:
343-
if: ${{ !inputs.snapshot-version }}
330+
if: ${{ !inputs.is-snapshot }}
344331
name: python
345332
runs-on: ubuntu-24.04
346333
needs: [linux, sign-macos-binaries, windows, python-base]
347334
steps:
348335
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
336+
with:
337+
ref: ${{ inputs.checkout-ref }}
349338
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # 6.2.0
350339
with:
351340
python-version: '3.11'
@@ -372,15 +361,11 @@ jobs:
372361
needs: [linux, sign-macos-binaries, windows]
373362
steps:
374363
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
364+
with:
365+
ref: ${{ inputs.checkout-ref }}
375366
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # 6.2.0
376367
with:
377368
node-version: '20.10.0'
378-
- name: Override version
379-
if: ${{ inputs.snapshot-version != '' }}
380-
uses: ./.github/actions/override-version
381-
with:
382-
version: ${{ inputs.snapshot-version }}
383-
target: npm-distributions
384369
- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
385370
with:
386371
pattern: artifact-bin-*
@@ -416,7 +401,7 @@ jobs:
416401
if-no-files-found: 'error'
417402

418403
platform-specific-docker:
419-
if: ${{ !inputs.snapshot-version }}
404+
if: ${{ !inputs.is-snapshot }}
420405
name: Build Docker Image (${{ matrix.platform }})
421406
strategy:
422407
matrix:
@@ -431,6 +416,8 @@ jobs:
431416
packages: write
432417
steps:
433418
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
419+
with:
420+
ref: ${{ inputs.checkout-ref }}
434421

435422
- name: Set up Docker Buildx
436423
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # 3.12.0
@@ -453,7 +440,7 @@ jobs:
453440
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
454441

455442
multiarch-docker:
456-
if: ${{ !inputs.snapshot-version }}
443+
if: ${{ !inputs.is-snapshot }}
457444
name: Create Multi-Architecture Docker Image
458445
needs: platform-specific-docker
459446
runs-on: ubuntu-24.04
@@ -474,7 +461,7 @@ jobs:
474461
ghcr.io/${{ github.repository }}:${{ github.sha }}-arm64
475462
476463
merge:
477-
if: ${{ !inputs.snapshot-version }}
464+
if: ${{ !inputs.is-snapshot }}
478465
name: Create Release Artifact
479466
runs-on: ubuntu-24.04
480467
needs: [linux, sign-macos-binaries, windows, npm-distributions, node, python]

.github/workflows/snapshot.yml

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@ name: Snapshot Release
33
on:
44
workflow_dispatch:
55

6+
permissions:
7+
contents: write
8+
69
jobs:
7-
compute-version:
8-
name: Compute Snapshot Version
10+
prepare:
11+
name: Prepare Snapshot
912
runs-on: ubuntu-24.04
1013
outputs:
1114
version: ${{ steps.version.outputs.version }}
15+
ref: ${{ steps.push.outputs.ref }}
1216
steps:
1317
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
1418

19+
# Computes a semver-compliant snapshot version based on the current
20+
# version in Cargo.toml. The minor version is bumped so that the
21+
# snapshot sorts higher than the current release but lower than the
22+
# next real release. For example, if Cargo.toml has 3.3.1, the
23+
# snapshot version will be 3.4.0-snapshot.20260312.abc1234.
1524
- name: Compute snapshot version
1625
id: version
1726
run: |
@@ -23,20 +32,41 @@ jobs:
2332
SHORT_SHA=$(git rev-parse --short HEAD)
2433
VERSION="${MAJOR}.${NEXT_MINOR}.0-snapshot.${DATE}.${SHORT_SHA}"
2534
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
35+
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
2636
echo "Snapshot version: $VERSION"
2737
38+
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # 6.2.0
39+
with:
40+
node-version: '20.10.0'
41+
42+
- name: Bump versions
43+
run: scripts/bump-version.sh "${{ steps.version.outputs.current }}" "${{ steps.version.outputs.version }}"
44+
45+
- name: Push snapshot branch
46+
id: push
47+
run: |
48+
BRANCH="snapshot/${{ steps.version.outputs.version }}"
49+
git config user.name "github-actions[bot]"
50+
git config user.email "github-actions[bot]@users.noreply.github.com"
51+
git checkout -b "$BRANCH"
52+
git add -A
53+
git commit -m "snapshot: ${{ steps.version.outputs.version }}"
54+
git push origin "$BRANCH"
55+
echo "ref=$BRANCH" >> "$GITHUB_OUTPUT"
56+
2857
build:
2958
name: Build
30-
needs: compute-version
59+
needs: prepare
3160
uses: ./.github/workflows/build.yml
3261
with:
3362
skip-signing: true
34-
snapshot-version: ${{ needs.compute-version.outputs.version }}
63+
is-snapshot: true
64+
checkout-ref: ${{ needs.prepare.outputs.ref }}
3565
secrets: inherit
3666

3767
publish-npm:
3868
name: Publish to npm
39-
needs: [compute-version, build]
69+
needs: [prepare, build]
4070
runs-on: ubuntu-24.04
4171
steps:
4272
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # 6.2.0
@@ -70,3 +100,15 @@ jobs:
70100
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
71101
run: |
72102
npm publish node-package/*.tgz --tag snapshot
103+
104+
cleanup:
105+
name: Cleanup
106+
needs: [prepare, publish-npm]
107+
if: always()
108+
runs-on: ubuntu-24.04
109+
steps:
110+
- name: Delete snapshot branch
111+
env:
112+
GH_TOKEN: ${{ github.token }}
113+
run: |
114+
gh api -X DELETE "repos/${{ github.repository }}/git/refs/heads/${{ needs.prepare.outputs.ref }}" || true

0 commit comments

Comments
 (0)