feat(release): a Linux arm64 binary, built through one cross toolchain
CI / installer (macos-14) (pull_request) Successful in 5s
CI / check (pull_request) Successful in 27s
CI / starter (bun) (pull_request) Successful in 33s
CI / starter (deno) (pull_request) Successful in 32s
CI / starter (edge) (pull_request) Successful in 39s
CI / core-freshness (pull_request) Has been skipped
CI / installer (ubuntu-latest) (pull_request) Failing after 6s
CI / starter (node) (pull_request) Successful in 32s
CI / installer (macos-14) (pull_request) Successful in 5s
CI / check (pull_request) Successful in 27s
CI / starter (bun) (pull_request) Successful in 33s
CI / starter (deno) (pull_request) Successful in 32s
CI / starter (edge) (pull_request) Successful in 39s
CI / core-freshness (pull_request) Has been skipped
CI / installer (ubuntu-latest) (pull_request) Failing after 6s
CI / starter (node) (pull_request) Successful in 32s
The installer refused Linux arm64 and sent you to `cargo install --git`, so Graviton, a Raspberry Pi, an ARM CI runner and Docker on Apple Silicon all needed a Rust toolchain to install a CLI whose whole point is not needing one. `rustup target add` could never have fixed it. `tree-sitter` and `tree-sitter-typescript` both compile C through the `cc` crate, so the target needs a real cross C compiler, and Ubuntu ships none for aarch64 musl. zig is one, for both arches — which is why the x86_64 leg moved onto it too rather than keeping `musl-tools` beside it. One toolchain for Linux beats a working one plus a second one that only the new target uses. Verified before touching the pipeline: all four targets cross-compile from macOS arm64 through zig, C included, producing binaries of the right architecture and format. Each release job now also runs the artifact it built, wherever the runner can execute it. agartha is a macOS host executor, so it runs both macOS binaries — the Intel one through Rosetta, confirmed by running the built binary on that host. Rosetta is probed rather than assumed, because a hosted runner may not have it and a smoke that hard-failed there would block a release over the runner's configuration rather than over the binary; the probe is an `if` rather than an AND-list so a missing Rosetta cannot end the step through `set -e`. Whether the aarch64 Linux binary gets started that way is not a property of the pipeline, though — it depends on what `ubuntu-latest` resolves to on the forge that fired. `verify-linux-arm64` removes the dependency by pinning an arm64 Linux runner and installing the published binary there through `install.sh`, so the answer is the same on every release, and the installer's arm64 branch and its checksum verification are covered against the real assets on the way. It carries the same `server_url` guard `publish-crate` already uses, since GitHub offers such runners and Gitea does not, and a job pinned to a label one forge lacks would queue there forever. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
5 files changed
+119
-10
No files matched your search
@@ -46,6 +46,8 @@ jobs:
|
||||
os: macos-14
|
||||
- target: x86_64-unknown-linux-musl
|
||||
os: ubuntu-latest
|
||||
- target: aarch64-unknown-linux-musl
|
||||
os: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -55,16 +57,69 @@ jobs:
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Add target + musl tooling
|
||||
run: |
|
||||
rustup target add ${{ matrix.target }}
|
||||
if [ "${{ matrix.target }}" = "x86_64-unknown-linux-musl" ]; then
|
||||
sudo apt-get update && sudo apt-get install -y musl-tools
|
||||
fi
|
||||
- name: Add target
|
||||
run: rustup target add ${{ matrix.target }}
|
||||
|
||||
- name: Build
|
||||
# Both Linux targets go through zig rather than through apt's musl-tools.
|
||||
# `tree-sitter` and `tree-sitter-typescript` compile C with the `cc` crate,
|
||||
# so `rustup target add` alone cannot produce an aarch64 binary — a real
|
||||
# cross C toolchain is required, and Ubuntu ships none for aarch64 musl.
|
||||
# zig is one, for both arches, which is also why the x86_64 leg moved onto
|
||||
# it: one toolchain for Linux beats a working one plus a second one.
|
||||
- name: Install zig cross toolchain
|
||||
if: contains(matrix.target, 'linux')
|
||||
run: |
|
||||
# `--break-system-packages` is required from pip 23 (PEP 668) and is an
|
||||
# unknown flag before it, so try the plain form first.
|
||||
python3 -m pip install --user ziglang \
|
||||
|| python3 -m pip install --user --break-system-packages ziglang
|
||||
cargo install --locked cargo-zigbuild
|
||||
|
||||
- name: Build (Linux, cross via zig)
|
||||
if: contains(matrix.target, 'linux')
|
||||
run: cargo zigbuild --release --locked --target ${{ matrix.target }}
|
||||
|
||||
- name: Build (macOS)
|
||||
if: contains(matrix.target, 'darwin')
|
||||
run: cargo build --release --locked --target ${{ matrix.target }}
|
||||
|
||||
# Run the artifact wherever the runner can actually execute it, and say so
|
||||
# where it cannot. A binary that links and will not start is the failure a
|
||||
# release pipeline must not leave for a user's terminal to find.
|
||||
#
|
||||
# A matching architecture always can. An x86_64 macOS binary on the arm64
|
||||
# macOS runners can too — through Rosetta, which is a system component
|
||||
# shared by every user on the host, so the runner account inherits it. It
|
||||
# is probed rather than assumed: a hosted runner may not have it, and a
|
||||
# smoke that hard-failed there would block a release over the runner's
|
||||
# configuration rather than over the binary.
|
||||
#
|
||||
# Across the two forges that leaves nothing unexecuted. Gitea's
|
||||
# `ubuntu-latest` is arm64 Linux (containers in a colima VM on the macOS
|
||||
# host), so it runs the aarch64 binary; GitHub's is x86_64 and runs the
|
||||
# other. Both macOS binaries run on either forge's arm64 macOS runner.
|
||||
- name: Smoke the binary
|
||||
shell: bash
|
||||
run: |
|
||||
target='${{ matrix.target }}'
|
||||
arch='${{ runner.arch }}'
|
||||
bin="./target/$target/release/matcha"
|
||||
runnable=no
|
||||
case "$target:$arch" in
|
||||
aarch64-*:ARM64|x86_64-*:X64) runnable=yes ;;
|
||||
x86_64-apple-darwin:ARM64)
|
||||
# An `if` rather than `[ … ] && …`: under `set -e` the AND-list's
|
||||
# failure is the case branch's exit status, and whether that ends
|
||||
# the step is a subtlety of the shell rather than a decision. A
|
||||
# missing Rosetta must skip the smoke, never fail the release.
|
||||
if [ -d /Library/Apple/usr/libexec/oah ]; then runnable=yes; fi ;;
|
||||
esac
|
||||
if [ "$runnable" = yes ]; then
|
||||
"$bin" --version
|
||||
else
|
||||
echo "::notice::smoke skipped: this $arch runner cannot execute $target"
|
||||
fi
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
TAR="matcha-${{ matrix.target }}.tar.gz"
|
||||
@@ -87,6 +142,36 @@ jobs:
|
||||
matcha-${{ matrix.target }}.tar.gz
|
||||
matcha-${{ matrix.target }}.tar.gz.sha256
|
||||
|
||||
# Guarantees the arm64 Linux binary is executed before it reaches anyone.
|
||||
#
|
||||
# The `Smoke the binary` step above runs each artifact only where the runner
|
||||
# can, which depends on what `ubuntu-latest` resolves to on the forge that
|
||||
# fired — so whether the aarch64 Linux binary gets started is a property of the
|
||||
# runner pool rather than of the pipeline. This job removes that dependency:
|
||||
# it pins an arm64 Linux runner, so the answer is the same on every release.
|
||||
#
|
||||
# GitHub offers such runners and Gitea does not, and a job pinned to a label a
|
||||
# forge lacks would queue there forever — hence the same `server_url` guard
|
||||
# `publish-crate` below already uses, which skips the job before a runner is
|
||||
# ever looked for.
|
||||
#
|
||||
# It goes through `install.sh` rather than running the binary directly, so the
|
||||
# same job also covers the installer's arm64 branch and its checksum
|
||||
# verification against the release assets exactly as a user receives them.
|
||||
verify-linux-arm64:
|
||||
needs: build
|
||||
if: ${{ github.server_url == 'https://github.com' }}
|
||||
runs-on: ubuntu-24.04-arm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install the published arm64 binary and run it
|
||||
run: |
|
||||
set -eu
|
||||
test "$(uname -m)" = aarch64 || { echo "expected an arm64 runner, got $(uname -m)"; exit 1; }
|
||||
MATCHA_VERSION="$GITHUB_REF_NAME" MATCHA_INSTALL_DIR="$PWD/.bin" sh ./install.sh
|
||||
"$PWD/.bin/matcha" --version
|
||||
"$PWD/.bin/matcha" --help > /dev/null
|
||||
|
||||
# crates.io = production only.
|
||||
# crates.io = production only, via OIDC Trusted Publishing (no CARGO_TOKEN).
|
||||
# Requires a trusted publisher configured on crates.io (Expressive-Tea/matcha, release.yml).
|
||||
|
||||
@@ -104,6 +104,25 @@ is pinned to is `CORE_VERSION` in `src/template.rs`, and each entry below says w
|
||||
was `TS2868: Cannot find name 'Bun'` — meaning `tsc --noEmit`, and therefore
|
||||
`matcha create --check`, failed on every bun project the CLI has ever scaffolded.
|
||||
|
||||
- **A prebuilt binary for Linux arm64.** The installer used to refuse that platform and
|
||||
send you to `cargo install --git` — so Graviton, a Raspberry Pi, an ARM CI runner and
|
||||
Docker on Apple Silicon all needed a Rust toolchain. `rustup target add` alone could
|
||||
never have produced it: `tree-sitter` and `tree-sitter-typescript` compile C through the
|
||||
`cc` crate, and Ubuntu ships no aarch64 musl cross compiler. Both Linux targets now build
|
||||
through zig, which is one, so the arch that was missing and the arch that worked share a
|
||||
toolchain instead of having two.
|
||||
|
||||
Each release job also runs the binary it just built, wherever the runner can execute it —
|
||||
a binary that links and will not start is the failure a release pipeline must not leave
|
||||
for a user's terminal to find. Both macOS binaries run on the arm64 macOS runner, the
|
||||
Intel one through Rosetta, which is probed rather than assumed since a runner without it
|
||||
would otherwise fail a release over its own configuration; and each Linux binary runs wherever
|
||||
`ubuntu-latest` resolves to its architecture. Because that last part depends on the
|
||||
runner pool rather than on the pipeline, a separate job pins an arm64 Linux runner and
|
||||
installs the published binary there through `install.sh` — so the arm64 artifact is
|
||||
started before it reaches anyone, on every release, and the installer's arm64 branch and
|
||||
checksum verification are exercised against the real assets on the way.
|
||||
|
||||
- **`install.sh` resolves `latest` without the release API.** The API is rate-limited to
|
||||
60 requests an hour per IP unauthenticated — an office behind one NAT or a CI runner
|
||||
burns through it — and a throttled response carries no `tag_name`, so the installer
|
||||
|
||||
@@ -17,7 +17,9 @@ binary. Needs a Rust toolchain; takes a few seconds.
|
||||
curl -fsSL https://raw.githubusercontent.com/Expressive-Tea/matcha/main/install.sh | sh
|
||||
```
|
||||
|
||||
Drops the binary in `~/.local/bin`. Env vars go on the `sh` side of the pipe:
|
||||
Drops the binary in `~/.local/bin`. Prebuilt for macOS (arm64, x86_64) and Linux
|
||||
(arm64, x86_64), statically linked against musl so any distro works, Alpine
|
||||
included. Env vars go on the `sh` side of the pipe:
|
||||
|
||||
```bash
|
||||
curl -fsSL …/install.sh | MATCHA_VERSION=v26.7.0 MATCHA_INSTALL_DIR=/usr/local/bin sh
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ case "$os" in
|
||||
Linux)
|
||||
case "$arch" in
|
||||
x86_64|amd64) triple="x86_64-unknown-linux-musl" ;;
|
||||
arm64|aarch64) err "linux arm64 has no prebuilt binary yet — use: cargo install --git $REPO_BASE" ;;
|
||||
arm64|aarch64) triple="aarch64-unknown-linux-musl" ;;
|
||||
*) err "unsupported Linux arch: $arch" ;;
|
||||
esac ;;
|
||||
*) err "unsupported OS: $os — try: cargo install --git $REPO_BASE" ;;
|
||||
|
||||
+4
-1
@@ -8,7 +8,10 @@ fail() { echo "FAIL: $*" >&2; exit 1; }
|
||||
os=$(uname -s); arch=$(uname -m)
|
||||
case "$os" in
|
||||
Darwin) case "$arch" in arm64|aarch64) triple=aarch64-apple-darwin;; x86_64) triple=x86_64-apple-darwin;; esac;;
|
||||
Linux) case "$arch" in x86_64|amd64) triple=x86_64-unknown-linux-musl;; esac;;
|
||||
Linux) case "$arch" in
|
||||
x86_64|amd64) triple=x86_64-unknown-linux-musl;;
|
||||
arm64|aarch64) triple=aarch64-unknown-linux-musl;;
|
||||
esac;;
|
||||
esac
|
||||
[ -n "${triple:-}" ] || { echo "SKIP: unsupported test host"; exit 0; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user