Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

124 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 # npm's downloads, kept between runs: an install reads them first
71 # and asks the registry only for what changed, so a dropped
72 # connection to it rarely stops the job.
73 - name: Cache npm's downloads
74 uses: actions/cache@v4
75 with:
76 path: ~/.npm
77 key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
78 restore-keys: npm-${{ runner.os }}-
79 - name: Install Wrangler
80 run: npm ci --prefer-offline --workspaces=false --no-audit --no-fund
81 - name: Publish to g1t.sh/downloads/runner
82 env:
83 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
84 run: node scripts/runner-release.mjs publish
85 - uses: actions/upload-artifact@v4
86 with:
87 name: linux-binaries
88 path: |
89 target/runner-release/*/g1t-runner-linux-x64
90 target/runner-release/*/g1t-runner-linux-arm64
91
92 image:
93 name: Container image
94 needs: binaries
95 # Builds for arm64 as well as amd64, which needs QEMU's emulators
96 # registered on the machine: a self-hosted runner's, for now.
97 runs-on: [self-hosted, docker]
98 environment: production
99 timeout-minutes: 30
100 # Its token pushes the image to g1t's registry.
101 permissions:
102 contents: read
103 packages: write
104 steps:
105 - uses: actions/checkout@v5
106 - uses: actions/download-artifact@v4
107 with:
108 name: linux-binaries
109 path: release
110 - name: Build and push for amd64 and arm64
111 # To g1t's own registry, where flagon-io keeps it public.
112 env:
113 IMAGE: g1t.sh/flagon-io/g1t-runner
114 run: |
115 version="$(sed -n 's/^version = "\(.*\)"/\1/p' crates/runner/Cargo.toml | head -1)"
116 echo "${{ secrets.G1T_TOKEN }}" | docker login g1t.sh -u g1t --password-stdin
117 for arch in amd64 arm64; do
118 mkdir -p "context-$arch"
119 cp deploy/runner/Dockerfile "context-$arch/"
120 name="g1t-runner-linux-$([ "$arch" = amd64 ] && echo x64 || echo arm64)"
121 cp release/*/"$name" "context-$arch/g1t-runner"
122 docker buildx build --platform "linux/$arch" -t "$IMAGE:$version-$arch" --push "context-$arch"
123 done
124 docker buildx imagetools create -t "$IMAGE:$version" -t "$IMAGE:latest" "$IMAGE:$version-amd64" "$IMAGE:$version-arm64"