CI / installer (macos-14) (pull_request) Successful in 3s
CI / check (pull_request) Successful in 38s
CI / starter (bun) (pull_request) Successful in 41s
CI / starter (deno) (pull_request) Failing after 36s
CI / starter (edge) (pull_request) Successful in 45s
CI / core-freshness (pull_request) Has been skipped
CI / installer (ubuntu-latest) (pull_request) Successful in 11s
CI / starter (node) (pull_request) Successful in 42s
GitHub retired the macos-14 image, so both darwin release builds for v26.11.0-rc.1 were cancelled before running a step and the GitHub release shipped without macOS binaries (uploaded afterwards from the Gitea build of the same tag). On Gitea, macos-14 is the self-hosted runner's label, so the label only changes on GitHub. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
226 lines
10 KiB
YAML
226 lines
10 KiB
YAML
name: Release
|
|
|
|
# On a version tag: build cross-platform binaries and attach them to the release (on
|
|
# whichever forge fired — the release API calls are portable). ADDITIONALLY, on GitHub
|
|
# only (production), publish the crate to crates.io.
|
|
on:
|
|
push:
|
|
tags: ['v*']
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
# Gitea's delete-asset API differs from GitHub's (it requires the release id in the
|
|
# path), so softprops' delete-then-reupload 404s when re-releasing an existing tag.
|
|
# Delete the whole release first so every run's uploads are fresh. Portable: the
|
|
# get-by-tag + delete-by-id endpoints exist on both Gitea and GitHub, and deleting
|
|
# first is harmless on GitHub (softprops just recreates it).
|
|
prepare:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Delete existing release for this tag
|
|
env:
|
|
GT_TOKEN: ${{ github.token }}
|
|
run: |
|
|
tag="$GITHUB_REF_NAME"
|
|
api="$GITHUB_API_URL/repos/$GITHUB_REPOSITORY"
|
|
id=$(curl -sSL -H "Authorization: token $GT_TOKEN" "$api/releases/tags/$tag" \
|
|
| grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true)
|
|
if [ -n "${id:-}" ]; then
|
|
echo "deleting existing release id=$id for $tag"
|
|
curl -sS -X DELETE -H "Authorization: token $GT_TOKEN" "$api/releases/$id" || true
|
|
else
|
|
echo "no existing release for $tag — nothing to delete"
|
|
fi
|
|
|
|
build:
|
|
needs: prepare
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: aarch64-apple-darwin
|
|
os: macos-14
|
|
- target: x86_64-apple-darwin
|
|
os: macos-14
|
|
- target: x86_64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
- target: aarch64-unknown-linux-musl
|
|
os: ubuntu-latest
|
|
# GitHub retired the macos-14 image (jobs are cancelled with "configuration not supported");
|
|
# on Gitea, macos-14 is the label of the self-hosted macOS runner, so only GitHub moves.
|
|
runs-on: ${{ matrix.os == 'macos-14' && github.server_url == 'https://github.com' && 'macos-15' || matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Install Rust
|
|
run: |
|
|
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
|
|
run: rustup target add ${{ matrix.target }}
|
|
|
|
# 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"
|
|
tar -czf "$TAR" -C "target/${{ matrix.target }}/release" matcha
|
|
if command -v sha256sum >/dev/null 2>&1; then
|
|
sha256sum "$TAR" > "$TAR.sha256"
|
|
else
|
|
shasum -a 256 "$TAR" > "$TAR.sha256"
|
|
fi
|
|
|
|
- name: Upload to release
|
|
uses: softprops/action-gh-release@v3
|
|
with:
|
|
# A tag with a hyphen is a prerelease (26.9.0-beta.1). Unflagged, it
|
|
# would answer /releases/latest — which is what install.sh resolves
|
|
# with no MATCHA_VERSION — so the first stable release would be
|
|
# displaced by the next beta published after it.
|
|
prerelease: ${{ contains(github.ref_name, '-') }}
|
|
files: |
|
|
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@v5
|
|
- 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
|
|
|
|
# Gitea only: hand the tag to GitHub, but only once this forge has built all
|
|
# four targets and run every artifact it can.
|
|
#
|
|
# This is the gate. Pushing the tag is what starts GitHub's release and, with
|
|
# it, the crates.io publish — and crates.io has no unpublish, only yank. So the
|
|
# local build is not a parallel opinion, it is the thing that has to pass
|
|
# first. `needs: build` is what makes the two sequential; when both workflows
|
|
# fired on the same tag push they were not.
|
|
promote-tag:
|
|
needs: build
|
|
if: ${{ github.server_url != 'https://github.com' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Push the tag to GitHub
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GH_PROMOTE_TOKEN }}
|
|
run: |
|
|
git remote add github "https://x-access-token:${GH_TOKEN}@github.com/Expressive-Tea/matcha.git"
|
|
# `${{ github.ref_name }}` rather than $GITHUB_REF_NAME: the expression
|
|
# is what promote.yml used to hand v26.8.0-beta.0 to GitHub, so it is
|
|
# proven on this act_runner. Whether the env var is exported here is
|
|
# not, and getting it wrong would push an empty ref and leave the tag
|
|
# on this forge alone.
|
|
git push github "refs/tags/${{ github.ref_name }}"
|
|
|
|
# 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).
|
|
publish-crate:
|
|
if: ${{ github.server_url == 'https://github.com' }}
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
id-token: write
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- name: Install Rust
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
# Exchanges the OIDC id-token for a short-lived crates.io token.
|
|
- uses: rust-lang/crates-io-auth-action@v1
|
|
id: auth
|
|
- name: cargo publish
|
|
env:
|
|
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
|
|
run: cargo publish --locked
|