diff options
| author | user <user@clank> | 2026-08-27 01:28:45 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-27 01:28:45 +0200 |
| commit | 5ba81343523e7b56a1514f2fc98f47973299b8f4 (patch) | |
| tree | 002d3958474651ccf851157c76a953ecf3b6ea8f | |
| parent | add LICENSE (MIT) and THIRD-PARTY-LICENSES (diff) | |
| download | slosh-5ba81343523e7b56a1514f2fc98f47973299b8f4.tar.gz slosh-5ba81343523e7b56a1514f2fc98f47973299b8f4.tar.xz slosh-5ba81343523e7b56a1514f2fc98f47973299b8f4.zip | |
release: one 'make release' for the three target binaries
Streamline the release into a single target that stages all three binaries
in dist/ with a SHA256SUMS:
linux x86_64 } cross-built here with 'zig cc -target ... -s', static musl
linux aarch64 } (runs on any distro), packaged as a .tar.gz with the binary
+ README + LICENSE + THIRD-PARTY-LICENSES
macos arm64 handed to 'macos-dist', which signs/notarizes on the builder
zig is already the compiler, so the two linux cross-builds need no extra
toolchain -- just the vendored libghostty-vt rebuilt per -Dtarget. Verified
both: static, stripped (~2MB), and both run (aarch64 under qemu-user).
Factor the version ladder out of the Makefile into contrib/version, and call
it from both Makefile and Makefile.macos, so the linux tarballs, the signed
zip and the binary's own --version are all named from the same tag instead
of Makefile.macos using its own 'git describe --always' scheme (which would
have named the mac artifact after a bare commit hash while linux used the
tag).
make release-linux # just the two linux tarballs
make release REF=<tag> # all three + SHA256SUMS
| -rw-r--r-- | Makefile | 89 | ||||
| -rw-r--r-- | Makefile.macos | 7 | ||||
| -rwxr-xr-x | contrib/version | 37 |
3 files changed, 109 insertions, 24 deletions
@@ -19,27 +19,13 @@ VT_INC := $(VT_OUT)/include # behaving oddly is "which build is this?" -- and a session keeps the binary it # started with, so the answer is not "whatever is in build/ now". # -# It is derived from git tags (vX.Y.Z), so a tag is the single source of truth -# and nothing here is bumped by hand: -# on a tag v0.2.0 -> 0.2.0 -# past a tag v0.2.0-5-gabc123 -> 0.2.0-5-gabc123 (sorts after 0.2.0) -# before any tag 0.1.0-197-g2d1815 -> ./VERSION + commit count + short id -# no .git at all 0.1.0 -> ./VERSION verbatim (a cgit snapshot -# tarball, which is how Homebrew builds) -# A dirty tree appends -dirty. ./VERSION is the committed floor and the only -# value a source tarball without git can show; contrib/brew-release reads it too. -# The commit count is in there so `brew upgrade` sees a later build as later: -# without it 0.1.0-gabc123 vs 0.1.0-gdef456 would sort alphabetically, which -# has nothing to do with which came first. -VERSION := $(shell \ - if git rev-parse --git-dir >/dev/null 2>&1; then \ - d=$$(git describe --tags --match 'v[0-9]*' --dirty 2>/dev/null); \ - if [ -n "$$d" ]; then printf '%s\n' "$${d#v}"; \ - else printf '%s-%s-g%s%s\n' "$$(cat VERSION 2>/dev/null || echo 0.0.0)" \ - "$$(git rev-list --count HEAD 2>/dev/null || echo 0)" \ - "$$(git rev-parse --short=8 HEAD 2>/dev/null || echo unknown)" \ - "$$(git diff --quiet 2>/dev/null || echo -dirty)"; fi; \ - else cat VERSION 2>/dev/null || echo 0.0.0; fi) +# It is derived from git tags (vX.Y.Z) by contrib/version -- a tag is the single +# source of truth and nothing here is bumped by hand. The same script names the +# release artifacts and is read by Makefile.macos, so a build, its file name and +# its baked-in --version can never disagree. See contrib/version for the ladder +# (on a tag -> 0.2.0; before any tag -> <VERSION>-<count>-g<short>; no git at +# all -> ./VERSION verbatim, which is how a cgit snapshot / Homebrew build sees it). +VERSION := $(shell contrib/version) CFLAGS := -std=c23 -O1 -g -Wall -Wextra -Wno-unused-parameter -MMD -MP \ -I$(VT_INC) -Iinclude -Ibuild @@ -74,7 +60,8 @@ else endif .PHONY: all clean vendor run test retest test-live test-all smoke help coverage \ - docs www fmt fmt-check hooks tools install uninstall macos-dist + docs www fmt fmt-check hooks tools install uninstall macos-dist \ + release release-linux .DEFAULT_GOAL := help help: ## show this @@ -361,6 +348,64 @@ macos-dist: ## signed, notarized macOS build on the builder mac (REF=<tag> for a echo "To provision a builder mac: contrib/macos-builder-setup --help"; exit 1; } $(Q)$(MAKE) -f Makefile.macos remote-dist REF=$(REF) +# ── releases ──────────────────────────────────────────────────────────────── +# Three binaries for a tagged release, staged in dist/ with a SHA256SUMS beside +# them. The two linux ones are cross-built right here: zig cc is already the +# compiler, so -target gets us x86_64 and aarch64 for free, statically linked +# against musl so they run on any distro regardless of its libc. macOS is the +# one that cannot be built here -- it must be signed and notarized on a mac -- +# so `release` hands that leg to `macos-dist`, which drives the builder. +# +# VERSION comes from the git tag (contrib/version), so the usual flow is to +# check out the tag and run `make release REF=<tag>`: the linux tarballs are +# named from the working tree, the macOS zip from the ref the builder checks +# out, and because both resolve the same tag the three names agree. +DIST ?= dist +# Each tarball carries the binary plus the paperwork a redistributed build must +# ship (see THIRD-PARTY-LICENSES: libghostty-vt and stb_image are linked in). +REL_DOCS := README.md LICENSE THIRD-PARTY-LICENSES +# The target triples we cross-build. The arch label in the artifact name is the +# part before the first '-' (x86_64, aarch64). +LINUX_TARGETS := x86_64-linux-musl aarch64-linux-musl +# Release build flags: like CFLAGS but -O2, no -g (we strip at link with -s) and +# no depfiles (a one-shot build, not an incremental one). The per-target zig-out +# include is added in-recipe; the host VT_INC is deliberately left out. +REL_CFLAGS := -std=c23 -O2 -Wall -Wextra -Wno-unused-parameter -Iinclude -Ibuild + +release-linux: build/version.h build/logo.h ## cross-build the static linux tarballs into dist/ + $(Q)mkdir -p $(DIST) + $(Q)set -e; for t in $(LINUX_TARGETS); do \ + arch=$${t%%-*}; stem=slosh-$(VERSION)-linux-$$arch; \ + vtpfx=build/vt/$$t; vta=$$vtpfx/lib/libghostty-vt.a; \ + odir=build/obj/$$t; stage=build/stage/$$stem; \ + printf ' %-5s %s\n' '[VT]' "$$t"; \ + ( cd $(VT) && PATH="$(dir $(ZIG)):$$PATH" zig build \ + -Demit-lib-vt -Demit-xcframework=false -Doptimize=ReleaseFast \ + -Dtarget=$$t --prefix "$(CURDIR)/$$vtpfx" ); \ + mkdir -p $$odir; \ + for c in $(SRC); do \ + o=$$odir/$$(basename $${c%.c}).o; \ + if [ "$$(basename $$c)" = png.c ]; then \ + $(CC) -target $$t $(REL_CFLAGS) -I$$vtpfx/include -I$(VT)/src/stb -Wno-unused-function -c "$$c" -o "$$o"; \ + else \ + $(CC) -target $$t $(REL_CFLAGS) -I$$vtpfx/include -c "$$c" -o "$$o"; \ + fi; \ + done; \ + printf ' %-5s %s\n' '[LD]' "$$stem/slosh"; \ + $(CC) -target $$t -s $$odir/*.o "$$vta" -o build/slosh-$$t; \ + rm -rf $$stage; mkdir -p $$stage; \ + cp build/slosh-$$t $$stage/slosh; cp $(REL_DOCS) $$stage/; \ + ( cd build/stage && tar czf "$(CURDIR)/$(DIST)/$$stem.tar.gz" "$$stem" ); \ + printf ' %-5s %s\n' '[TAR]' "$(DIST)/$$stem.tar.gz"; \ + done + +release: release-linux ## full release: linux tarballs + signed macOS zip + SHA256SUMS in dist/ + $(Q)$(MAKE) --no-print-directory macos-dist REF=$(REF) + $(Q)cd $(DIST) && { sha256sum slosh-$(VERSION)-* 2>/dev/null \ + || shasum -a 256 slosh-$(VERSION)-*; } > SHA256SUMS + $(call say,[SUMS],$(DIST)/SHA256SUMS) + $(Q)cat $(DIST)/SHA256SUMS + # ── installation ──────────────────────────────────────────────────────────── # For packagers (Homebrew's formula calls exactly this) and for anyone doing # `sudo make install`. DESTDIR is the staging root a package manager wants; diff --git a/Makefile.macos b/Makefile.macos index 4bce7d6..d53424b 100644 --- a/Makefile.macos +++ b/Makefile.macos @@ -68,8 +68,11 @@ MAINMAKE ?= $(MAKE) -f Makefile BIN ?= build/slosh DIST ?= dist -# Version string for the artifact names. Matches the Makefile's scheme. -VERSION ?= $(shell git describe --always --dirty 2>/dev/null || echo 0.0.0) +# Version string for the artifact names. Derived by contrib/version, exactly as +# the main Makefile does, so the signed zip's name matches the linux tarballs +# and the binary's own --version. Runs on the builder, over the ref it checked +# out, so a release names itself after that tag. +VERSION ?= $(shell contrib/version) ARCH ?= $(shell uname -m) STEM := slosh-$(VERSION)-macos-$(ARCH) ZIP := $(DIST)/$(STEM).zip diff --git a/contrib/version b/contrib/version new file mode 100755 index 0000000..0190a30 --- /dev/null +++ b/contrib/version @@ -0,0 +1,37 @@ +#!/bin/sh +# version -- print slosh's version string, derived from git tags with ./VERSION +# as the floor (and the answer when there is no git at all). +# +# One script, so a build, the artifact it is packaged into, and the string the +# binary prints for `--version` can never disagree: the main Makefile bakes it +# in, Makefile.macos names the signed zip with it, and the release target names +# the linux tarballs with it. The ladder: +# +# on a tag v0.2.0 -> 0.2.0 +# past a tag v0.2.0-5-gabc123 -> 0.2.0-5-gabc123 (sorts after 0.2.0) +# before any tag <VERSION>-<count>-g<short> (+ -dirty if dirty) +# no .git at all <VERSION> (verbatim) +# +# ./VERSION is the committed floor and the only value a source tarball without +# git can show -- a cgit snapshot, which is how Homebrew builds from source. The +# commit count is in the tag-less form so `brew upgrade` sees a later build as +# later: without it 0.1.0-gabc123 vs 0.1.0-gdef456 would sort alphabetically, +# which has nothing to do with which came first. +set -eu + +root="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)" +base="$(cat "$root/VERSION" 2>/dev/null || echo 0.0.0)" + +if git -C "$root" rev-parse --git-dir >/dev/null 2>&1; then + d="$(git -C "$root" describe --tags --match 'v[0-9]*' --dirty 2>/dev/null || true)" + if [ -n "$d" ]; then + printf '%s\n' "${d#v}" + else + count="$(git -C "$root" rev-list --count HEAD 2>/dev/null || echo 0)" + short="$(git -C "$root" rev-parse --short=8 HEAD 2>/dev/null || echo unknown)" + dirty=""; git -C "$root" diff --quiet 2>/dev/null || dirty="-dirty" + printf '%s-%s-g%s%s\n' "$base" "$count" "$short" "$dirty" + fi +else + printf '%s\n' "$base" +fi |
