chadtmiller.com/knotless
git that lives in your Atmosphere account
1
10
Releases build each target in a step of its own
.knotless/workflows/release.yml+18−4
| @@ -53,11 +53,25 @@ steps: | ||
fi | ||
ln -sf /opt/tools/zig/zig /usr/local/bin/zig | ||
ln -sf /opt/tools/bin/cargo-zigbuild /usr/local/cargo/bin/cargo-zigbuild | ||
- name: build | ||
timeout: 60 | ||
# A target a step: from cold caches each takes some 13 minutes, and the | ||
# four in one step outran the runner's 30-minute step timeout. | ||
- name: build aarch64-apple-darwin | ||
run: | | ||
[ ! -e ~/.done ] || exit 0 | ||
TOOLCHAIN= deploy/build-client.sh target/client | ||
rm -rf target/client | ||
TOOLCHAIN= deploy/build-client.sh target/client aarch64-apple-darwin | ||
- name: build x86_64-apple-darwin | ||
run: | | ||
[ ! -e ~/.done ] || exit 0 | ||
TOOLCHAIN= deploy/build-client.sh target/client x86_64-apple-darwin | ||
- name: build x86_64-unknown-linux-musl | ||
run: | | ||
[ ! -e ~/.done ] || exit 0 | ||
TOOLCHAIN= deploy/build-client.sh target/client x86_64-unknown-linux-musl | ||
- name: build aarch64-unknown-linux-musl | ||
run: | | ||
[ ! -e ~/.done ] || exit 0 | ||
TOOLCHAIN= deploy/build-client.sh target/client aarch64-unknown-linux-musl | ||
ls -l target/client | ||
- name: publish | ||
on: {refs: [refs/heads/main]} | ||
| @@ -66,7 +80,7 @@ steps: | ||
version=$(cat ~/.version) | ||
# The version's section of the changelog, less its heading. | ||
awk -v v="$version" '/^## / { on = ($2 == v); next } on' CHANGELOG.md > ~/.notes | ||
KNOTLESS_PASSWORD="$RELEASE_PASSWORD" knotless release publish "$REPO" knotless "$version" target/client/*.tar.gz --notes - < ~/.notes | ||
KNOTLESS_PASSWORD="$RELEASE_PASSWORD" knotless release publish "$REPO" knotless "$version" target/client/knotless-"$version"-*.tar.gz --notes - < ~/.notes | ||
# Tagged once published, at the commit it was built from, as the | ||
# owner, so a git checkout finds the version by name. | ||
owner=${REPO#knotless://} | ||
deploy/build-client.sh+18−5
| @@ -4,11 +4,14 @@ | ||
# `knotless-triage` (its labeller) and `knotless-agent` (its reviewer, with | ||
# the `knotless-claude-review` script it runs), for every target the install script fetches, as one archive per target: | ||
# | ||
# deploy/build-client.sh <out dir> | ||
# deploy/build-client.sh <out dir> [<target>...] | ||
# | ||
# leaves <out dir>/knotless-<version>-<target>.tar.gz, each holding a | ||
# directory of that name with the binaries, README and licences. The | ||
# version is the workspace's, in Cargo.toml. | ||
# version is the workspace's, in Cargo.toml. With no target named, it | ||
# empties <out dir> and builds them all; with some, it builds only those, | ||
# replacing their archives and leaving the rest, so a workflow can build | ||
# each in a step of its own, each within the runner's step timeout. | ||
# | ||
# On a Mac, both macOS targets build natively; every other target builds | ||
# with cargo-zigbuild (`brew install zig`, `cargo install cargo-zigbuild`), | ||
| @@ -19,17 +22,26 @@ | ||
set -euo pipefail | ||
cd "$(dirname "$0")/.." | ||
| ||
OUT="${1:?usage: deploy/build-client.sh <out dir>}" | ||
OUT="${1:?usage: deploy/build-client.sh <out dir> [<target>...]}" | ||
shift | ||
TOOLCHAIN="${TOOLCHAIN-stable}" | ||
CARGO="${CARGO:-${TOOLCHAIN:+rustup run $TOOLCHAIN }cargo}" | ||
VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)" | ||
TARGETS=(aarch64-apple-darwin x86_64-apple-darwin x86_64-unknown-linux-musl aarch64-unknown-linux-musl) | ||
ALL=(aarch64-apple-darwin x86_64-apple-darwin x86_64-unknown-linux-musl aarch64-unknown-linux-musl) | ||
if [ $# -gt 0 ]; then | ||
TARGETS=("$@") | ||
for target in "${TARGETS[@]}"; do | ||
[[ " ${ALL[*]} " == *" $target "* ]] || { echo "not a target the install script fetches: $target" >&2; exit 2; } | ||
done | ||
else | ||
TARGETS=("${ALL[@]}") | ||
rm -rf "$OUT" | ||
fi | ||
| ||
$CARGO zigbuild --help >/dev/null 2>&1 \ | ||
|| { echo "needs cargo-zigbuild: cargo install cargo-zigbuild, and zig" >&2; exit 1; } | ||
rustup target add ${TOOLCHAIN:+--toolchain "$TOOLCHAIN"} "${TARGETS[@]}" >/dev/null | ||
| ||
rm -rf "$OUT" | ||
mkdir -p "$OUT" | ||
for target in "${TARGETS[@]}"; do | ||
echo "→ building $VERSION for $target" | ||
| @@ -39,6 +51,7 @@ for target in "${TARGETS[@]}"; do | ||
esac | ||
$CARGO $build --release --locked --target "$target" -p knotless -p knotless-mcp -p knotless-run -p knotless-triage -p knotless-agent | ||
name="knotless-$VERSION-$target" | ||
rm -rf "$OUT/$name" "$OUT/$name.tar.gz" | ||
mkdir "$OUT/$name" | ||
for bin in knotless git-remote-knotless knotless-mcp knotless-run knotless-triage knotless-agent; do | ||
cp "target/$target/release/$bin" "$OUT/$name/" | ||