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: ubuntu-latest 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 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