Skip to content
115 linesCodeBlameRaw
1# Releases the self-hosted runner, g1t-runner (crates/runner): builds it for
2# Linux, macOS and Windows on x64 and arm64, signs the release, publishes it
3# to g1t.sh/downloads/runner/ (the g1t-downloads R2 bucket), and pushes its
4# container image. Runners already out there update themselves to it.
5#
6# A release is a tag `runner-v<version>`, where the version is the one in
7# crates/runner/Cargo.toml; or run it by hand. scripts/runner-release.mjs
8# does the work, and its header says how to make the release key the first
9# time; CONTRIBUTING.md ("Deploying") says how a release is made.
10name: Runner release
11
12on:
13 push:
14 tags: ["runner-v*"]
15 workflow_dispatch:
16
17permissions:
18 contents: read
19
20concurrency:
21 group: runner-release
22 cancel-in-progress: false
23
24env:
25 CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
26 WRANGLER_SEND_METRICS: "false"
27
28jobs:
29 binaries:
30 name: Build, sign and publish
31 runs-on: ubuntu-latest
32 environment: production
33 timeout-minutes: 60
34 steps:
35 - uses: actions/checkout@v5
36 - name: The tag names this version
37 if: startsWith(github.ref, 'refs/tags/runner-v')
38 run: |
39 version="$(sed -n 's/^version = "\(.*\)"/\1/p' crates/runner/Cargo.toml | head -1)"
40 [ "runner-v$version" = "${GITHUB_REF_NAME}" ] || { echo "::error::The tag is ${GITHUB_REF_NAME}, but crates/runner is $version"; exit 1; }
41 - name: Install zig and cargo-zigbuild
42 run: |
43 # The runner's Debian marks its Python as externally managed (PEP 668); zig goes under ~/.local anyway.
44 pip install --user --break-system-packages ziglang==0.13.0
45 echo "$HOME/.local/bin" >> "$GITHUB_PATH"
46 cargo install --locked cargo-zigbuild
47 - uses: actions/cache@v4
48 with:
49 path: |
50 ~/.cargo/registry
51 target
52 key: runner-release-${{ hashFiles('Cargo.lock') }}
53 - name: Build Linux and Windows
54 # The macOS targets need Apple's SDK to link (the Security and
55 # CoreFoundation frameworks), which zig does not carry, so they are
56 # left out until this builds in the rust-cross/cargo-zigbuild image
57 # as the CLI's release does (scripts/cli-release.mjs). A Mac runner
58 # keeps the version it has, since the manifest names no file for it.
59 env:
60 G1T_RUNNER_RELEASE_KEY: ${{ vars.RUNNER_RELEASE_PUBLIC_KEY }}
61 RUNNER_AGENT_IMAGE: ${{ vars.RUNNER_AGENT_IMAGE }}
62 run: node scripts/runner-release.mjs build --targets linux-x64,linux-arm64,windows-x64
63 - name: Sign
64 env:
65 RUNNER_RELEASE_KEY: ${{ secrets.RUNNER_RELEASE_KEY }}
66 G1T_RUNNER_RELEASE_KEY: ${{ vars.RUNNER_RELEASE_PUBLIC_KEY }}
67 run: |
68 node scripts/runner-release.mjs sign
69 node scripts/runner-release.mjs verify
70 - name: Install Wrangler
71 run: npm ci --workspaces=false --no-audit --no-fund
72 - name: Publish to g1t.sh/downloads/runner
73 env:
74 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
75 run: node scripts/runner-release.mjs publish
76 - uses: actions/upload-artifact@v4
77 with:
78 name: linux-binaries
79 path: |
80 target/runner-release/*/g1t-runner-linux-x64
81 target/runner-release/*/g1t-runner-linux-arm64
82
83 image:
84 name: Container image
85 needs: binaries
86 # Builds for arm64 as well as amd64, which needs QEMU's emulators
87 # registered on the machine: a self-hosted runner's, for now.
88 runs-on: [self-hosted, docker]
89 environment: production
90 timeout-minutes: 30
91 # Its token pushes the image to g1t's registry.
92 permissions:
93 contents: read
94 packages: write
95 steps:
96 - uses: actions/checkout@v5
97 - uses: actions/download-artifact@v4
98 with:
99 name: linux-binaries
100 path: release
101 - name: Build and push for amd64 and arm64
102 # To g1t's own registry, where flagon-io keeps it public.
103 env:
104 IMAGE: g1t.sh/flagon-io/g1t-runner
105 run: |
106 version="$(sed -n 's/^version = "\(.*\)"/\1/p' crates/runner/Cargo.toml | head -1)"
107 echo "${{ secrets.G1T_TOKEN }}" | docker login g1t.sh -u g1t --password-stdin
108 for arch in amd64 arm64; do
109 mkdir -p "context-$arch"
110 cp deploy/runner/Dockerfile "context-$arch/"
111 name="g1t-runner-linux-$([ "$arch" = amd64 ] && echo x64 || echo arm64)"
112 cp release/*/"$name" "context-$arch/g1t-runner"
113 docker buildx build --platform "linux/$arch" -t "$IMAGE:$version-$arch" --push "context-$arch"
114 done
115 docker buildx imagetools create -t "$IMAGE:$version" -t "$IMAGE:latest" "$IMAGE:$version-amd64" "$IMAGE:$version-arm64"