Skip to content

Commit

A runner release builds its three binaries side by side. Linux x64, Linux arm64 and Windows each build in a job of their own, where one job built them one after another (about six minutes each); zig and cargo-zigbuild are kept between releases rather than installed every time (four minutes); each target's build restores from the last release's when Cargo.lock has changed, and sccache brings back unchanged crates. The jobs after the build take every target's binaries, and re-running a failed job replaces what an earlier attempt uploaded.

syntaqxcommitted Parentcef88c4Browse files
1 file+40−80/1 viewed
+40−8
3636
3737 jobs:
3838 binaries:
39− name: Build
39+ # One job per target, side by side: each cross-compile takes about six
40+ # minutes, and one after another they were most of a release's wait.
41+ name: Build ${{ matrix.target }}
4042 runs-on: ubuntu-latest
4143 timeout-minutes: 60
44+ strategy:
45+ fail-fast: true
46+ matrix:
47+ target: [linux-x64, linux-arm64, windows-x64]
4248 steps:
4349 - uses: actions/checkout@v5
4450 - name: The tag names this version
4652 run: |
4753 version="$(sed -n 's/^version = "\(.*\)"/\1/p' crates/runner/Cargo.toml | head -1)"
4854 [ "runner-v$version" = "${GITHUB_REF_NAME}" ] || { echo "::error::The tag is ${GITHUB_REF_NAME}, but crates/runner is $version"; exit 1; }
55+ # zig and cargo-zigbuild, kept between releases: installing them took
56+ # four minutes of every one. Change the key to take newer versions.
57+ - name: Cache zig and cargo-zigbuild
58+ id: zig
59+ uses: actions/cache@v4
60+ with:
61+ path: |
62+ ~/.local/lib/python3*/site-packages/ziglang
63+ ~/.local/bin
64+ ~/.cargo/bin/cargo-zigbuild
65+ key: zig-0.13.0-zigbuild-${{ runner.os }}-1
4966 - name: Install zig and cargo-zigbuild
67+ if: steps.zig.outputs.cache-hit != 'true'
5068 run: |
5169 # The runner's Debian marks its Python as externally managed (PEP 668); zig goes under ~/.local anyway.
5270 pip install --user --break-system-packages ziglang==0.13.0
53− echo "$HOME/.local/bin" >> "$GITHUB_PATH"
5471 cargo install --locked cargo-zigbuild
72+ - name: zig on the PATH
73+ run: echo "$HOME/.local/bin" >> "$GITHUB_PATH"
74+ # Each target's build, kept between releases; a release after a
75+ # Cargo.lock change starts from the last one's rather than from nothing.
5576 - uses: actions/cache@v4
5677 with:
5778 path: |
5879 ~/.cargo/registry
5980 target
60− key: runner-release-${{ hashFiles('Cargo.lock') }}
81+ key: runner-release-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
82+ restore-keys: runner-release-${{ matrix.target }}-
83+ # Crates whose inputs did not change come back from the Actions cache
84+ # instead of being compiled (scripts/sccache.sh); without it, the job
85+ # builds as before.
86+ - name: sccache
87+ run: bash scripts/sccache.sh install
6188 - name: Build Linux and Windows
6289 # The macOS targets need Apple's SDK to link (the Security and
6390 # CoreFoundation frameworks), which zig does not carry, so they are
6794 env:
6895 G1T_RUNNER_RELEASE_KEY: ${{ vars.RUNNER_RELEASE_PUBLIC_KEY }}
6996 RUNNER_AGENT_IMAGE: ${{ vars.RUNNER_AGENT_IMAGE }}
70− run: node scripts/runner-release.mjs build --targets linux-x64,linux-arm64,windows-x64
97+ run: node scripts/runner-release.mjs build --targets ${{ matrix.target }}
98+ - name: sccache's hits
99+ if: always()
100+ run: bash scripts/sccache.sh stats
71101 - uses: actions/upload-artifact@v4
72102 with:
73− name: binaries
103+ name: binaries-${{ matrix.target }}
74104 path: target/runner-release/
105+ overwrite: true
75106
76107 image:
77108 name: Container image
94125 - uses: actions/checkout@v5
95126 - uses: actions/download-artifact@v4
96127 with:
97− name: binaries
128+ pattern: binaries-*
98129 path: release
99130 - name: QEMU for arm64, if this machine allows it
100131 id: qemu
138169 - uses: actions/checkout@v5
139170 - uses: actions/download-artifact@v4
140171 with:
141− name: binaries
172+ pattern: binaries-*
142173 path: target/runner-release
143174 - name: QEMU for arm64, if this machine allows it
144175 id: qemu
168199 path: |
169200 target/runner-release/*/g1t-sandbox-*
170201 target/runner-release/*/sandbox.json
202+ overwrite: true
171203
172204 publish:
173205 name: Sign and publish
184216 - uses: actions/checkout@v5
185217 - uses: actions/download-artifact@v4
186218 with:
187− name: binaries
219+ pattern: binaries-*
188220 path: target/runner-release
189221 - uses: actions/download-artifact@v4
190222 if: ${{ needs.sandbox.result == 'success' }}