-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (141 loc) · 4.86 KB
/
release.yml
File metadata and controls
163 lines (141 loc) · 4.86 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Release
on:
workflow_dispatch:
push:
branches:
- main
jobs:
prepare-release:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Calculate version
id: version
run: |
# CalVer: YEAR.MONTH.DAY+HHMM — e.g., 2026.4.7+1823
# The +HHMM build metadata ensures uniqueness for multiple same-day
# releases. Per semver, build metadata is ignored for version
# comparison (2026.4.7+0900 == 2026.4.7+1400), but that's fine
# since this package isn't published to crates.io — the version
# only appears in the compiled binary and git tags.
VERSION="$(date -u +%-Y.%-m.%-d+%H%M)"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Version: ${VERSION}"
push-release:
name: Push Release Branch and Tag
needs: prepare-release
runs-on:
group: gusto-ubuntu-default
outputs:
version: ${{ needs.prepare-release.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup git user
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Merge to release branch and tag
run: |
set -euo pipefail
VERSION="${{ needs.prepare-release.outputs.version }}"
# Checkout or create release branch
if git fetch origin release:release 2>/dev/null; then
git checkout release
else
git checkout -b release
fi
# Merge main into release (no commit yet)
git merge origin/main --no-commit --no-ff || true
# Update version in Cargo.toml (replace any existing version)
sed -i 's/^version = ".*"/version = "'"${VERSION}"'"/' Cargo.toml
grep -q "^version = \"${VERSION}\"" Cargo.toml || { echo "Version update failed"; exit 1; }
# Commit release with version bump
git add -A
git commit -m "Release v${VERSION}"
# Create tag
git tag "v${VERSION}"
# Push release branch and tag
git push origin release --force-with-lease
git push origin "v${VERSION}"
build:
name: Build ${{ matrix.target }}
needs: push-release
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
runner: macos-latest
use-cross: false
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
use-cross: true
- target: x86_64-unknown-linux-musl
runner: ubuntu-latest
use-cross: true
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
use-cross: true
steps:
- name: Checkout release branch
uses: actions/checkout@v4
with:
ref: release
- name: Install Rust
run: rustup update stable && rustup default stable
- name: Install cross
if: matrix.use-cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build with cross
if: matrix.use-cross
run: cross build --release --target ${{ matrix.target }}
- name: Add Rust target
if: ${{ !matrix.use-cross }}
run: rustup target add ${{ matrix.target }}
- name: Build with cargo
if: ${{ !matrix.use-cross }}
run: cargo build --release --target ${{ matrix.target }}
- name: Create tarball
run: |
set -euo pipefail
mkdir -p dist
cp target/${{ matrix.target }}/release/scope dist/
cp target/${{ matrix.target }}/release/scope-intercept dist/
tar -czvf dev-scope-${{ matrix.target }}.tar.gz -C dist .
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dev-scope-${{ matrix.target }}
path: dev-scope-${{ matrix.target }}.tar.gz
release:
name: Create GitHub Release
needs: [push-release, build]
runs-on:
group: gusto-ubuntu-default
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
VERSION="${{ needs.push-release.outputs.version }}"
gh release create "v${VERSION}" \
--title "v${VERSION}" \
--notes "" \
artifacts/*.tar.gz