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.
1 file+40−80/1 viewed
| 36 | 36 | ||
| 37 | 37 | jobs: | |
| 38 | 38 | 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 }} | |
| 40 | 42 | runs-on: ubuntu-latest | |
| 41 | 43 | timeout-minutes: 60 | |
| 44 | + | strategy: | |
| 45 | + | fail-fast: true | |
| 46 | + | matrix: | |
| 47 | + | target: [linux-x64, linux-arm64, windows-x64] | |
| 42 | 48 | steps: | |
| 43 | 49 | - uses: actions/checkout@v5 | |
| 44 | 50 | - name: The tag names this version | |
| ⋯ | |||
| 46 | 52 | run: | | |
| 47 | 53 | version="$(sed -n 's/^version = "\(.*\)"/\1/p' crates/runner/Cargo.toml | head -1)" | |
| 48 | 54 | [ "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 | |
| 49 | 66 | - name: Install zig and cargo-zigbuild | |
| 67 | + | if: steps.zig.outputs.cache-hit != 'true' | |
| 50 | 68 | run: | | |
| 51 | 69 | # The runner's Debian marks its Python as externally managed (PEP 668); zig goes under ~/.local anyway. | |
| 52 | 70 | pip install --user --break-system-packages ziglang==0.13.0 | |
| 53 | − | echo "$HOME/.local/bin" >> "$GITHUB_PATH" | |
| 54 | 71 | 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. | |
| 55 | 76 | - uses: actions/cache@v4 | |
| 56 | 77 | with: | |
| 57 | 78 | path: | | |
| 58 | 79 | ~/.cargo/registry | |
| 59 | 80 | 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 | |
| 61 | 88 | - name: Build Linux and Windows | |
| 62 | 89 | # The macOS targets need Apple's SDK to link (the Security and | |
| 63 | 90 | # CoreFoundation frameworks), which zig does not carry, so they are | |
| ⋯ | |||
| 67 | 94 | env: | |
| 68 | 95 | G1T_RUNNER_RELEASE_KEY: ${{ vars.RUNNER_RELEASE_PUBLIC_KEY }} | |
| 69 | 96 | 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 | |
| 71 | 101 | - uses: actions/upload-artifact@v4 | |
| 72 | 102 | with: | |
| 73 | − | name: binaries | |
| 103 | + | name: binaries-${{ matrix.target }} | |
| 74 | 104 | path: target/runner-release/ | |
| 105 | + | overwrite: true | |
| 75 | 106 | ||
| 76 | 107 | image: | |
| 77 | 108 | name: Container image | |
| ⋯ | |||
| 94 | 125 | - uses: actions/checkout@v5 | |
| 95 | 126 | - uses: actions/download-artifact@v4 | |
| 96 | 127 | with: | |
| 97 | − | name: binaries | |
| 128 | + | pattern: binaries-* | |
| 98 | 129 | path: release | |
| 99 | 130 | - name: QEMU for arm64, if this machine allows it | |
| 100 | 131 | id: qemu | |
| ⋯ | |||
| 138 | 169 | - uses: actions/checkout@v5 | |
| 139 | 170 | - uses: actions/download-artifact@v4 | |
| 140 | 171 | with: | |
| 141 | − | name: binaries | |
| 172 | + | pattern: binaries-* | |
| 142 | 173 | path: target/runner-release | |
| 143 | 174 | - name: QEMU for arm64, if this machine allows it | |
| 144 | 175 | id: qemu | |
| ⋯ | |||
| 168 | 199 | path: | | |
| 169 | 200 | target/runner-release/*/g1t-sandbox-* | |
| 170 | 201 | target/runner-release/*/sandbox.json | |
| 202 | + | overwrite: true | |
| 171 | 203 | ||
| 172 | 204 | publish: | |
| 173 | 205 | name: Sign and publish | |
| ⋯ | |||
| 184 | 216 | - uses: actions/checkout@v5 | |
| 185 | 217 | - uses: actions/download-artifact@v4 | |
| 186 | 218 | with: | |
| 187 | − | name: binaries | |
| 219 | + | pattern: binaries-* | |
| 188 | 220 | path: target/runner-release | |
| 189 | 221 | - uses: actions/download-artifact@v4 | |
| 190 | 222 | if: ${{ needs.sandbox.result == 'success' }} | |