|
1
|
name: Release GitHub |
|
2
|
|
|
3
|
# Attaches the prebuilt `si` binaries, each with a .sha256 sidecar, to the GitHub release for the |
|
4
|
# tag, so Homebrew, Scoop or winget can be added later without rebuilding. Re-running overwrites |
|
5
|
# the assets on the same release, so a re-pushed or re-dispatched tag is harmless. |
|
6
|
|
|
7
|
on: |
|
8
|
push: |
|
9
|
tags: |
|
10
|
- "v*.*.*" |
|
11
|
workflow_dispatch: |
|
12
|
inputs: |
|
13
|
tag: |
|
14
|
description: "Release tag (e.g. v1.3.0)" |
|
15
|
required: true |
|
16
|
|
|
17
|
concurrency: |
|
18
|
group: ${{ github.workflow }}-${{ github.event.inputs.tag || github.ref_name }} |
|
19
|
cancel-in-progress: false |
|
20
|
|
|
21
|
permissions: |
|
22
|
contents: read |
|
23
|
|
|
24
|
env: |
|
25
|
CARGO_TERM_COLOR: always |
|
26
|
|
|
27
|
jobs: |
|
28
|
verify-version: |
|
29
|
runs-on: ubuntu-latest |
|
30
|
steps: |
|
31
|
- uses: actions/checkout@v6 |
|
32
|
with: |
|
33
|
ref: ${{ github.event.inputs.tag || github.ref }} |
|
34
|
- name: Tag matches the workspace version |
|
35
|
shell: bash |
|
36
|
env: |
|
37
|
TAG: ${{ github.event.inputs.tag || github.ref_name }} |
|
38
|
run: | |
|
39
|
workspace=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) |
|
40
|
if [ "$TAG" != "v$workspace" ]; then |
|
41
|
echo "::error::tag $TAG does not match the workspace version $workspace" |
|
42
|
exit 1 |
|
43
|
fi |
|
44
|
|
|
45
|
build: |
|
46
|
name: Build binary (${{ matrix.build.NAME }}) |
|
47
|
needs: verify-version |
|
48
|
runs-on: ${{ matrix.build.OS }} |
|
49
|
strategy: |
|
50
|
fail-fast: false |
|
51
|
matrix: |
|
52
|
build: |
|
53
|
- { |
|
54
|
NAME: linux-x64, |
|
55
|
OS: ubuntu-22.04, |
|
56
|
TARGET: x86_64-unknown-linux-gnu, |
|
57
|
} |
|
58
|
- { |
|
59
|
NAME: linux-arm64, |
|
60
|
OS: ubuntu-22.04-arm, |
|
61
|
TARGET: aarch64-unknown-linux-gnu, |
|
62
|
} |
|
63
|
- { |
|
64
|
NAME: windows-x64, |
|
65
|
OS: windows-2022, |
|
66
|
TARGET: x86_64-pc-windows-msvc, |
|
67
|
} |
|
68
|
- { |
|
69
|
NAME: windows-arm64, |
|
70
|
OS: windows-2022, |
|
71
|
TARGET: aarch64-pc-windows-msvc, |
|
72
|
} |
|
73
|
- { NAME: darwin-x64, OS: macos-26, TARGET: x86_64-apple-darwin } |
|
74
|
- { NAME: darwin-arm64, OS: macos-26, TARGET: aarch64-apple-darwin } |
|
75
|
steps: |
|
76
|
- name: Checkout |
|
77
|
uses: actions/checkout@v6 |
|
78
|
with: |
|
79
|
ref: ${{ github.event.inputs.tag || github.ref }} |
|
80
|
|
|
81
|
- name: Read Rust toolchain |
|
82
|
shell: bash |
|
83
|
run: | |
|
84
|
rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)" |
|
85
|
if [ -z "$rust_toolchain" ]; then |
|
86
|
echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2 |
|
87
|
exit 1 |
|
88
|
fi |
|
89
|
echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV" |
|
90
|
|
|
91
|
- name: Install Rust toolchain |
|
92
|
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 |
|
93
|
with: |
|
94
|
toolchain: ${{ env.RUST_TOOLCHAIN }} |
|
95
|
|
|
96
|
- name: Install Rust target |
|
97
|
shell: bash |
|
98
|
run: | |
|
99
|
rustup target add ${{ matrix.build.TARGET }} --toolchain ${{ env.RUST_TOOLCHAIN }} |
|
100
|
rustup target list --installed |
|
101
|
|
|
102
|
- name: Setup Rust cache |
|
103
|
uses: Swatinem/rust-cache@v2 |
|
104
|
with: |
|
105
|
key: github-${{ matrix.build.TARGET }} |
|
106
|
|
|
107
|
# Linux builds on the oldest runner image for its glibc floor (2.35). The repo uses rustls, |
|
108
|
# so there is no OpenSSL to link or vendor. |
|
109
|
- name: Build binary |
|
110
|
shell: bash |
|
111
|
run: cargo build --locked --release -p sigit-si-cli --bin si --target ${{ matrix.build.TARGET }} |
|
112
|
|
|
113
|
# The exe must not import the VC++ runtime DLLs (see .cargo/config.toml), or it fails to |
|
114
|
# load on a machine without the redistributable. |
|
115
|
- name: Check static CRT |
|
116
|
if: contains(matrix.build.TARGET, 'windows') |
|
117
|
shell: pwsh |
|
118
|
run: ./packaging/windows/check-static-crt.ps1 -Path target/${{ matrix.build.TARGET }}/release/si.exe |
|
119
|
|
|
120
|
# Windows runners use bash from Git for Windows, which has sha256sum; macOS only has shasum. |
|
121
|
- name: Package binary and checksum |
|
122
|
shell: bash |
|
123
|
env: |
|
124
|
BUILD_NAME: ${{ matrix.build.NAME }} |
|
125
|
TARGET: ${{ matrix.build.TARGET }} |
|
126
|
run: | |
|
127
|
suffix="" |
|
128
|
if [[ "${BUILD_NAME}" == windows-* ]]; then |
|
129
|
suffix=".exe" |
|
130
|
fi |
|
131
|
|
|
132
|
mkdir -p release |
|
133
|
asset="si-${BUILD_NAME}${suffix}" |
|
134
|
cp "target/${TARGET}/release/si${suffix}" "release/${asset}" |
|
135
|
|
|
136
|
cd release |
|
137
|
if command -v sha256sum >/dev/null 2>&1; then |
|
138
|
sha256sum "${asset}" | awk '{print $1}' > "${asset}.sha256" |
|
139
|
else |
|
140
|
shasum -a 256 "${asset}" | awk '{print $1}' > "${asset}.sha256" |
|
141
|
fi |
|
142
|
echo "${asset}: $(cat "${asset}.sha256")" |
|
143
|
|
|
144
|
- name: Upload binary artifact |
|
145
|
uses: actions/upload-artifact@v4 |
|
146
|
with: |
|
147
|
name: github-binary-${{ matrix.build.NAME }} |
|
148
|
path: release/* |
|
149
|
|
|
150
|
release: |
|
151
|
name: Create GitHub release |
|
152
|
needs: build |
|
153
|
runs-on: ubuntu-latest |
|
154
|
permissions: |
|
155
|
contents: write |
|
156
|
steps: |
|
157
|
- name: Download binary artifacts |
|
158
|
uses: actions/download-artifact@v4 |
|
159
|
with: |
|
160
|
pattern: github-binary-* |
|
161
|
path: release |
|
162
|
merge-multiple: true |
|
163
|
|
|
164
|
- name: Release |
|
165
|
uses: softprops/action-gh-release@v2 |
|
166
|
with: |
|
167
|
tag_name: ${{ github.event.inputs.tag || github.ref_name }} |
|
168
|
files: release/* |
|
169
|
generate_release_notes: true |