ci: update the Homebrew tap on release; docs for brew and branches
CI / test (push) Successful in 3m19s
CI / test (push) Successful in 3m19s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
47b12895fd
commit
24c7a2804d
4 files changed
+97
-1
No files matched your search
Executable
+65
@@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Print the Homebrew formula for a release.
|
||||||
|
# render-formula.sh <version without v> <path to SHA256SUMS>
|
||||||
|
set -eu
|
||||||
|
version=$1
|
||||||
|
sums=$2
|
||||||
|
sha() { awk -v n="zag-$1" '$2 == n { print $1 }' "$sums"; }
|
||||||
|
base="https://gitea.samson.media/samson-media/zag/releases/download/v$version"
|
||||||
|
|
||||||
|
cat <<RUBY
|
||||||
|
# Generated by zag's release workflow (.github/ci/render-formula.sh); do not edit by hand.
|
||||||
|
#
|
||||||
|
# The zag repository is private, so downloads send a Gitea access token. Set it before installing:
|
||||||
|
# export HOMEBREW_GITEA_TOKEN=<token with read access to samson-media/zag>
|
||||||
|
class GiteaPrivateReleaseStrategy < CurlDownloadStrategy
|
||||||
|
def _fetch(url:, resolved_url:, timeout:)
|
||||||
|
token = ENV["HOMEBREW_GITEA_TOKEN"]
|
||||||
|
odie "Set HOMEBREW_GITEA_TOKEN to a Gitea access token that can read samson-media/zag" if token.to_s.empty?
|
||||||
|
curl_download resolved_url, "--header", "Authorization: token #{token}", to: temporary_path, timeout: timeout
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Zag < Formula
|
||||||
|
desc "Cross-platform job daemon for long-running FFmpeg and WebDAV media jobs"
|
||||||
|
homepage "https://gitea.samson.media/samson-media/zag"
|
||||||
|
version "$version"
|
||||||
|
|
||||||
|
on_macos do
|
||||||
|
on_arm do
|
||||||
|
url "$base/zag-macos-arm64", using: GiteaPrivateReleaseStrategy
|
||||||
|
sha256 "$(sha macos-arm64)"
|
||||||
|
end
|
||||||
|
on_intel do
|
||||||
|
url "$base/zag-macos-x64", using: GiteaPrivateReleaseStrategy
|
||||||
|
sha256 "$(sha macos-x64)"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
on_linux do
|
||||||
|
on_arm do
|
||||||
|
url "$base/zag-linux-arm64", using: GiteaPrivateReleaseStrategy
|
||||||
|
sha256 "$(sha linux-arm64)"
|
||||||
|
end
|
||||||
|
on_intel do
|
||||||
|
url "$base/zag-linux-x64", using: GiteaPrivateReleaseStrategy
|
||||||
|
sha256 "$(sha linux-x64)"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def install
|
||||||
|
bin.install Dir["zag-*"].first => "zag"
|
||||||
|
end
|
||||||
|
|
||||||
|
service do
|
||||||
|
run [opt_bin/"zag", "service", "start", "--foreground"]
|
||||||
|
keep_alive crashed: true
|
||||||
|
log_path var/"log/zag.log"
|
||||||
|
error_log_path var/"log/zag.log"
|
||||||
|
end
|
||||||
|
|
||||||
|
test do
|
||||||
|
assert_match version.to_s, shell_output("#{bin}/zag --version")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
@@ -79,3 +79,22 @@ jobs:
|
|||||||
-H "Authorization: token $TOKEN" -F "attachment=@$f")
|
-H "Authorization: token $TOKEN" -F "attachment=@$f")
|
||||||
[ "$code" = "201" ] || { echo "upload of $f failed: HTTP $code"; cat "$resp"; echo; exit 1; }
|
[ "$code" = "201" ] || { echo "upload of $f failed: HTTP $code"; cat "$resp"; echo; exit 1; }
|
||||||
done
|
done
|
||||||
|
|
||||||
|
- name: Update the Homebrew tap
|
||||||
|
# Needs a TAP_TOKEN secret: a personal access token with write access to
|
||||||
|
# samson-media/homebrew-tap. Skipped when the secret is not set.
|
||||||
|
env:
|
||||||
|
TAP_TOKEN: ${{ secrets.TAP_TOKEN }}
|
||||||
|
run: |
|
||||||
|
if [ -z "$TAP_TOKEN" ]; then echo "TAP_TOKEN not set; skipping the tap update"; exit 0; fi
|
||||||
|
tap=$(mktemp -d)
|
||||||
|
git clone "https://x-access-token:${TAP_TOKEN}@${GITHUB_SERVER_URL#https://}/samson-media/homebrew-tap.git" "$tap"
|
||||||
|
mkdir -p "$tap/Formula"
|
||||||
|
sh .github/ci/render-formula.sh "${TAG#v}" dist/SHA256SUMS > "$tap/Formula/zag.rb"
|
||||||
|
cd "$tap"
|
||||||
|
git config user.name "zag release workflow"
|
||||||
|
git config user.email "actions@gitea.samson.media"
|
||||||
|
git add Formula/zag.rb
|
||||||
|
if git diff --cached --quiet; then echo "formula unchanged"; exit 0; fi
|
||||||
|
git commit -m "Update zag to ${TAG#v}"
|
||||||
|
git push origin HEAD:main
|
||||||
@@ -60,6 +60,8 @@ Guidance for AI coding agents working in `zag`, the Zig port of the
|
|||||||
|
|
||||||
## Build notes
|
## Build notes
|
||||||
|
|
||||||
|
- Branches: `main` is the default (same as the other submodules; the mono repo's `make update` pulls `origin main`); `develop` is the working branch. Merge `develop` into `main` to publish docs and `install.sh`.
|
||||||
|
|
||||||
- `build.zig` links libc (for `localtime_r`) and defaults Linux builds to `x86_64-linux-musl` so the
|
- `build.zig` links libc (for `localtime_r`) and defaults Linux builds to `x86_64-linux-musl` so the
|
||||||
binary is static and does not depend on the host's crt files (the host linker fails on newer gcc
|
binary is static and does not depend on the host's crt files (the host linker fails on newer gcc
|
||||||
`.sframe` sections).
|
`.sframe` sections).
|
||||||
@@ -67,6 +69,7 @@ Guidance for AI coding agents working in `zag`, the Zig port of the
|
|||||||
- `zig build e2e` runs `test/e2e.sh` against the built binary; CI runs `zig fmt --check`, unit tests,
|
- `zig build e2e` runs `test/e2e.sh` against the built binary; CI runs `zig fmt --check`, unit tests,
|
||||||
the e2e test and a cross-compile of all four release targets (`.github/workflows/ci.yml`).
|
the e2e test and a cross-compile of all four release targets (`.github/workflows/ci.yml`).
|
||||||
- Releases: tag `vX.Y.Z` (must equal `.version` in `build.zig.zon`); `.github/workflows/release.yml`
|
- Releases: tag `vX.Y.Z` (must equal `.version` in `build.zig.zon`); `.github/workflows/release.yml`
|
||||||
builds the static binaries and publishes them to Gitea.
|
builds the static binaries and publishes them to Gitea, then updates the Homebrew formula in
|
||||||
|
`samson-media/homebrew-tap` when the `TAP_TOKEN` secret is set (`.github/ci/render-formula.sh`).
|
||||||
- Gotchas: never return a struct holding a pointer into itself (e.g. an `Allocating` writer plus a
|
- Gotchas: never return a struct holding a pointer into itself (e.g. an `Allocating` writer plus a
|
||||||
`jsonpretty.Writer` over it) -- initialise it in place (`Payload.init` in `cli_jobs.zig`).
|
`jsonpretty.Writer` over it) -- initialise it in place (`Payload.init` in `cli_jobs.zig`).
|
||||||
@@ -68,6 +68,15 @@ curl -fsSL -H "Authorization: token $ZAG_TOKEN" \
|
|||||||
|
|
||||||
`ZAG_VERSION`, `ZAG_PREFIX` and `ZAG_NO_SERVICE=1` tune the install; see the header of `install.sh`.
|
`ZAG_VERSION`, `ZAG_PREFIX` and `ZAG_NO_SERVICE=1` tune the install; see the header of `install.sh`.
|
||||||
|
|
||||||
|
### Homebrew
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew tap samson-media/tap https://gitea.samson.media/samson-media/homebrew-tap
|
||||||
|
export HOMEBREW_GITEA_TOKEN=<gitea access token that can read this repository>
|
||||||
|
brew install zag
|
||||||
|
brew services start zag
|
||||||
|
```
|
||||||
|
|
||||||
### Manual
|
### Manual
|
||||||
|
|
||||||
Download `zag-linux-x64`, `zag-linux-arm64`, `zag-macos-arm64` or `zag-macos-x64` from the
|
Download `zag-linux-x64`, `zag-linux-arm64`, `zag-macos-arm64` or `zag-macos-x64` from the
|
||||||
|
|||||||
Reference in new issue
Block a user