-
-
Notifications
You must be signed in to change notification settings - Fork 244
106 lines (95 loc) · 3.54 KB
/
snapshot.yml
File metadata and controls
106 lines (95 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Snapshot Release
on:
push:
branches: [master]
permissions:
contents: write
packages: write
jobs:
prepare:
name: Prepare Snapshot
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.version.outputs.version }}
ref: ${{ steps.push.outputs.ref }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
# Computes a semver-compliant snapshot version based on the current
# version in Cargo.toml. The patch version is bumped so that the
# snapshot sorts higher than the current release but lower than the
# next real release. For example, if Cargo.toml has 3.3.1, the
# snapshot version will be 3.3.2-snapshot.20260312.abc1234.
- name: Compute snapshot version
id: version
run: |
CURRENT=$(cargo metadata --no-deps --format-version 1 \
| jq -er '(.workspace_default_members[0]) as $id | .packages[] | select(.id == $id) | .version')
MAJOR=$(echo "$CURRENT" | cut -d. -f1)
MINOR=$(echo "$CURRENT" | cut -d. -f2)
PATCH=$(echo "$CURRENT" | cut -d. -f3)
NEXT_PATCH=$((PATCH + 1))
DATE=$(date -u +%Y%m%d)
SHORT_SHA=$(git rev-parse --short HEAD)
VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}-snapshot.${DATE}.${SHORT_SHA}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "Snapshot version: $VERSION"
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # 6.3.0
with:
node-version: '20.10.0'
- name: Bump versions
run: scripts/bump-version.sh "${{ steps.version.outputs.current }}" "${{ steps.version.outputs.version }}"
- name: Push snapshot branch
id: push
run: |
BRANCH="snapshot/${{ steps.version.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git add -A
git commit -m "snapshot: ${{ steps.version.outputs.version }}"
git push origin "$BRANCH"
echo "ref=$BRANCH" >> "$GITHUB_OUTPUT"
build:
name: Build
needs: prepare
uses: ./.github/workflows/build.yml
with:
is-snapshot: true
checkout-ref: ${{ needs.prepare.outputs.ref }}
secrets: inherit
publish-github-release:
name: Publish GitHub Release
needs: [prepare, build]
runs-on: ubuntu-24.04
steps:
- name: Download binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # 8.0.1
with:
pattern: artifact-bin-*
merge-multiple: true
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
VERSION: ${{ needs.prepare.outputs.version }}
REF: ${{ needs.prepare.outputs.ref }}
run: |
gh release create "$VERSION" \
--target "$REF" \
--prerelease \
--title "$VERSION" \
--notes "Snapshot build from master at ${VERSION##*.}." \
sentry-cli-*
cleanup:
name: Cleanup
needs: [prepare, publish-github-release]
if: always()
runs-on: ubuntu-24.04
steps:
- name: Delete snapshot branch
if: needs.prepare.outputs.ref != ''
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api -X DELETE "repos/${{ github.repository }}/git/refs/heads/${{ needs.prepare.outputs.ref }}"