commit - a661165cc7bc169b44fc78c8f76d04e720826524
commit + d8ff7486b6a709a9f7ec76aa641095d9f15cb7df
blob - /dev/null
blob + e81a8279a202d1afa9fb4e088ec45c66d99f8321 (mode 644)
--- /dev/null
+++ cliff.toml
+[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/virittaa/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\\(deps\\)", group = "Dependencies" },
+ { message = "^chore", skip = true },
+ { 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"
blob - /dev/null
blob + a19044bb26872c4fd68183c0d350cdeb28693025 (mode 755)
--- /dev/null
+++ hack/release
+#!/usr/bin/env bash
+set -euo pipefail
+
+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
+
+# --- 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
+
+echo "releasing -> v$next"
+
+# --- update Cargo.toml ---
+
+sed -i "s/^version = .*/version = \"$next\"/" Cargo.toml
+cargo generate-lockfile
+git add Cargo.toml Cargo.lock
+
+# --- changelog ---
+
+git-cliff --tag "v$next" --output CHANGELOG.md
+sed -i -e :a -e '/^\s*$/{$d;N;ba' -e '}' CHANGELOG.md
+git add CHANGELOG.md
+
+git commit -m "chore: release v$next"
+
+# --- tag and push ---
+
+git tag "v$next"
+git push origin master --tags
+
+echo "released v$next successfully"