-
Notifications
You must be signed in to change notification settings - Fork 2
363 lines (322 loc) · 11.6 KB
/
Copy pathrelease.yml
File metadata and controls
363 lines (322 loc) · 11.6 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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release (for example: v1.2.3)"
required: true
type: string
enable_signing_hooks:
description: "Run optional signing hooks when hook scripts are present"
required: false
default: false
type: boolean
enable_notarization_hooks:
description: "Run optional macOS notarization hook when hook script is present"
required: false
default: false
type: boolean
permissions:
contents: write
attestations: write
id-token: write
packages: write
env:
CARGO_TERM_COLOR: always
APP_NAME: tau-coding-agent
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
ENABLE_SIGNING_HOOKS: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.enable_signing_hooks || vars.RELEASE_ENABLE_SIGNING_HOOKS || 'false' }}
ENABLE_NOTARIZATION_HOOKS: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.enable_notarization_hooks || vars.RELEASE_ENABLE_NOTARIZATION_HOOKS || 'false' }}
jobs:
build:
name: Build (${{ matrix.platform }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
platform: linux-amd64
archive_ext: tar.gz
smoke_mode: run
smoke_reason: native_arch
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
platform: linux-arm64
archive_ext: tar.gz
smoke_mode: skip
smoke_reason: cross_arch_linux_arm64_on_amd64_runner
- os: macos-14
target: x86_64-apple-darwin
platform: macos-amd64
archive_ext: tar.gz
smoke_mode: skip
smoke_reason: cross_arch_macos_amd64_on_arm64_runner
- os: macos-14
target: aarch64-apple-darwin
platform: macos-arm64
archive_ext: tar.gz
smoke_mode: run
smoke_reason: native_arch
- os: windows-latest
target: x86_64-pc-windows-msvc
platform: windows-amd64
archive_ext: zip
smoke_mode: run
smoke_reason: native_arch
- os: windows-latest
target: aarch64-pc-windows-msvc
platform: windows-arm64
archive_ext: zip
smoke_mode: skip
smoke_reason: cross_arch_windows_arm64_on_amd64_runner
steps:
- name: Checkout tag
uses: actions/checkout@v6
with:
ref: ${{ env.RELEASE_TAG }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Linux ARM64 linker
if: matrix.target == 'aarch64-unknown-linux-gnu'
shell: bash
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install --yes gcc-aarch64-linux-gnu
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
- name: Build/package/smoke (Unix)
if: runner.os != 'Windows'
shell: bash
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: ${{ matrix.target == 'aarch64-unknown-linux-gnu' && 'aarch64-linux-gnu-gcc' || '' }}
run: |
set -euo pipefail
cargo build --release -p "${APP_NAME}" --target "${{ matrix.target }}"
mkdir -p dist
binary_path="target/${{ matrix.target }}/release/${APP_NAME}"
packaged_binary="dist/${APP_NAME}-${{ matrix.platform }}"
cp "${binary_path}" "${packaged_binary}"
chmod +x "${packaged_binary}"
if [[ "${ENABLE_SIGNING_HOOKS}" == "true" ]]; then
if [[ "${RUNNER_OS}" == "Linux" ]]; then
hook_path="scripts/release/hooks/sign-linux.sh"
else
hook_path="scripts/release/hooks/sign-macos.sh"
fi
if [[ -x "${hook_path}" ]]; then
"${hook_path}" "${packaged_binary}" "${{ matrix.target }}" "${RELEASE_TAG}"
else
echo "release_hook_reason=sign_hook_missing hook=${hook_path}"
fi
else
echo "release_hook_reason=sign_hooks_disabled"
fi
if [[ "${{ matrix.smoke_mode }}" == "run" ]]; then
# Smoke test gate: artifact must execute and print help before publish.
"${packaged_binary}" --help > /dev/null
else
echo "release_smoke_reason=${{ matrix.smoke_reason }}"
fi
archive_path="dist/${APP_NAME}-${{ matrix.platform }}.tar.gz"
tar -czf "${archive_path}" -C dist "${APP_NAME}-${{ matrix.platform }}"
if [[ "${RUNNER_OS}" == "macOS" && "${ENABLE_NOTARIZATION_HOOKS}" == "true" ]]; then
hook_path="scripts/release/hooks/notarize-macos.sh"
if [[ -x "${hook_path}" ]]; then
"${hook_path}" "${archive_path}" "${{ matrix.target }}" "${RELEASE_TAG}"
else
echo "release_hook_reason=notarize_hook_missing hook=${hook_path}"
fi
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
echo "release_hook_reason=notarization_hooks_disabled"
fi
- name: Build/package/smoke (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
cargo build --release -p "$env:APP_NAME" --target "${{ matrix.target }}"
New-Item -ItemType Directory -Force dist | Out-Null
$binaryPath = "target\\${{ matrix.target }}\\release\\$env:APP_NAME.exe"
$packagedBinary = "dist\\$env:APP_NAME-${{ matrix.platform }}.exe"
Copy-Item "$binaryPath" "$packagedBinary"
if ($env:ENABLE_SIGNING_HOOKS -eq "true") {
$hookPath = "scripts/release/hooks/sign-windows.ps1"
if (Test-Path $hookPath) {
& $hookPath -BinaryPath "$packagedBinary" -Target "${{ matrix.target }}" -Tag "$env:RELEASE_TAG"
} else {
Write-Output "release_hook_reason=sign_hook_missing hook=$hookPath"
}
} else {
Write-Output "release_hook_reason=sign_hooks_disabled"
}
if ("${{ matrix.smoke_mode }}" -eq "run") {
# Smoke test gate: artifact must execute and print help before publish.
& "$packagedBinary" --help | Out-Null
} else {
Write-Output "release_smoke_reason=${{ matrix.smoke_reason }}"
}
Compress-Archive -Path "$packagedBinary" -DestinationPath "dist\\$env:APP_NAME-${{ matrix.platform }}.zip" -Force
- name: Upload release artifact
uses: actions/upload-artifact@v6
with:
name: release-${{ matrix.platform }}
if-no-files-found: error
path: dist/${{ env.APP_NAME }}-${{ matrix.platform }}.${{ matrix.archive_ext }}
checksums:
name: Generate checksums
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download release artifacts
uses: actions/download-artifact@v7
with:
pattern: release-*
merge-multiple: true
path: dist
- name: Generate checksum manifests
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
artifacts=(dist/*.tar.gz dist/*.zip)
if [[ ${#artifacts[@]} -eq 0 ]]; then
echo "::error::no release archives were downloaded"
exit 1
fi
for artifact in "${artifacts[@]}"; do
sha256sum "${artifact}" > "${artifact}.sha256"
done
sha256sum "${artifacts[@]}" > dist/SHA256SUMS
- name: Upload checksum artifacts
uses: actions/upload-artifact@v6
with:
name: release-checksums
if-no-files-found: error
path: |
dist/*.sha256
dist/SHA256SUMS
publish:
name: Publish release
runs-on: ubuntu-latest
needs:
- build
- checksums
steps:
- name: Checkout tag
uses: actions/checkout@v6
with:
ref: ${{ env.RELEASE_TAG }}
- name: Download release artifacts
uses: actions/download-artifact@v7
with:
pattern: release-*
merge-multiple: true
path: dist
- name: Download checksums for Homebrew formula
uses: actions/download-artifact@v7
with:
name: release-checksums
path: dist
- name: Render Homebrew formula
shell: bash
run: |
set -euo pipefail
scripts/release/render-homebrew-formula.sh \
"${RELEASE_TAG}" \
dist/SHA256SUMS \
"${GITHUB_REPOSITORY}" > dist/tau.rb
- name: Generate shell completions
shell: bash
run: |
set -euo pipefail
tar -xzf "dist/${APP_NAME}-linux-amd64.tar.gz" -C dist
chmod +x "dist/${APP_NAME}-linux-amd64"
scripts/release/generate-shell-completions.sh \
"dist/${APP_NAME}-linux-amd64" \
dist/completions
- name: Verify staged files
shell: bash
run: |
set -euo pipefail
ls -la dist
- name: Attest release artifacts
uses: actions/attest-build-provenance@v3
with:
subject-path: |
dist/*.tar.gz
dist/*.zip
dist/*.sha256
dist/SHA256SUMS
dist/tau.rb
dist/completions/tau-coding-agent.bash
dist/completions/tau-coding-agent.zsh
dist/completions/tau-coding-agent.fish
- name: Publish release assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_TAG }}
generate_release_notes: true
files: |
dist/*.tar.gz
dist/*.zip
dist/*.sha256
dist/SHA256SUMS
dist/tau.rb
dist/completions/tau-coding-agent.bash
dist/completions/tau-coding-agent.zsh
dist/completions/tau-coding-agent.fish
publish-container:
name: Publish container image
runs-on: ubuntu-latest
needs:
- publish
steps:
- name: Checkout tag
uses: actions/checkout@v6
with:
ref: ${{ env.RELEASE_TAG }}
- name: Compute image metadata
id: image_meta
shell: bash
run: |
set -euo pipefail
owner_lowercase="${GITHUB_REPOSITORY_OWNER,,}"
echo "image_repository=ghcr.io/${owner_lowercase}/${APP_NAME}" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and publish container image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ steps.image_meta.outputs.image_repository }}:${{ env.RELEASE_TAG }}
${{ steps.image_meta.outputs.image_repository }}:latest
- name: Release summary
shell: bash
run: |
{
echo "### Container Publish"
echo "- Repository: ${{ steps.image_meta.outputs.image_repository }}"
echo "- Tags:"
echo " - ${{ env.RELEASE_TAG }}"
echo " - latest"
echo "- Platforms: linux/amd64,linux/arm64"
} >> "$GITHUB_STEP_SUMMARY"