Skip to content

Modern Docker Management, Designed for Everyone

chore: use git cliff for releases (thanks pocket-id :))

Kyle Mendelld742817ccd9c
diff --git a/cliff.toml b/cliff.toml
new file mode 100644
index 000000000..2a4aad97c
--- /dev/null
+++ b/cliff.toml
@@ -0,0 +1,50 @@
+# git-cliff ~ configuration file
+# https://git-cliff.org/docs/configuration
+# originally from pocket-id
+
+[remote.github]
+owner = "ofkm"
+repo = "arcane"
+
+[git]
+conventional_commits = true
+filter_unconventional = true
+commit_preprocessors = [{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" }]
+commit_parsers = [
+ { message = "^feat", group = "Features" },
+ { message = "^fix", group = "Bug Fixes" },
+ { message = "^docs", group = "Documentation" },
+ { message = "^perf", group = "Performance Improvements" },
+ { message = "^release", skip = true },
+ { message = "update translations via Crowdin", skip = true },
+ { message = ".*", group = "Other", default_scope = "other"},
+]
+filter_commits = false
+
+[changelog]
+trim = true
+body = """
+## {{ version | default(value="Unknown Version") }}
+{% for group, commits in commits | group_by(attribute="group") %}
+### {{ group | title }}
+{% for commit in commits %}
+ * {{ commit.message }} \
+ {%- if commit.remote.pr_number -%}
+ ([#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) by @{{ commit.remote.username | default(value=commit.author.name) }})
+ {%- else -%}
+ ([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}) by @{{ commit.remote.username | default(value=commit.author.name) }})
+ {%- endif -%}
+{% endfor %}
+{% endfor %}
+{% if version %}
+ {% if previous.version %}
+ **Full Changelog**: {{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}
+ {% endif %}
+{% else -%}
+ {% raw %}\n{% endraw %}
+{% endif %}
+
+{%- macro remote_url() -%}
+ https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
+{%- endmacro -%}
+"""
\ No newline at end of file
diff --git a/scripts/development/create-release.sh b/scripts/development/create-release.sh
index 6ffb0329c..70ec8d984 100755
--- a/scripts/development/create-release.sh
+++ b/scripts/development/create-release.sh
@@ -7,14 +7,10 @@ if [ ! -f .version ] || [ ! -f frontend/package.json ] || [ ! -f CHANGELOG.md ];
exit 1
fi
-# Check if conventional-changelog is installed, if not install it
-if ! command -v conventional-changelog &>/dev/null; then
- echo "conventional-changelog not found, installing..."
- npm install -g conventional-changelog-cli
- if ! command -v conventional-changelog &>/dev/null; then
- echo "Error: Failed to install conventional-changelog-cli."
- exit 1
- fi
+# Check if git cliff is installed
+if ! command -v git cliff &>/dev/null; then
+ echo "Error: git cliff is not installed. Please install it from https://git-cliff.org/docs/installation."
+ exit 1
fi
# Check if GitHub CLI is installed
@@ -129,7 +125,7 @@ git add .revision
# Generate changelog
echo "Generating changelog..."
-conventional-changelog -p conventionalcommits -i CHANGELOG.md -s --pkg frontend/package.json
+git cliff --github-token=$(gh auth token) --prepend CHANGELOG.md --tag "v$NEW_VERSION" --unreleased
git add CHANGELOG.md
# Commit the changes with the new version
@@ -144,7 +140,7 @@ git push --tags
# Extract the changelog content for the latest release
echo "Extracting changelog content for version $NEW_VERSION..."
-CHANGELOG=$(awk '/^## / {if (NR > 1) exit} NR > 1 {print}' CHANGELOG.md | awk 'NR > 2 || NF {print}')
+CHANGELOG=$(awk '/^## v[0-9]/ { if (found) exit; found=1; next } found' CHANGELOG.md)
if [ -z "$CHANGELOG" ]; then
echo "Error: Could not extract changelog for version $NEW_VERSION."
diff --git a/scripts/development/create-release.zsh b/scripts/development/create-release.zsh
deleted file mode 100755
index 1564d7020..000000000
--- a/scripts/development/create-release.zsh
+++ /dev/null
@@ -1,270 +0,0 @@
-#!/usr/bin/env zsh
-
-set -euo pipefail
-set -o pipefail
-
-# set git pager to cat instead of less
-export GIT_PAGER=cat
-export PAGER=cat
-
-print_err() { printf "%s\n" "$*" >&2; }
-
-usage() {
- cat <<'EOF'
-Usage: create-release.zsh [--major|--minor|--patch] [--yes] [--dry-run]
-
-Options:
- --major Force a major version bump
- --minor Force a minor version bump
- --patch Force a patch version bump
- --yes Skip confirmation prompt
- --dry-run Show planned actions without applying changes
- -h, --help Show this help
-
-Logic (when no explicit bump flag is given):
- - If no previous tag exists: minor
- - If commits contain feat: minor
- - Else if commits contain fix: patch
- - Else abort (no release)
-
-Examples:
- ./create-release.zsh
- ./create-release.zsh --major --yes
- ./create-release.zsh --dry-run
-
-EOF
-}
-
-# ---------- Parse arguments ----------
-FORCE_BUMP=""
-AUTO_YES=false
-DRY_RUN=false
-
-for arg in "$@"; do
- case "$arg" in
- --major|--minor|--patch)
- FORCE_BUMP="${arg#--}"
- ;;
- --yes)
- AUTO_YES=true
- ;;
- --dry-run)
- DRY_RUN=true
- ;;
- -h|--help)
- usage
- exit 0
- ;;
- *)
- print_err "Unknown argument: $arg"
- usage
- exit 1
- ;;
- esac
-done
-
-# ---------- Project root checks ----------
-if [[ ! -f .version || ! -f frontend/package.json || ! -f CHANGELOG.md ]]; then
- print_err "Error: Must run from project root (need .version, frontend/package.json, CHANGELOG.md)"
- exit 1
-fi
-
-# ---------- Tool checks ----------
-if ! command -v conventional-changelog &>/dev/null; then
- echo "conventional-changelog not found, installing..."
- if ! npm install -g conventional-changelog-cli; then
- print_err "Error: Failed to install conventional-changelog-cli."
- exit 1
- fi
-fi
-
-if ! command -v gh &>/dev/null; then
- print_err "Error: GitHub CLI (gh) not installed or not in PATH. Run: gh auth login"
- exit 1
-fi
-
-if ! command -v jq &>/dev/null; then
- print_err "Error: jq is required."
- exit 1
-fi
-
-# ---------- Git state ----------
-git fetch --tags --quiet || true
-
-current_branch=$(git rev-parse --abbrev-ref HEAD)
-if [[ "$current_branch" != "main" ]]; then
- print_err "Error: Must be on main branch (current: $current_branch)."
- exit 1
-fi
-
-VERSION=$(<.version)
-
-increment_version() {
- local version part
- version=$1
- part=$2
- local -a parts
- IFS='.' read -rA parts <<<"$version"
- case "$part" in
- major)
- parts[0]=$((parts[0] + 1))
- parts[1]=0
- parts[2]=0
- ;;
- minor)
- parts[1]=$((parts[1] + 1))
- parts[2]=0
- ;;
- patch)
- parts[2]=$((parts[2] + 1))
- ;;
- *)
- print_err "Unknown bump part: $part"
- return 1
- ;;
- esac
- echo "${parts[0]}.${parts[1]}.${parts[2]}"
-}
-
-# ---------- Determine release type ----------
-RELEASE_TYPE=""
-if [[ -n "$FORCE_BUMP" ]]; then
- RELEASE_TYPE="$FORCE_BUMP"
-else
- LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
- if [[ -z "$LATEST_TAG" ]]; then
- RELEASE_TYPE="minor"
- else
- SUBJECTS=$(git log --no-merges --format=%s "${LATEST_TAG}..HEAD")
- if echo "$SUBJECTS" | grep -Eiq '^feat(\([^)]+\))?: '; then
- RELEASE_TYPE="minor"
- elif echo "$SUBJECTS" | grep -Eiq '^fix(\([^)]+\))?: '; then
- RELEASE_TYPE="patch"
- else
- echo "No 'fix' or 'feat' commits since ${LATEST_TAG}. No release created."
- echo "Commits since ${LATEST_TAG}:"
- git log --oneline --no-merges "${LATEST_TAG}..HEAD" || true
- exit 0
- fi
- fi
-fi
-
-# ---------- Compute new version ----------
-NEW_VERSION=$(increment_version "$VERSION" "$RELEASE_TYPE") || exit 1
-echo "Proposed ${RELEASE_TYPE} release: $VERSION -> $NEW_VERSION"
-
-if ! $AUTO_YES; then
- if $DRY_RUN; then
- echo "(dry-run) Skipping confirmation prompt."
- else
- read "?Proceed with release v$NEW_VERSION? (y/n) " CONFIRM
- if [[ "$CONFIRM" != "y" ]]; then
- echo "Aborted."
- exit 1
- fi
- fi
-fi
-
-# ---------- Dry run early exit path ----------
-if $DRY_RUN; then
- # Generate prospective release notes by temporarily bumping package.json
- DRY_RELEASE_NOTES=""
- ORIGINAL_PKG_VERSION=$(jq -r '.version' frontend/package.json || echo "")
- if command -v conventional-changelog &>/dev/null; then
- TMP_UPDATED=false
- if [[ -n "$ORIGINAL_PKG_VERSION" && "$ORIGINAL_PKG_VERSION" != "$NEW_VERSION" ]]; then
- jq --arg new_version "$NEW_VERSION" '.version = $new_version' frontend/package.json > frontend/package_tmp.json
- mv frontend/package_tmp.json frontend/package.json
- TMP_UPDATED=true
- fi
-
- GENERATED_CHANGELOG=$(conventional-changelog -p conventionalcommits -u -r 0 2>/dev/null || echo "")
- if $TMP_UPDATED; then
- # Revert package.json
- jq --arg orig "$ORIGINAL_PKG_VERSION" '.version = $orig' frontend/package.json > frontend/package_tmp.json || true
- mv frontend/package_tmp.json frontend/package.json || true
- fi
- if [[ -n "$GENERATED_CHANGELOG" ]]; then
- # Extract first section body (skip header line(s) & blank separation similar to post-release logic)
- DRY_RELEASE_NOTES=$(echo "$GENERATED_CHANGELOG" | awk '/^## / {if (NR>1) exit} NR>1 {print}' | awk 'NR>2 || NF {print}')
- fi
- fi
- if [[ -z "$DRY_RELEASE_NOTES" ]]; then
- DRY_RELEASE_NOTES="(No release notes content could be generated – likely no qualifying commits.)"
- fi
-
- cat <<EOF
-Dry run summary:
- Release type : $RELEASE_TYPE
- Old version : $VERSION
- New version : $NEW_VERSION
- Actions that would occur:
- - Update .version
- - Update frontend/package.json
- - Update .revision
- - Update ARG VERSION/REVISION in Dockerfiles
- - Regenerate CHANGELOG.md
- - Commit, tag v$NEW_VERSION, push
- - Create draft GitHub release with extracted changelog section
-
-Planned release notes (preview):
-$DRY_RELEASE_NOTES
-EOF
- exit 0
-fi
-
-# ---------- Apply changes ----------
-echo "$NEW_VERSION" > .version
-git add .version
-
-jq --arg new_version "$NEW_VERSION" '.version = $new_version' frontend/package.json > frontend/package_tmp.json
-mv frontend/package_tmp.json frontend/package.json
-git add frontend/package.json
-
-LATEST_REVISION=$(git rev-parse --short HEAD)
-echo "$LATEST_REVISION" > .revision
-git add .revision
-
-if [[ -f docker/Dockerfile ]]; then
- echo "Updating docker/Dockerfile ARGs..."
- sed -i.bak -e "s/^ARG VERSION=.*/ARG VERSION=\"${NEW_VERSION}\"/" \
- -e "s/^ARG REVISION=.*/ARG REVISION=\"${LATEST_REVISION}\"/" docker/Dockerfile
- rm docker/Dockerfile.bak
- git add docker/Dockerfile
-fi
-
-if [[ -f docker/Dockerfile-agent ]]; then
- echo "Updating docker/Dockerfile-agent ARGs..."
- sed -i.bak -e "s/^ARG VERSION=.*/ARG VERSION=\"${NEW_VERSION}\"/" \
- -e "s/^ARG REVISION=.*/ARG REVISION=\"${LATEST_REVISION}\"/" docker/Dockerfile-agent
- rm docker/Dockerfile-agent.bak
- git add docker/Dockerfile-agent
-fi
-
-echo "Regenerating CHANGELOG.md..."
-conventional-changelog -p conventionalcommits -i CHANGELOG.md -s
-git add CHANGELOG.md
-
-git commit -m "release: ${NEW_VERSION}"
-git tag "v${NEW_VERSION}"
-git push
-git push --tags
-
-echo "Extracting changelog section for v${NEW_VERSION}..."
-# Extract newest section
-CHANGELOG=$(awk '/^## / {if (NR>1) exit} NR>1 {print}' CHANGELOG.md | awk 'NR>2 || NF {print}')
-
-if [[ -z "$CHANGELOG" ]]; then
- print_err "Error: Could not extract changelog content for v${NEW_VERSION}"
- exit 1
-fi
-
-echo "Creating draft GitHub release..."
-if gh release create "v${NEW_VERSION}" --title "v${NEW_VERSION}" --notes "$CHANGELOG" --draft; then
- echo "Draft release created."
-else
- print_err "Failed to create GitHub release."
- exit 1
-fi
-
-echo "Release complete: v${NEW_VERSION}"
\ No newline at end of file
diff --git a/scripts/development/test-release.sh b/scripts/development/test-release.sh
new file mode 100755
index 000000000..f83551d03
--- /dev/null
+++ b/scripts/development/test-release.sh
@@ -0,0 +1,139 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+echo "[test-release] Dry-run release script (no files mutated)"
+
+# Preconditions
+if [ ! -f .version ] || [ ! -f frontend/package.json ] || [ ! -f CHANGELOG.md ]; then
+ echo "Error: run from project root."
+ exit 1
+fi
+
+need() {
+ if ! command -v "$1" &>/dev/null; then
+ echo "Missing required tool: $1"
+ exit 1
+ fi
+}
+
+need git
+need jq
+need awk
+need sed
+
+if ! command -v git-cliff &>/dev/null && ! command -v git\ cliff &>/dev/null; then
+ if ! command -v git-cliff &>/dev/null; then
+ echo "Error: git-cliff (git cliff) not installed."
+ exit 1
+ fi
+fi
+
+if ! command -v gh &>/dev/null; then
+ echo "Warning: gh not installed"
+fi
+
+git fetch --tags --quiet || true
+
+BRANCH=$(git rev-parse --abbrev-ref HEAD)
+if [ "$BRANCH" != "main" ]; then
+ echo "Error: must be on main (current: $BRANCH)."
+ exit 1
+fi
+
+CURRENT_VERSION=$(cat .version)
+echo "[test-release] Current version: $CURRENT_VERSION"
+
+increment_version() {
+ local version=$1 part=$2
+ IFS='.' read -r -a p <<<"$version"
+ case "$part" in
+ major) p[0]=$((p[0]+1)); p[1]=0; p[2]=0 ;;
+ minor) p[1]=$((p[1]+1)); p[2]=0 ;;
+ patch) p[2]=$((p[2]+1)) ;;
+ *) echo "Invalid part '$part'"; exit 1 ;;
+ esac
+ echo "${p[0]}.${p[1]}.${p[2]}"
+}
+
+FORCE_MAJOR=false
+for arg in "$@"; do
+ case $arg in
+ --major) FORCE_MAJOR=true ;;
+ *) echo "Ignoring unknown arg: $arg" ;;
+ esac
+done
+
+LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
+RELEASE_TYPE="minor"
+
+if [ "$FORCE_MAJOR" = true ]; then
+ RELEASE_TYPE="major"
+else
+ if [ -z "$LATEST_TAG" ]; then
+ RELEASE_TYPE="minor"
+ echo "[test-release] No prior tag found -> default minor."
+ else
+ SUBJECTS=$(git log --no-merges --format=%s "${LATEST_TAG}..HEAD")
+ if echo "$SUBJECTS" | grep -Eiq '^feat(\([^)]+\))?: '; then
+ RELEASE_TYPE="minor"
+ elif echo "$SUBJECTS" | grep -Eiq '^fix(\([^)]+\))?: '; then
+ RELEASE_TYPE="patch"
+ else
+ echo "[test-release] No feat/fix since ${LATEST_TAG}. Would abort real release."
+ RELEASE_TYPE="none"
+ fi
+ fi
+fi
+
+if [ "$RELEASE_TYPE" = "none" ]; then
+ echo "[test-release] Exiting (nothing to release)."
+ exit 0
+fi
+
+NEW_VERSION=$(increment_version "$CURRENT_VERSION" "$RELEASE_TYPE")
+echo "[test-release] Detected release type: $RELEASE_TYPE"
+echo "[test-release] Proposed new version: $NEW_VERSION"
+
+LATEST_REVISION=$(git rev-parse --short HEAD)
+echo "[test-release] Current revision: $LATEST_REVISION"
+
+echo "[test-release] Simulating changelog generation..."
+
+CLIFF_BIN="git-cliff"
+if ! command -v git-cliff &>/dev/null && command -v git &>/dev/null; then
+ CLIFF_BIN="git cliff"
+fi
+
+CLIFF_TOKEN_OPT=""
+if command -v gh &>/dev/null; then
+ TOKEN=$(gh auth token 2>/dev/null || true)
+ if [ -n "${TOKEN}" ]; then
+ CLIFF_TOKEN_OPT="--github-token=${TOKEN}"
+ fi
+fi
+
+if command -v git-cliff &>/dev/null; then
+ CHANGELOG_FRAGMENT=$(git-cliff ${CLIFF_TOKEN_OPT} --tag "v${NEW_VERSION}" --unreleased || true)
+else
+ CHANGELOG_FRAGMENT=""
+fi
+
+if [ -z "${CHANGELOG_FRAGMENT}" ]; then
+ echo "Warning: git-cliff produced empty output (maybe no new conventional commits)."
+else
+ echo "----------- BEGIN CHANGELOG PREVIEW (v${NEW_VERSION}) -----------"
+ echo "${CHANGELOG_FRAGMENT}"
+ echo "------------ END CHANGELOG PREVIEW ------------------------------"
+fi
+
+echo
+echo "[test-release] WOULD UPDATE FILES:"
+echo " .version -> ${NEW_VERSION}"
+echo " frontend/package.json version -> ${NEW_VERSION}"
+echo " .revision -> ${LATEST_REVISION}"
+echo " CHANGELOG.md (prepend new section)"
+echo "[test-release] WOULD COMMIT: release: ${NEW_VERSION}"
+echo "[test-release] WOULD TAG: v${NEW_VERSION}"
+echo "[test-release] WOULD CREATE DRAFT GH RELEASE"
+echo
+echo "[test-release] Dry run complete. No changes were made."
\ No newline at end of file