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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
name: Release
on:
push:
tags:
# Recovery/backfill path: build and attach assets to a tag that already
# exists. Needed because auto-release.yml pushes the release tag using
# secrets.GITHUB_TOKEN, and GitHub deliberately does not start workflows
# from GITHUB_TOKEN-created events -- so the `push: tags` trigger above
# never fires for an automated release and the tag ends up with no binaries.
workflow_dispatch:
inputs:
tag:
description: "Existing tag to build and attach assets to (e.g. v0.0.22)"
required: true
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
permissions:
contents: write
actions: read
jobs:
runner:
uses: zakuro-ai/zakuro-infra/.github/workflows/pick-runner.yml@main
permissions:
secrets: inherit
release:
# Push-only: on the dispatch path the release already exists, and
# generate_release_notes would overwrite auto-release's git-cliff body.
if: github.event_name == 'push'
needs: runner
runs-on: ${{ needs.runner.outputs.runner }}
timeout-minutes: 10
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Create GitHub Release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3
with:
generate_release_notes: true
# Build the Linux binaries and attach them so `zc update` (prebuilt path)
# works without a source build. Mirrors build.yml's proven ARC setup
# (private-dep deploy key + hooks feature).
#
# arm64 is CROSS-COMPILED from the same x86_64 runner rather than built on an
# arm64 runner, because the org has none. The asset names must match
# `asset_name()` in src/update.rs exactly -- it already expects
# `zc-linux-arm64`, so until this job existed an arm64 host asking for an
# update got a 404.
build-linux:
needs:
# `skipped` is the normal state on the workflow_dispatch path.
if: ${{ always() && (needs.release.result == 'success' || needs.release.result == 'skipped') }}
runs-on: ${{ needs.runner.outputs.runner }}
timeout-minutes: 30
env:
HOME: /home/runner
# Debian 11 / Ubuntu 20.04. Chosen to cover Ubuntu 22.04 (2.35), which
# is what the mesh hosts run, with room below it. Raising this strands
# every host older than the new value, so it moves only deliberately.
GLIBC_FLOOR: "2.31"
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
asset: zc-linux-x86_64
cross: false
- target: aarch64-unknown-linux-gnu
asset: zc-linux-arm64
cross: true
steps:
# ARC runners reuse $HOME between jobs, and a job that sets the
# `url.ssh://git@github.com/zakuro-ai/.insteadOf` rewrite for the private
# drive dep leaves it in the GLOBAL gitconfig. The next job's checkout
# then clones zc itself over ssh with a deploy key scoped to
# zakuro-drive, and fails with a misleading "ERROR: Repository not
# found." Strip any stale rewrite BEFORE checkout.
- name: Purge stale git URL rewrites (ARC runner hygiene)
shell: bash
run: |
git config --global --remove-section 'url.ssh://git@github.com/zakuro-ai/' 2>/dev/null || true
git config --global --remove-section 'url.ssh://git@github.com/zakuro-ai/zakuro-drive' 2>/dev/null || true
git config --global --unset-all core.sshCommand 2>/dev/null || true
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ inputs.tag || github.ref_name }}
- name: Git auth for private zakuro-drive dependency (read-only deploy key)
shell: bash
run: |
mkdir -p ~/.ssh && chmod 700 ~/.ssh
printf '%s\n' "${{ secrets.DRIVE_DEPLOY_KEY }}" > ~/.ssh/zakuro_drive_deploy
chmod 600 ~/.ssh/zakuro_drive_deploy
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
git config --global core.sshCommand "ssh -i ~/.ssh/zakuro_drive_deploy -o IdentitiesOnly=yes"
git config --global url."ssh://git@github.com/zakuro-ai/".insteadOf "https://github.com/zakuro-ai/"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
toolchain: "stable"
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
key: ${{ matrix.target }}
# Build against an OLD glibc, not the runner's.
#
# `cargo build` links against whatever libc the runner happens to have,
# and the ARC image was upgraded to one with glibc 2.39. Every Linux
# release from v0.0.23 on therefore refused to start on Ubuntu 22.04
# (glibc 2.35) with
# /usr/local/bin/zc: /lib/x86_64-linux-gnu/libc.so.6: version
# `GLIBC_2.39' not found
# Nothing caught it: the binaries were the right architecture, the
# release was green, and hosts simply could not run the result. x399 sat
# on v0.0.21 for that reason.
#
# cargo-zigbuild pins the floor explicitly via the `.2.31` target suffix,
# so the produced binary is portable to anything at least that old
# regardless of what the runner is. Zig also supplies the cross C
# compiler, which replaces the gcc-aarch64/libc6-dev-arm64-cross install
# this step used to do for the QUIC stack's C dependencies.
# `pip` is not on PATH on the ARC image -- the same minimalism that
# already cost this job `file` (see "Verify architecture" below). The
# v0.0.33 run died here with `pip: command not found`, exit 127, before
# compiling anything, so BOTH Linux assets were missing from the release
# while the macOS one published and the run still produced a release.
# That is the failure mode the glibc work existed to end, reappearing one
# step earlier.
#
# `python3 -m pip` rather than the `pip` shim: python3 is present (see
# auto-release.yml), only the console script is not. apt is the fallback
# and not the default, because installing it on every run would add a
# package index refresh to a job that does not otherwise need one.
# Zig comes from ziglang.org, not from PyPI. The `ziglang` wheel that
# this step used is a convenience repackaging, and routing a toolchain
# through the runner's system Python failed three times running, each
# time on a different property of that Python:
#
# 1. no `pip` console script -> exit 127 (v0.0.33's release)
# 2. PEP 668 externally-managed -> `pip install --user` refused
# 3. no `ensurepip` -> `python3 -m venv` refused
#
# and the wheel ships no `zig` executable entry point either, so the
# `echo .../bin >> GITHUB_PATH` line the step carried from the start
# never put a zig on PATH at all -- cargo-zigbuild only ever found it
# through its `python3 -m ziglang` fallback.
#
# The upstream tarball has none of those properties. It needs curl, tar
# and xz, and it lands a real `zig` with its `lib/` beside it, which is
# what both cargo-zigbuild and the PATH check below actually want.
#
# Pinned by sha256 from https://ziglang.org/download/index.json, because
# this is now a binary fetched over the network rather than a versioned
# package from an index.
- name: Install zig and cargo-zigbuild
env:
ZIG_VERSION: "0.13.0"
ZIG_SHA256_X86_64: "d45312e61ebcc48032b77bc4cf7fd6915c11fa16e4aad116b66c9468211230ea"
ZIG_SHA256_AARCH64: "041ac42323837eb5624068acd8b00cd5777dac4cf91179e8dad7a7e90dd0c556"
run: |
set -euo pipefail
# The HOST architecture, not matrix.target -- zig is the compiler
# doing the cross-compiling, so it must run here.
case "$(uname -m)" in
x86_64) ZIG_ARCH=x86_64; ZIG_SHA="$ZIG_SHA256_X86_64" ;;
aarch64) ZIG_ARCH=aarch64; ZIG_SHA="$ZIG_SHA256_AARCH64" ;;
*) echo "::error::no zig tarball mapping for host $(uname -m)"; exit 1 ;;
esac
if ! command -v xz >/dev/null 2>&1; then
echo "xz missing; installing xz-utils"
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends xz-utils
fi
TARBALL="zig-linux-${ZIG_ARCH}-${ZIG_VERSION}.tar.xz"
curl -fsSL --retry 3 --retry-all-errors \
"https://ziglang.org/download/${ZIG_VERSION}/${TARBALL}" -o "/tmp/${TARBALL}"
echo "${ZIG_SHA} /tmp/${TARBALL}" | sha256sum -c -
rm -rf "$HOME/.zig" && mkdir -p "$HOME/.zig"
tar -xJf "/tmp/${TARBALL}" -C "$HOME/.zig" --strip-components=1
echo "$HOME/.zig" >> "$GITHUB_PATH"
# 0.23+, not 0.19.8: rustc emits `-Wl,--fix-cortex-a53-843419` for
# aarch64-unknown-linux-gnu (rust-lang/rust#155453) and zig's linker
# rejects it --
# error: unsupported linker arg: --fix-cortex-a53-843419
# which failed `zc` and `zc-hooks` at the link step while x86_64 built
# fine. cargo-zigbuild filters that arg from 0.23.0 on
# (src/zig/linker_args.rs); 0.22 and earlier do not.
cargo install --locked cargo-zigbuild@0.23.4
# Fail here, with the versions named, rather than inside `cargo zigbuild`
# with a linker error. The install step above is the one that has broken
# twice now, and a missing `zig` on PATH is indistinguishable downstream
# from a genuine build failure.
- name: Verify zig and cargo-zigbuild are on PATH
run: |
set -euo pipefail
command -v zig || { echo "::error::zig is not on PATH after install"; exit 1; }
zig version
# `command -v`, not `cargo zigbuild --version`: that form forwards
# --version to the subcommand, which rejects it with
# `error: unexpected argument '--version' found` -- the check failing
# on its own syntax while the install it was checking had succeeded.
command -v cargo-zigbuild || { echo "::error::cargo-zigbuild is not installed"; exit 1; }
# --workspace also builds the zc-hooks sidecar. `zc hooks` execs it, so
# shipping it beside zc keeps that command working in release binaries
# exactly as it did when hooks was linked into zc via --features hooks.
- name: Build release binaries
run: cargo zigbuild --release --workspace --target ${{ matrix.target }}.${{ env.GLIBC_FLOOR }}
- name: Stage assets
run: |
set -euo pipefail
cp target/${{ matrix.target }}/release/zc ${{ matrix.asset }}
cp target/${{ matrix.target }}/release/zc-hooks ${{ matrix.asset }}-hooks
# Confirm the artifact is for the architecture it claims. A silent
# fallback to a host build would publish an x86_64 binary under the arm64
# name, which fails for the user at exec time with "cannot execute".
# Read the ELF header directly instead of shelling out to `file`, which
# the minimal ARC image does not ship (`file: command not found`, exit
# 127 -- it failed here after the binary had already built fine).
# e_machine is a 2-byte little-endian field at offset 0x12:
# 0x3E -> x86-64 ("3e00"), 0xB7 -> aarch64 ("b700").
- name: Verify architecture
run: |
set -euo pipefail
ASSET="${{ matrix.asset }}"
MACHINE=$(od -An -tx1 -j18 -N2 "$ASSET" | tr -d ' \n')
echo "$ASSET e_machine=0x$MACHINE"
case "${{ matrix.target }}" in
aarch64-*) EXPECT="b700" ;;
x86_64-*) EXPECT="3e00" ;;
*) echo "::error::no e_machine mapping for ${{ matrix.target }}"; exit 1 ;;
esac
if [ "$MACHINE" != "$EXPECT" ]; then
echo "::error::$ASSET is e_machine=0x$MACHINE, expected 0x$EXPECT for ${{ matrix.target }}"
exit 1
fi
# The architecture check above exists because a wrong-arch binary failed
# at exec time for the user. A too-new glibc fails the same way, for the
# same reason -- nothing downstream looks -- so it gets the same
# treatment rather than being left to the next person to discover on a
# host that cannot run the release.
#
# Versioned symbols appear in the dynamic string table as GLIBC_x.y;
# `strings` over the binary finds them without needing readelf, which the
# minimal ARC image does not ship (the same reason the check above reads
# the ELF header with od).
- name: Verify glibc floor
run: |
set -euo pipefail
for ASSET in "${{ matrix.asset }}" "${{ matrix.asset }}-hooks"; do
MAX=$(strings -a "$ASSET" | grep -oE '^GLIBC_2\.[0-9]+$' | sort -t. -k2 -n | tail -1 || true)
echo "$ASSET requires at most ${MAX:-none}"
if [ -z "$MAX" ]; then continue; fi
HAVE=${MAX#GLIBC_2.}
WANT=${GLIBC_FLOOR#2.}
if [ "$HAVE" -gt "$WANT" ]; then
echo "::error::$ASSET needs $MAX but the floor is GLIBC_$GLIBC_FLOOR;"
echo "::error::it would not start on a host older than that."
exit 1
fi
done
# Sign every asset for zak-get (zc#377, docs/release-signing.md). The key
# comes in through the environment only, is staged at mode 600 by the
# script, and is never echoed. Without the secret this warns and the
# release proceeds unsigned.
- name: Sign assets
shell: bash
env:
ZC_RELEASE_SIGNING_KEY: ${{ secrets.ZC_RELEASE_SIGNING_KEY }}
ZC_SIGN_KEY_FILE: ${{ runner.temp }}/zc-release-signing.key
run: |
# A backfill of a tag cut before signing existed has no script.
[ -f scripts/sign-release-asset.sh ] || { echo "::warning::tag predates release signing; assets are unsigned"; exit 0; }
scripts/sign-release-asset.sh "${{ matrix.asset }}" "${{ matrix.asset }}-hooks"
- name: Remove signing key
if: always()
shell: bash
run: shred -u "${{ runner.temp }}/zc-release-signing.key" 2>/dev/null || rm -f "${{ runner.temp }}/zc-release-signing.key"
- name: Attach to release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3
with:
tag_name: ${{ inputs.tag || github.ref_name }}
files: |
${{ matrix.asset }}
${{ matrix.asset }}-hooks
${{ matrix.asset }}.sig
${{ matrix.asset }}-hooks.sig
- name: Cleanup git SSH config (runner hygiene)
if: always()
run: |
git config --global --remove-section 'url.ssh://git@github.com/zakuro-ai/' 2>/dev/null || true
git config --global --unset-all 'core.sshCommand' 2>/dev/null || true
# macOS binary (`zc-darwin-arm64`). Hosted macos-14 when hosted jobs run,
# else the enrolled self-hosted Mac (picker output runner_macos). No var gate:
# a release must never silently ship without the darwin binary (v0.0.36 did).
build-macos:
needs:
if: ${{ always() && (needs.release.result == 'success' || needs.release.result == 'skipped') }}
runs-on: ${{ fromJSON(needs.runner.outputs.runner_macos) }}
timeout-minutes: 30
steps:
# ARC runners reuse $HOME between jobs, and a job that sets the
# `url.ssh://git@github.com/zakuro-ai/.insteadOf` rewrite for the private
# drive dep leaves it in the GLOBAL gitconfig. The next job's checkout
# then clones zc itself over ssh with a deploy key scoped to
# zakuro-drive, and fails with a misleading "ERROR: Repository not
# found." Strip any stale rewrite BEFORE checkout.
- name: Purge stale git URL rewrites (ARC runner hygiene)
shell: bash
run: |
git config --global --remove-section 'url.ssh://git@github.com/zakuro-ai/' 2>/dev/null || true
git config --global --remove-section 'url.ssh://git@github.com/zakuro-ai/zakuro-drive' 2>/dev/null || true
git config --global --unset-all core.sshCommand 2>/dev/null || true
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ inputs.tag || github.ref_name }}
- name: Git auth for private zakuro-drive dependency (read-only deploy key)
shell: bash
run: |
mkdir -p ~/.ssh && chmod 700 ~/.ssh
printf '%s\n' "${{ secrets.DRIVE_DEPLOY_KEY }}" > ~/.ssh/zakuro_drive_deploy
chmod 600 ~/.ssh/zakuro_drive_deploy
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
git config --global core.sshCommand "ssh -i ~/.ssh/zakuro_drive_deploy -o IdentitiesOnly=yes"
git config --global url."ssh://git@github.com/zakuro-ai/".insteadOf "https://github.com/zakuro-ai/"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
toolchain: "stable"
targets: aarch64-apple-darwin
- name: Build release binaries
run: cargo build --release --workspace --target aarch64-apple-darwin
- name: Stage assets
run: |
set -euo pipefail
cp target/aarch64-apple-darwin/release/zc zc-darwin-arm64
cp target/aarch64-apple-darwin/release/zc-hooks zc-darwin-arm64-hooks
# Sign every asset for zak-get (zc#377, docs/release-signing.md). The key
# comes in through the environment only, is staged at mode 600 by the
# script, and is never echoed. Without the secret this warns and the
# release proceeds unsigned.
- name: Sign assets
shell: bash
env:
ZC_RELEASE_SIGNING_KEY: ${{ secrets.ZC_RELEASE_SIGNING_KEY }}
ZC_SIGN_KEY_FILE: ${{ runner.temp }}/zc-release-signing.key
run: |
# A backfill of a tag cut before signing existed has no script.
[ -f scripts/sign-release-asset.sh ] || { echo "::warning::tag predates release signing; assets are unsigned"; exit 0; }
scripts/sign-release-asset.sh zc-darwin-arm64 zc-darwin-arm64-hooks
- name: Remove signing key
if: always()
shell: bash
run: shred -u "${{ runner.temp }}/zc-release-signing.key" 2>/dev/null || rm -f "${{ runner.temp }}/zc-release-signing.key"
- name: Attach to release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3
with:
tag_name: ${{ inputs.tag || github.ref_name }}
files: |
zc-darwin-arm64
zc-darwin-arm64-hooks
zc-darwin-arm64.sig
zc-darwin-arm64-hooks.sig
- name: Cleanup git SSH config (runner hygiene)
if: always()
run: |
git config --global --remove-section 'url.ssh://git@github.com/zakuro-ai/' 2>/dev/null || true
git config --global --unset-all 'core.sshCommand' 2>/dev/null || true
deploy-prod:
needs:
# Push-only on purpose: rebuilding assets for an existing tag must never
# trigger a production deploy.
if: github.event_name == 'push'
runs-on: ${{ needs.runner.outputs.runner }}
timeout-minutes: 10
steps:
- name: Deploy to production
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.DEPLOY_PAT }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/zakuro-ai/zakuro-infra/dispatches \
-d '{"event_type":"deploy-prod","client_payload":{"service":"zc","version":"${{ github.ref_name }}"}}'