-
-
Notifications
You must be signed in to change notification settings - Fork 17
311 lines (262 loc) · 9.2 KB
/
Copy pathrelease-cli.yml
File metadata and controls
311 lines (262 loc) · 9.2 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
---
name: Release CLI (Ephemeral)
on:
workflow_call:
inputs:
version:
description: 'Version to release'
required: true
type: string
dry-run:
description: 'Dry run (no actual release)'
required: false
type: boolean
default: false
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.1.0)'
required: true
type: string
dry-run:
description: 'Dry run (no actual release)'
required: false
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
CARGO_INCREMENTAL: 0
concurrency:
group: release-cli-${{ github.repository }}
cancel-in-progress: false
permissions:
contents: write
packages: write
jobs:
generate-ephemeral-keys:
name: Generate Ephemeral Signing Keys
runs-on: ubuntu-latest
outputs:
key-id: ${{ steps.generate.outputs.key-id }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: Generate ephemeral keypair
id: generate
env:
AGE_KEY_PUBLIC: ${{ vars.AGE_KEY_PUBLIC }}
run: |
./ephemeral-gen.sh
KEY_ID=$(head -1 minisign.pub | sed 's/.*: //')
echo "key-id=${KEY_ID}" >> "$GITHUB_OUTPUT"
- name: Upload ephemeral keys
uses: actions/upload-artifact@v4
with:
name: ephemeral-keys
path: |
minisign.pub
minisign.key.age
retention-days: 1
build-binaries:
name: Build ${{ matrix.target }}
needs: generate-ephemeral-keys
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
use_cross: true
archive: tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
use_cross: true
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
use_cross: true
archive: tar.gz
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
use_cross: true
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
use_cross: false
archive: zip
- target: aarch64-apple-darwin
os: macos-latest
use_cross: false
archive: tar.gz
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Ensure target is installed
run: rustup target add ${{ matrix.target }}
- name: Install cross for cross-compilation
if: matrix.use_cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Download ephemeral keys
uses: actions/download-artifact@v4
with:
name: ephemeral-keys
- name: Cache signing tools
id: cache-signing
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/rsign
~/.cargo/bin/rage
key: signing-tools-${{ runner.os }}-rsign2-0.6.5-rage-0.11.1
- name: Install signing tools
if: steps.cache-signing.outputs.cache-hit != 'true'
shell: bash
run: |
cargo install rsign2 --locked
cargo install rage --locked
- name: Build binary
shell: bash
env:
BINARY_DEFAULT: ${{ vars.BINARY_DEFAULT }}
PACKAGE_NAME: ${{ vars.PACKAGE_NAME }}
run: |
if [ "${{ matrix.use_cross }}" = "true" ]; then
cross build --release --package "$PACKAGE_NAME" --bin "$BINARY_DEFAULT" --target "${{ matrix.target }}"
else
cargo build --release --package "$PACKAGE_NAME" --bin "$BINARY_DEFAULT" --target "${{ matrix.target }}"
fi
- name: Package binary (tar.gz)
if: matrix.archive == 'tar.gz'
shell: bash
env:
BINARY_DEFAULT: ${{ vars.BINARY_DEFAULT }}
run: |
cd "target/${{ matrix.target }}/release"
tar czf "../../../${BINARY_DEFAULT}-${{ inputs.version }}-${{ matrix.target }}.tar.gz" "$BINARY_DEFAULT"
- name: Package binary (zip, native Windows)
if: matrix.archive == 'zip' && runner.os == 'Windows'
env:
BINARY_DEFAULT: ${{ vars.BINARY_DEFAULT }}
shell: pwsh
run: |
cd "target/${{ matrix.target }}/release"
Compress-Archive -Path "${env:BINARY_DEFAULT}.exe" -DestinationPath "../../../${env:BINARY_DEFAULT}-${{ inputs.version }}-${{ matrix.target }}.zip"
- name: Package binary (zip, cross-compiled)
if: matrix.archive == 'zip' && runner.os != 'Windows'
shell: bash
env:
BINARY_DEFAULT: ${{ vars.BINARY_DEFAULT }}
run: |
cd "target/${{ matrix.target }}/release"
zip "../../../${BINARY_DEFAULT}-${{ inputs.version }}-${{ matrix.target }}.zip" "${BINARY_DEFAULT}.exe"
- name: Sign packages
env:
AGE_KEY_SECRET: ${{ secrets.AGE_KEY_SECRET }}
BINARY_DEFAULT: ${{ vars.BINARY_DEFAULT }}
shell: bash
run: |
bash ./ephemeral-sign.sh "${BINARY_DEFAULT}-${{ inputs.version }}-${{ matrix.target }}.${{ matrix.archive }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.target }}
path: |
${{ vars.BINARY_DEFAULT }}-*.tar.gz
${{ vars.BINARY_DEFAULT }}-*.tar.gz.sig
${{ vars.BINARY_DEFAULT }}-*.zip
${{ vars.BINARY_DEFAULT }}-*.zip.sig
minisign.pub
create-release:
name: Create Release
if: ${{ always() && !cancelled() && needs.generate-ephemeral-keys.result == 'success' }}
needs: [generate-ephemeral-keys, build-binaries]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release files
env:
BINARY_DEFAULT: ${{ vars.BINARY_DEFAULT }}
run: |
mkdir -p release
find artifacts -name "${BINARY_DEFAULT}-*" -type f -exec mv {} release/ \;
cp artifacts/binaries-*/minisign.pub release/ 2>/dev/null || cp artifacts/ephemeral-keys/minisign.pub release/
cd release
sha256sum "${BINARY_DEFAULT}"-*.{tar.gz,zip} > SHA256SUMS 2>/dev/null || true
cd ..
ls -la release/
- name: Create release notes
run: |
cat > release/RELEASE_NOTES.md << 'EOF'
## ${{ vars.BINARY_DEFAULT }} v${{ inputs.version }}
### Verification
This release uses ephemeral signing keys. To verify:
1. Download the binary, signature (`.sig`), and public key (`minisign.pub`)
2. Verify using minisign or rsign:
```bash
# Using minisign
minisign -V -p minisign.pub -m ${{ vars.BINARY_DEFAULT }}-${{ inputs.version }}-<target>.tar.gz
# Using rsign
rsign verify -p minisign.pub ${{ vars.BINARY_DEFAULT }}-${{ inputs.version }}-<target>.tar.gz
```
### Ephemeral Key ID
This release was signed with ephemeral key: `${{ needs.generate-ephemeral-keys.outputs.key-id }}`
### Installation
#### Unix-like systems
```bash
curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/main/install.sh | bash
```
#### Windows PowerShell
```powershell
irm https://raw.githubusercontent.com/${{ github.repository }}/main/install.ps1 | iex
```
### Supported Platforms
- Linux: x86_64, aarch64 (GNU and musl)
- Windows: x86_64 (MSVC)
- macOS: aarch64 (Apple Silicon)
### Checksums
SHA256 checksums are available in the `SHA256SUMS` file.
EOF
- name: Create GitHub Release
if: ${{ !inputs.dry-run }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ vars.TAG_PREFIX }}${{ inputs.version }}
name: ${{ vars.BINARY_DEFAULT }} v${{ inputs.version }}
body_path: release/RELEASE_NOTES.md
files: |
release/${{ vars.BINARY_DEFAULT }}-*.tar.gz
release/${{ vars.BINARY_DEFAULT }}-*.tar.gz.sig
release/${{ vars.BINARY_DEFAULT }}-*.zip
release/${{ vars.BINARY_DEFAULT }}-*.zip.sig
release/minisign.pub
release/SHA256SUMS
- name: Dry run summary
if: ${{ inputs.dry-run }}
run: |
echo "=== DRY RUN SUMMARY ==="
echo "Would have created release: ${{ vars.BINARY_DEFAULT }} v${{ inputs.version }}"
echo ""
echo "Files that would be uploaded:"
ls -la release/
echo ""
echo "Release notes:"
cat release/RELEASE_NOTES.md