commit 99d3d815815f65638ca4d40d4b860bc8c730bcd9
parent d52a0fc3a2d9006da9ffac8b84e5452b51219846
Author: mtmn <miro@haravara.org>
Date: Sun, 14 Jun 2026 21:01:39 +0200
build: streamline release script
Diffstat:
| D | CHANGELOG.md | | | 71 | ----------------------------------------------------------------------- |
| D | cliff.toml | | | 45 | --------------------------------------------- |
| M | hack/release | | | 82 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
3 files changed, 41 insertions(+), 157 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -1,71 +0,0 @@
-# Changelog
-
-## [0.3.0] - 2026-06-09
-
-### Bug Fixes
-
-- Consume newline on reading memcached response ([`7372072`](https://git.sr.ht/~mtmn/magdalena/commit/737207265c3f886fe87a06552f89cc7bdc1654db))
-
-### Features
-
-- Apply findings from zlint ([`42bf945`](https://git.sr.ht/~mtmn/magdalena/commit/42bf945818946a95a481c92fb101235a2945396a))
-
-## [0.2.0] - 2026-06-09
-
-### Features
-
-- Test: add `testing` and fix findings ([`746932d`](https://git.sr.ht/~mtmn/magdalena/commit/746932d8a6954fd27d99593b7d4b51774cf95a1b))
-
-### Housekeeping
-
-- Release v0.2.0 ([`208223b`](https://git.sr.ht/~mtmn/magdalena/commit/208223b916c59db30ee10b33e5f9bef9374d2a3e))
-
-## [0.1.3] - 2026-05-10
-
-### Documentation
-
-- Add dependencies ([`05ccaca`](https://git.sr.ht/~mtmn/magdalena/commit/05ccacac83090df21df186527581684a3d170f66))
-
-### Housekeeping
-
-- Release v0.1.3 ([`f1e6f51`](https://git.sr.ht/~mtmn/magdalena/commit/f1e6f51bc60368c7032a44f5d58f451c17179178))
-
-## [0.1.2] - 2026-05-09
-
-### Bug Fixes
-
-- Exec into opener instead of waiting on it ([`85c09f1`](https://git.sr.ht/~mtmn/magdalena/commit/85c09f10232b26acc41a65f71074a056c56f4192))
-
-### Housekeeping
-
-- Release v0.1.2 ([`5a00413`](https://git.sr.ht/~mtmn/magdalena/commit/5a004133666946788609b87a7453e0346516c833))
-
-## [0.1.1] - 2026-05-07
-
-### Bug Fixes
-
-- Wrong url in git-cliff ([`f11e187`](https://git.sr.ht/~mtmn/magdalena/commit/f11e187dd8e96daa59f1fcc4785b0a380311c593))
-
-### Housekeeping
-
-- Release v0.1.1 ([`21c3a6f`](https://git.sr.ht/~mtmn/magdalena/commit/21c3a6f2c5b42e9206109bd04e55d9f3d597e342))
-
-## [0.1.0]
-
-### Documentation
-
-- Update readme ([`ea661a8`](https://git.sr.ht/~mtmn/magdalena/commit/ea661a8f54b6407e299e1989faf0b7448ff323ac))
-- Update readme ([`d44a239`](https://git.sr.ht/~mtmn/magdalena/commit/d44a2393f26e695f4c62f27808f6f1e5d7c85586))
-
-### Features
-
-- **breaking:** Add path based overrides ([`69bab0e`](https://git.sr.ht/~mtmn/magdalena/commit/69bab0eed9881f0a425140ef8c9677f0fcf7dd4c))
-- Add release script ([`447368a`](https://git.sr.ht/~mtmn/magdalena/commit/447368a7b2cd4034ff4d4928fb1aa4ae3317fe58))
-
-### Housekeeping
-
-- Remove bazel files ([`7d7917b`](https://git.sr.ht/~mtmn/magdalena/commit/7d7917b4a094f0ac54537173182b03fe38d65303))
-- Add license ([`af46877`](https://git.sr.ht/~mtmn/magdalena/commit/af46877b6bf86045d68dcfb761c05139c2033a36))
-- Add gitignore ([`cd5524c`](https://git.sr.ht/~mtmn/magdalena/commit/cd5524ce778d7e5969bf08a0ecbca226d2449e94))
-- Format config.json ([`36c8e6a`](https://git.sr.ht/~mtmn/magdalena/commit/36c8e6ad640f08574facc58c4bb2f6d87d540827))
-- Release v0.1.0 ([`82f75ea`](https://git.sr.ht/~mtmn/magdalena/commit/82f75eaba5f9cc8945f0ad6de5a649bd33c4b143))
diff --git a/cliff.toml b/cliff.toml
@@ -1,45 +0,0 @@
-[changelog]
-header = "# Changelog\n\n"
-body = """
-{% if version -%}
-## [{{ version | trim_start_matches(pat="v") }}]{% if previous.version %} - {{ timestamp | date(format="%Y-%m-%d") }}{% endif %}
-
-{% else -%}
-## [Unreleased]
-
-{% endif -%}
-{% for group, commits in commits | group_by(attribute="group") -%}
-### {{ group }}
-
-{% for commit in commits -%}
-- {% if commit.breaking %}**breaking:** {% endif -%}
-{% if commit.scope %}**{{ commit.scope }}:** {% endif -%}
-{{ commit.message | upper_first }} \
-([`{{ commit.id | truncate(length=7, end="") }}`](https://git.sr.ht/~mtmn/magdalena/commit/{{ commit.id }}))
-{% endfor %}
-{% endfor %}
-"""
-footer = ""
-trim = true
-
-[git]
-conventional_commits = true
-filter_unconventional = true
-split_commits = false
-commit_parsers = [
- { message = "^feat", group = "Features" },
- { message = "^fix", group = "Bug Fixes" },
- { message = "^docs", group = "Documentation" },
- { message = "^test", group = "Testing" },
- { message = "^chore", group = "Housekeeping" },
- { message = "^chore\\(deps\\)", group = "Dependencies" },
- { message = "^ci", skip = true },
-]
-protect_breaking_commits = true
-filter_commits = true
-tag_pattern = "v[0-9].*"
-topo_order = false
-sort_commits = "oldest"
-
-[bump]
-initial_tag = "v0.1.0"
diff --git a/hack/release b/hack/release
@@ -1,54 +1,54 @@
#!/usr/bin/env bash
set -euo pipefail
+cd "$(dirname "$0")/.."
-require() {
- command -v "$1" &>/dev/null || {
- echo "error: $1 not found"
- exit 1
- }
-}
-require git
-require git-cliff
-
-# --- pre-flight ---
-
-if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
- echo "error: not on master branch"
- exit 1
-fi
-
-if [ -n "$(git status --porcelain)" ]; then
- echo "error: working tree is dirty"
- exit 1
-fi
+BRANCH="master"
+REMOTE="origin"
-# --- version calculation ---
-
-next=$(git-cliff --bumped-version | sed 's/^v//')
-
-if git tag | grep -qx "v$next"; then
- echo "no releasable commits since v$next"
- exit 0
-fi
+die() {
+ echo "error: $*" >&2
+ exit 1
+}
-echo "releasing -> v$next"
+update_version_file() {
+ local version="$1"
+ [ -f build.zig.zon ] || return 0
+ sed -i "s/\.version = \"[^\"]*\"/.version = \"$version\"/" build.zig.zon
+ git add build.zig.zon
+}
-# --- update build.zig.zon ---
+command -v git >/dev/null 2>&1 || die "git not found"
-sed -i "s/\.version = \"[^\"]*\"/.version = \"$next\"/" build.zig.zon
-git add build.zig.zon
+current=$(git tag --list 'v[0-9]*' --sort=-v:refname | head -n1)
+current=${current#v}
+usage="$(basename "$0") <version> [--push] (${current:-none})"
-# --- changelog ---
+version=""
+push=0
+for arg in "$@"; do
+ case "$arg" in
+ --push) push=1 ;;
+ -*) die "unknown flag: $arg" ;;
+ *)
+ [ -z "$version" ] || die "unexpected argument: $arg"
+ version="$arg"
+ ;;
+ esac
+done
-git-cliff --tag "v$next" --output CHANGELOG.md
-sed -i -e :a -e '/^\s*$/{$d;N;ba' -e '}' CHANGELOG.md
-git add CHANGELOG.md
+[ -n "$version" ] || die "$usage"
+echo "$version" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)*$' ||
+ die "'$version' is not a semantic version"
-git commit -m "chore: release v$next"
+[ "$(git rev-parse --abbrev-ref HEAD)" = "$BRANCH" ] || die "not on $BRANCH branch"
+[ -z "$(git status --porcelain)" ] || die "working tree is dirty"
+git rev-parse -q --verify "refs/tags/v$version" >/dev/null 2>&1 && die "tag v$version already exists"
-# --- tag and push ---
+update_version_file "$version"
-git tag "v$next"
-git push origin master --tags
+git commit -m "chore: release v$version"
+git tag -a "v$version" -m "v$version"
-echo "released v$next successfully"
+if [ "$push" -eq 1 ]; then
+ git push "$REMOTE" "$BRANCH" --follow-tags
+fi