Skip to content

Commit 9ae8e1d

Browse files
runningcodeclaude
andcommitted
ci(build): Add snapshot release workflow
Add a workflow_dispatch-triggered snapshot release pipeline that reuses the existing build workflow. Snapshot builds skip macOS code signing, override versions with a snapshot identifier, and publish to npm under the `snapshot` tag. - Add `workflow_call` inputs to build.yml for `skip-signing` and `snapshot-version` - Add `override-version` composite action to patch Cargo.toml, package.json, and npm-binary-distributions - Add `snapshot.yml` workflow that computes a snapshot version, triggers the build, and publishes to npm - Skip Python, Docker, and merge jobs for snapshot builds Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4271e21 commit 9ae8e1d

File tree

3 files changed

+181
-1
lines changed

3 files changed

+181
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Override Version
2+
description: Patch version strings for snapshot builds
3+
4+
inputs:
5+
version:
6+
required: true
7+
description: The version string to set
8+
target:
9+
required: true
10+
description: 'What to patch: cargo, npm, npm-distributions'
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Patch Cargo.toml and lockfile
16+
if: inputs.target == 'cargo'
17+
shell: bash
18+
run: |
19+
VERSION="${{ inputs.version }}"
20+
21+
sed -i.bak "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
22+
rm -f Cargo.toml.bak
23+
24+
awk -v ver="$VERSION" '
25+
/^name = "sentry-cli"/ { found = 1 }
26+
found && /^version = "/ { $0 = "version = \"" ver "\""; found = 0 }
27+
{ print }
28+
' Cargo.lock > Cargo.lock.tmp && mv Cargo.lock.tmp Cargo.lock
29+
30+
- name: Patch package.json
31+
if: inputs.target == 'npm'
32+
shell: bash
33+
run: |
34+
node -e "
35+
const fs = require('fs');
36+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
37+
pkg.version = '${{ inputs.version }}';
38+
for (const dep of Object.keys(pkg.optionalDependencies || {})) {
39+
pkg.optionalDependencies[dep] = '${{ inputs.version }}';
40+
}
41+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
42+
"
43+
44+
- name: Patch npm binary distribution packages
45+
if: inputs.target == 'npm-distributions'
46+
shell: bash
47+
run: |
48+
for pkgjson in npm-binary-distributions/*/package.json; do
49+
node -e "
50+
const fs = require('fs');
51+
const pkg = JSON.parse(fs.readFileSync('$pkgjson', 'utf8'));
52+
pkg.version = '${{ inputs.version }}';
53+
fs.writeFileSync('$pkgjson', JSON.stringify(pkg, null, 2) + '\n');
54+
"
55+
done

.github/workflows/build.yml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ on:
44
push:
55
branches:
66
- release/**
7+
workflow_call:
8+
inputs:
9+
skip-signing:
10+
type: boolean
11+
default: false
12+
snapshot-version:
13+
type: string
14+
default: ''
715

816
jobs:
917
linux:
@@ -33,6 +41,13 @@ jobs:
3341
steps:
3442
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
3543

44+
- name: Override version
45+
if: ${{ inputs.snapshot-version != '' }}
46+
uses: ./.github/actions/override-version
47+
with:
48+
version: ${{ inputs.snapshot-version }}
49+
target: cargo
50+
3651
- name: Add Rustup Target
3752
run: |
3853
rustup set profile minimal
@@ -69,6 +84,13 @@ jobs:
6984
steps:
7085
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
7186

87+
- name: Override version
88+
if: ${{ inputs.snapshot-version != '' }}
89+
uses: ./.github/actions/override-version
90+
with:
91+
version: ${{ inputs.snapshot-version }}
92+
target: cargo
93+
7294
- name: Add Rustup Target
7395
run: rustup target add ${{ matrix.target }}
7496

@@ -154,9 +176,11 @@ jobs:
154176

155177
steps:
156178
- name: Checkout repository
179+
if: ${{ !inputs.skip-signing }}
157180
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
158181

159182
- name: Install `rcodesign`
183+
if: ${{ !inputs.skip-signing }}
160184
run: |
161185
curl -L https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.29.0/apple-codesign-0.29.0-x86_64-unknown-linux-musl.tar.gz \
162186
-o rcodesign.tar.gz
@@ -166,6 +190,7 @@ jobs:
166190
rm rcodesign.tar.gz
167191
168192
- name: Decode Apple signing certificate and API key
193+
if: ${{ !inputs.skip-signing }}
169194
env:
170195
APPLE_CERT_DATA: ${{ secrets.APPLE_CERT_DATA }}
171196
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
@@ -179,6 +204,7 @@ jobs:
179204
name: unsigned-bin-macos-${{ matrix.arch }}
180205

181206
- name: Sign binary
207+
if: ${{ !inputs.skip-signing }}
182208
run: |
183209
rcodesign sign \
184210
--for-notarization \
@@ -188,17 +214,19 @@ jobs:
188214
sentry-cli-Darwin-${{ matrix.arch }}
189215
190216
- name: Zip signed binary
217+
if: ${{ !inputs.skip-signing }}
191218
run: |
192219
zip sentry-cli-Darwin-${{ matrix.arch }}.zip sentry-cli-Darwin-${{ matrix.arch }}
193220
194221
- name: Notarize binary
222+
if: ${{ !inputs.skip-signing }}
195223
run: |
196224
rcodesign notary-submit \
197225
--api-key-file ${{ env.APPLE_API_KEY_PATH }} \
198226
--wait \
199227
sentry-cli-Darwin-${{ matrix.arch }}.zip
200228
201-
- name: Upload signed binary
229+
- name: Upload binary
202230
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
203231
with:
204232
name: artifact-bin-macos-${{ matrix.arch }}
@@ -220,6 +248,13 @@ jobs:
220248
steps:
221249
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
222250

251+
- name: Override version
252+
if: ${{ inputs.snapshot-version != '' }}
253+
uses: ./.github/actions/override-version
254+
with:
255+
version: ${{ inputs.snapshot-version }}
256+
target: cargo
257+
223258
# When rustup is updated, it tries to replace its binary, which on Windows is somehow locked.
224259
# This can result in the CI failure, see: https://github.com/rust-lang/rustup/issues/3029
225260
- name: Disable rustup self-update
@@ -259,6 +294,13 @@ jobs:
259294
- name: Install dependencies
260295
run: npm ci --ignore-scripts
261296

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+
262304
- name: Download compiled binaries
263305
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
264306
with:
@@ -280,6 +322,7 @@ jobs:
280322
if-no-files-found: 'error'
281323

282324
python-base:
325+
if: ${{ !inputs.snapshot-version }}
283326
name: python (base)
284327
runs-on: ubuntu-24.04
285328
steps:
@@ -297,6 +340,7 @@ jobs:
297340
if-no-files-found: 'error'
298341

299342
python:
343+
if: ${{ !inputs.snapshot-version }}
300344
name: python
301345
runs-on: ubuntu-24.04
302346
needs: [linux, sign-macos-binaries, windows, python-base]
@@ -331,6 +375,12 @@ jobs:
331375
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # 6.2.0
332376
with:
333377
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
334384
- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
335385
with:
336386
pattern: artifact-bin-*
@@ -366,6 +416,7 @@ jobs:
366416
if-no-files-found: 'error'
367417

368418
platform-specific-docker:
419+
if: ${{ !inputs.snapshot-version }}
369420
name: Build Docker Image (${{ matrix.platform }})
370421
strategy:
371422
matrix:
@@ -402,6 +453,7 @@ jobs:
402453
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
403454

404455
multiarch-docker:
456+
if: ${{ !inputs.snapshot-version }}
405457
name: Create Multi-Architecture Docker Image
406458
needs: platform-specific-docker
407459
runs-on: ubuntu-24.04
@@ -422,6 +474,7 @@ jobs:
422474
ghcr.io/${{ github.repository }}:${{ github.sha }}-arm64
423475
424476
merge:
477+
if: ${{ !inputs.snapshot-version }}
425478
name: Create Release Artifact
426479
runs-on: ubuntu-24.04
427480
needs: [linux, sign-macos-binaries, windows, npm-distributions, node, python]

.github/workflows/snapshot.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Snapshot Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
compute-version:
8+
name: Compute Snapshot Version
9+
runs-on: ubuntu-24.04
10+
outputs:
11+
version: ${{ steps.version.outputs.version }}
12+
steps:
13+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
14+
15+
- name: Compute snapshot version
16+
id: version
17+
run: |
18+
CURRENT=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
19+
MAJOR=$(echo "$CURRENT" | cut -d. -f1)
20+
MINOR=$(echo "$CURRENT" | cut -d. -f2)
21+
NEXT_MINOR=$((MINOR + 1))
22+
DATE=$(date -u +%Y%m%d)
23+
SHORT_SHA=$(git rev-parse --short HEAD)
24+
VERSION="${MAJOR}.${NEXT_MINOR}.0-snapshot.${DATE}.${SHORT_SHA}"
25+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
26+
echo "Snapshot version: $VERSION"
27+
28+
build:
29+
name: Build
30+
needs: compute-version
31+
uses: ./.github/workflows/build.yml
32+
with:
33+
skip-signing: true
34+
snapshot-version: ${{ needs.compute-version.outputs.version }}
35+
secrets: inherit
36+
37+
publish-npm:
38+
name: Publish to npm
39+
needs: [compute-version, build]
40+
runs-on: ubuntu-24.04
41+
steps:
42+
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # 6.2.0
43+
with:
44+
node-version: '20.10.0'
45+
registry-url: 'https://registry.npmjs.org'
46+
47+
- name: Download npm binary distributions
48+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
49+
with:
50+
name: artifact-npm-binary-distributions
51+
path: npm-distributions
52+
53+
- name: Download node package
54+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
55+
with:
56+
name: artifact-pkg-node
57+
path: node-package
58+
59+
- name: Publish platform packages
60+
env:
61+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62+
run: |
63+
for pkg in npm-distributions/*.tgz; do
64+
echo "Publishing $pkg"
65+
npm publish "$pkg" --tag snapshot
66+
done
67+
68+
- name: Publish main package
69+
env:
70+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
71+
run: |
72+
npm publish node-package/*.tgz --tag snapshot

0 commit comments

Comments
 (0)