ci: Gitea Actions workflows for CI and tagged releases; strip option (M7)
CI / test (push) Canceled after 0s
CI / test (push) Canceled after 0s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5faf8a682
commit
b022dcf32b
5 files changed
+130
No files matched your search
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# Install the Zig toolchain used by CI into ${ZIG_DIR:-$HOME/.cache/zag-ci/zig} and print its bin dir.
|
||||
# Skips the download when the right version is already there.
|
||||
set -eu
|
||||
|
||||
VERSION=0.16.0
|
||||
DIR=${ZIG_DIR:-$HOME/.cache/zag-ci/zig-$VERSION}
|
||||
|
||||
case "$(uname -s)-$(uname -m)" in
|
||||
Linux-x86_64) target=x86_64-linux; sha=70e49664a74374b48b51e6f3fdfbf437f6395d42509050588bd49abe52ba3d00 ;;
|
||||
Linux-aarch64 | Linux-arm64) target=aarch64-linux; sha=ea4b09bfb22ec6f6c6ceac57ab63efb6b46e17ab08d21f69f3a48b38e1534f17 ;;
|
||||
Darwin-arm64) target=aarch64-macos; sha=b23d70deaa879b5c2d486ed3316f7eaa53e84acf6fc9cc747de152450d401489 ;;
|
||||
Darwin-x86_64) target=x86_64-macos; sha=0387557ed1877bc6a2e1802c8391953baddba76081876301c522f52977b52ba7 ;;
|
||||
*) echo "unsupported runner: $(uname -s)-$(uname -m)" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ ! -x "$DIR/zig" ] || [ "$("$DIR/zig" version 2>/dev/null)" != "$VERSION" ]; then
|
||||
tmp=$(mktemp -d)
|
||||
archive="zig-$target-$VERSION.tar.xz"
|
||||
curl -fsSL -o "$tmp/$archive" "https://ziglang.org/download/$VERSION/$archive"
|
||||
echo "$sha $tmp/$archive" | (sha256sum -c - 2>/dev/null || shasum -a 256 -c -) >&2
|
||||
mkdir -p "$DIR"
|
||||
tar -xJf "$tmp/$archive" -C "$DIR" --strip-components=1
|
||||
rm -rf "$tmp"
|
||||
fi
|
||||
echo "$DIR"
|
||||
@@ -0,0 +1,33 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [develop, main]
|
||||
pull_request:
|
||||
branches: [develop, main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: org-runner
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Zig
|
||||
run: echo "$(.github/ci/install-zig.sh)" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Format check
|
||||
run: zig fmt --check src build.zig test
|
||||
|
||||
- name: Unit tests
|
||||
run: zig build test --summary all
|
||||
|
||||
- name: End-to-end smoke test
|
||||
run: zig build e2e
|
||||
|
||||
- name: Cross-compile every release target
|
||||
run: |
|
||||
for target in x86_64-linux-musl aarch64-linux-musl aarch64-macos x86_64-macos; do
|
||||
echo "== $target"
|
||||
zig build -Dtarget="$target" -Doptimize=ReleaseSafe -Dstrip=true --prefix "zig-out/$target"
|
||||
done
|
||||
@@ -0,0 +1,58 @@
|
||||
name: Release
|
||||
|
||||
# Push a tag like v0.1.0 (it must match `.version` in build.zig.zon) to build the binaries for
|
||||
# every platform and publish a release.
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: org-runner
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Zig
|
||||
run: echo "$(.github/ci/install-zig.sh)" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Check the tag matches build.zig.zon
|
||||
run: |
|
||||
version=$(sed -n 's/^[[:space:]]*\.version = "\(.*\)",$/\1/p' build.zig.zon)
|
||||
[ "v$version" = "${GITHUB_REF_NAME}" ] || { echo "tag ${GITHUB_REF_NAME} != v$version"; exit 1; }
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
zig build test --summary all
|
||||
zig build e2e
|
||||
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
mkdir -p dist
|
||||
build() { # build <zig target> <asset suffix>
|
||||
zig build -Dtarget="$1" -Doptimize=ReleaseSafe -Dstrip=true --prefix "zig-out/$1"
|
||||
cp "zig-out/$1/bin/zag" "dist/zag-$2"
|
||||
}
|
||||
build x86_64-linux-musl linux-x64
|
||||
build aarch64-linux-musl linux-arm64
|
||||
build aarch64-macos macos-arm64
|
||||
build x86_64-macos macos-x64
|
||||
(cd dist && sha256sum zag-* > SHA256SUMS)
|
||||
cp install.sh dist/install.sh
|
||||
|
||||
- name: Publish the release
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||
notes=$(awk -v v="${GITHUB_REF_NAME#v}" '$0 ~ "^## \\[?"v {f=1; next} /^## / {f=0} f' CHANGELOG.md)
|
||||
body=$(printf '%s' "$notes" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))' 2>/dev/null || echo '""')
|
||||
id=$(curl -fsS -X POST "$api/releases" \
|
||||
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"${GITHUB_REF_NAME}\",\"name\":\"${GITHUB_REF_NAME}\",\"body\":${body}}" \
|
||||
| sed -n 's/.*"id":\([0-9]*\).*/\1/p' | head -1)
|
||||
[ -n "$id" ] || { echo "could not create the release"; exit 1; }
|
||||
for f in dist/*; do
|
||||
echo "uploading $f"
|
||||
curl -fsS -X POST "$api/releases/$id/assets?name=$(basename "$f")" \
|
||||
-H "Authorization: token $TOKEN" -F "attachment=@$f" >/dev/null
|
||||
done
|
||||
@@ -0,0 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Job daemon, scheduler (per-load-level concurrency), retries with backoff, per-job timeouts, crash recovery.
|
||||
- CLI compatible with barn: `run`, `status`, `describe`, `usage`, `kill`, `clean`, `service`, `config`, `autocompletion`.
|
||||
- Human, JSON and XML output; `--offline` mode.
|
||||
- systemd / launchd service installation and an `install.sh` installer.
|
||||
@@ -9,6 +9,8 @@ pub fn build(b: *std.Build) void {
|
||||
});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const strip = b.option(bool, "strip", "Strip debug symbols from the binary") orelse false;
|
||||
|
||||
const options = b.addOptions();
|
||||
options.addOption([]const u8, "version", zon.version);
|
||||
|
||||
@@ -28,6 +30,7 @@ pub fn build(b: *std.Build) void {
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
.strip = strip,
|
||||
.imports = &.{.{ .name = "zag", .module = mod }},
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user