6 Commits
Author SHA1 Message Date
Daniel SamsonandClaude Sonnet 5.5 0567e2ef8d build: fix the Windows-unsupported check (std.process.fatal)
CI / test (push) Successful in 3m22s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 14:49:21 +01:00
Daniel SamsonandClaude Sonnet 5.5 f4e15aa32d Drop Windows support: clear build error, docs updated
CI / test (push) Failing after 11s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 14:48:57 +01:00
Daniel SamsonandClaude Sonnet 5.5 4db6b7b1b3 docs/ci: zag is public, drop token handling from the formula, installer and README
CI / test (push) Successful in 3m23s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 14:37:33 +01:00
Daniel SamsonandClaude Sonnet 5.5 24c7a2804d ci: update the Homebrew tap on release; docs for brew and branches
CI / test (push) Successful in 3m19s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 14:27:43 +01:00
Daniel SamsonandClaude Sonnet 5.5 47b12895fd ci: read the release id correctly and reuse an existing release
CI / test (push) Successful in 3m20s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 14:17:26 +01:00
Daniel SamsonandClaude Sonnet 5.5 4b55f5a060 ci: report release API errors, support re-running the release for an existing tag
CI / test (push) Successful in 3m20s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 14:13:24 +01:00
7 changed files with 140 additions and 25 deletions

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
#!/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.
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"
sha256 "$(sha macos-arm64)"
end
on_intel do
url "$base/zag-macos-x64"
sha256 "$(sha macos-x64)"
end
end
on_linux do
on_arm do
url "$base/zag-linux-arm64"
sha256 "$(sha linux-arm64)"
end
on_intel do
url "$base/zag-linux-x64"
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
+52 -10
View File
@@ -5,12 +5,22 @@ name: Release
on: on:
push: push:
tags: ['v*'] tags: ['v*']
workflow_dispatch:
inputs:
tag:
description: 'Existing tag to build and publish (e.g. v0.1.0)'
required: true
env:
TAG: ${{ inputs.tag || github.ref_name }}
jobs: jobs:
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with:
ref: ${{ env.TAG }}
- name: Install Zig - name: Install Zig
run: echo "$(.github/ci/install-zig.sh)" >> "$GITHUB_PATH" run: echo "$(.github/ci/install-zig.sh)" >> "$GITHUB_PATH"
@@ -18,7 +28,7 @@ jobs:
- name: Check the tag matches build.zig.zon - name: Check the tag matches build.zig.zon
run: | run: |
version=$(sed -n 's/^[[:space:]]*\.version = "\(.*\)",$/\1/p' build.zig.zon) 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; } [ "v$version" = "$TAG" ] || { echo "tag $TAG != v$version"; exit 1; }
- name: Test - name: Test
run: | run: |
@@ -41,18 +51,50 @@ jobs:
- name: Publish the release - name: Publish the release
env: env:
TOKEN: ${{ secrets.GITHUB_TOKEN }} # RELEASE_TOKEN (a personal access token with write:repository) wins when the
# built-in token is not allowed to create releases.
TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
run: | run: |
api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" 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) notes=$(awk -v v="${TAG#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 '""') 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" \ resp=$(mktemp)
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \ code=$(curl -sS -o "$resp" -w '%{http_code}' -X POST "$api/releases" \
-d "{\"tag_name\":\"${GITHUB_REF_NAME}\",\"name\":\"${GITHUB_REF_NAME}\",\"body\":${body}}" \ -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
| sed -n 's/.*"id":\([0-9]*\).*/\1/p' | head -1) -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":${body}}")
[ -n "$id" ] || { echo "could not create the release"; exit 1; } if [ "$code" = "409" ]; then
# The release already exists (e.g. an earlier run created it): reuse it.
code=$(curl -sS -o "$resp" -w '%{http_code}' -H "Authorization: token $TOKEN" "$api/releases/tags/$TAG")
fi
if [ "$code" != "201" ] && [ "$code" != "200" ]; then
echo "creating the release failed: HTTP $code"; cat "$resp"; echo
exit 1
fi
# The release's own id is the first key; later "id"s belong to nested objects.
id=$(sed -n 's/^{"id":\([0-9]*\),.*/\1/p' "$resp" | head -1)
[ -n "$id" ] || { echo "could not read the release id"; cat "$resp"; echo; exit 1; }
for f in dist/*; do for f in dist/*; do
echo "uploading $f" echo "uploading $f"
curl -fsS -X POST "$api/releases/$id/assets?name=$(basename "$f")" \ code=$(curl -sS -o "$resp" -w '%{http_code}' -X POST "$api/releases/$id/assets?name=$(basename "$f")" \
-H "Authorization: token $TOKEN" -F "attachment=@$f" >/dev/null -H "Authorization: token $TOKEN" -F "attachment=@$f")
[ "$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
+10 -1
View File
@@ -58,8 +58,16 @@ Guidance for AI coding agents working in `zag`, the Zig port of the
| `test/e2e.sh` | End-to-end smoke test (`zig build e2e`) | | `test/e2e.sh` | End-to-end smoke test (`zig build e2e`) |
| `src/servicemgr.zig` | systemd unit / launchd plist generation, install detection, manager commands | | `src/servicemgr.zig` | systemd unit / launchd plist generation, install detection, manager commands |
## Platforms
Linux and macOS only. Windows support was dropped on purpose, and building for a Windows target
fails with a clear compile error (`src/root.zig`). A few `builtin.os.tag == .windows` branches remain in
the code from the port; new code does not need to handle Windows.
## 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 +75,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`).
+16 -9
View File
@@ -6,16 +6,17 @@
> name, and fixes the places where barn's behaviour did not match its documentation (see > name, and fixes the places where barn's behaviour did not match its documentation (see
> [Migration from barn](#migration-from-barn)). > [Migration from barn](#migration-from-barn)).
A **cross-platform service** for managing long-running jobs that involve A **cross-platform (Linux and macOS) service** for managing long-running jobs that involve
downloading and uploading media via WebDAV, using FFmpeg to analyse and transcode video, with strong guarantees around durability, downloading and uploading media via WebDAV, using FFmpeg to analyse and transcode video, with strong guarantees around durability,
observability, and crash recovery. observability, and crash recovery.
This project is designed to run as a **real OS service / daemon** on: This project is designed to run as a **real OS service / daemon** on:
- Windows (Windows Service)
- macOS (launchd) - macOS (launchd)
- Linux (systemd) - Linux (systemd)
Windows is not supported.
The daemon is **not HTTP-bound**. The daemon is **not HTTP-bound**.
It runs independently in the background and exposes control via a local CLI / RPC interface. It runs independently in the background and exposes control via a local CLI / RPC interface.
@@ -47,7 +48,7 @@ a low idle memory footprint, and easy cross-compilation to every supported platf
- Survive SSH disconnects, restarts, and crashes - Survive SSH disconnects, restarts, and crashes
- Explicitly model job state and failure reasons - Explicitly model job state and failure reasons
- Provide durable, inspectable job state - Provide durable, inspectable job state
- Work consistently on Windows, Linux, and macOS - Work consistently on Linux and macOS
- Avoid coupling to HTTP or web frameworks - Avoid coupling to HTTP or web frameworks
- Stay drop-in compatible with barn's CLI, JSON/XML output, and job directory layout - Stay drop-in compatible with barn's CLI, JSON/XML output, and job directory layout
@@ -58,16 +59,22 @@ a low idle memory footprint, and easy cross-compilation to every supported platf
### Linux / macOS ### Linux / macOS
The installer downloads the latest release, installs the binary and registers a service The installer downloads the latest release, installs the binary and registers a service
(systemd on Linux, launchd on macOS). The repository is private, so provide an access token: (systemd on Linux, launchd on macOS):
```bash ```bash
export ZAG_TOKEN=<gitea access token> curl -fsSL https://gitea.samson.media/samson-media/zag/raw/branch/main/install.sh | sh
curl -fsSL -H "Authorization: token $ZAG_TOKEN" \
https://gitea.samson.media/samson-media/zag/raw/branch/main/install.sh | sh
``` ```
`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
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
@@ -79,7 +86,7 @@ chmod +x zag-linux-x64 && sudo mv zag-linux-x64 /usr/local/bin/zag
zag --version zag --version
``` ```
The binaries are static and need no runtime. Windows is not supported yet. The binaries are static and need no runtime. Windows is not supported and there are no plans to add it.
### Setting up the service ### Setting up the service
@@ -270,7 +277,7 @@ documentation:
`curl` as LOW. `curl` as LOW.
- `config show` calls the load-limit section `load_levels`, matching the config file. - `config show` calls the load-limit section `load_levels`, matching the config file.
Not implemented yet: Windows, `max_disk_usage_gb`, `preserve_work_dir`, auto-update. Not implemented: Windows (dropped on purpose), `max_disk_usage_gb`, `preserve_work_dir`, auto-update.
## Project Layout ## Project Layout
+1
View File
@@ -7,6 +7,7 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{ const target = b.standardTargetOptions(.{
.default_target = if (builtin.os.tag == .linux) .{ .abi = .musl } else .{}, .default_target = if (builtin.os.tag == .linux) .{ .abi = .musl } else .{},
}); });
if (target.result.os.tag == .windows) std.process.fatal("zag does not support Windows (supported: Linux and macOS)", .{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const strip = b.option(bool, "strip", "Strip debug symbols from the binary") orelse false; const strip = b.option(bool, "strip", "Strip debug symbols from the binary") orelse false;
+2 -5
View File
@@ -5,7 +5,6 @@
# #
# Environment: # Environment:
# ZAG_VERSION release tag to install (default: latest) # ZAG_VERSION release tag to install (default: latest)
# ZAG_TOKEN Gitea access token (the repository is private)
# ZAG_PREFIX install directory (default: /usr/local/bin as root, ~/.local/bin otherwise) # ZAG_PREFIX install directory (default: /usr/local/bin as root, ~/.local/bin otherwise)
# ZAG_NO_SERVICE=1 skip `zag service install` # ZAG_NO_SERVICE=1 skip `zag service install`
set -eu set -eu
@@ -27,17 +26,15 @@ case "$(uname -m)" in
*) die "unsupported architecture: $(uname -m)" ;; *) die "unsupported architecture: $(uname -m)" ;;
esac esac
auth=""
[ -n "${ZAG_TOKEN:-}" ] && auth="Authorization: token $ZAG_TOKEN"
fetch() { # fetch <url> <output> fetch() { # fetch <url> <output>
if [ -n "$auth" ]; then curl -fsSL -H "$auth" -o "$2" "$1"; else curl -fsSL -o "$2" "$1"; fi curl -fsSL -o "$2" "$1"
} }
version="${ZAG_VERSION:-}" version="${ZAG_VERSION:-}"
if [ -z "$version" ]; then if [ -z "$version" ]; then
info "Looking up the latest release" info "Looking up the latest release"
tmp_json=$(mktemp) tmp_json=$(mktemp)
fetch "$BASE/api/v1/repos/$REPO/releases/latest" "$tmp_json" || die "could not query releases (is ZAG_TOKEN set?)" fetch "$BASE/api/v1/repos/$REPO/releases/latest" "$tmp_json" || die "could not query releases"
version=$(sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$tmp_json" | head -1) version=$(sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$tmp_json" | head -1)
rm -f "$tmp_json" rm -f "$tmp_json"
[ -n "$version" ] || die "could not determine the latest version" [ -n "$version" ] || die "could not determine the latest version"
+5
View File
@@ -1,6 +1,11 @@
//! zag: cross-platform job daemon (Zig port of barn). //! zag: cross-platform job daemon (Zig port of barn).
pub const version = @import("build_options").version; pub const version = @import("build_options").version;
comptime {
if (@import("builtin").os.tag == .windows)
@compileError("zag does not support Windows (supported: Linux and macOS)");
}
pub const duration = @import("duration.zig"); pub const duration = @import("duration.zig");
pub const timestamp = @import("timestamp.zig"); pub const timestamp = @import("timestamp.zig");
pub const state = @import("state.zig"); pub const state = @import("state.zig");