Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions .github/workflows/release-plz.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# On push to main: if there are feat/fix/hotfix commits since last tag, open a release PR (one commit + changelog + tag on PR branch). No crates.io.

name: Release

on:
push:
branches: [main]

jobs:
release:
name: Release PR + tag
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Should release?
id: plan
run: |
range="HEAD"
tag=$(git describe --tags --abbrev=0 2>/dev/null) && range="${tag}..HEAD"
log=$(git log "$range" --pretty=format:"%s%n%b")
if ! echo "$log" | grep -qE '^(feat|fix|hotfix)(\([^)]*\))?(!)?:'; then
echo "releasable=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "releasable=true" >> "$GITHUB_OUTPUT"
if echo "$log" | grep -qE 'BREAKING CHANGE|^[^:]+!:'; then
level=major
elif echo "$log" | grep -qE '^feat(\([^)]*\))?:'; then
level=minor
else
level=patch
fi
echo "level=$level" >> "$GITHUB_OUTPUT"
ver=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
IFS=. read -r ma mi pa <<< "$ver"
case "$level" in
major) echo "new_version=$((ma+1)).0.0" >> "$GITHUB_OUTPUT" ;;
minor) echo "new_version=${ma}.$((mi+1)).0" >> "$GITHUB_OUTPUT" ;;
*) echo "new_version=${ma}.${mi}.$((pa+1))" >> "$GITHUB_OUTPUT" ;;
esac

- name: Changelog
if: steps.plan.outputs.releasable == 'true'
uses: orhun/git-cliff-action@v4
with:
config: git-cliff.toml
args: --unreleased --tag v${{ steps.plan.outputs.new_version }} --prepend CHANGELOG.md
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}

- name: cargo-release
if: steps.plan.outputs.releasable == 'true'
uses: taiki-e/install-action@v2
with:
tool: cargo-release

- name: Open PR
if: steps.plan.outputs.releasable == 'true'
id: pr
uses: cargo-bins/release-pr@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ steps.plan.outputs.level }}
pr-label: release

- name: Tag PR branch
if: steps.plan.outputs.releasable == 'true' && steps.pr.outputs['pr-branch'] != ''
run: |
git fetch origin ${{ steps.pr.outputs['pr-branch'] }}
git checkout ${{ steps.pr.outputs['pr-branch'] }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "v${{ steps.plan.outputs.new_version }}"
git push origin "v${{ steps.plan.outputs.new_version }}"
42 changes: 42 additions & 0 deletions git-cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# git-cliff config for conventional commits (feat, fix, hotfix, etc.)
# https://git-cliff.org/docs/configuration

[changelog]
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [Unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }}
{% endfor %}
{% endfor %}
"""
trim = true
render_always = true

[git]
conventional_commits = true
filter_unconventional = true
commit_parsers = [
{ message = "^feat", group = "Added" },
{ message = "^fix", group = "Fixed" },
{ message = "^hotfix", group = "Fixed" },
{ message = "^doc", group = "Documentation" },
{ message = "^perf", group = "Performance" },
{ message = "^refactor", group = "Changed" },
{ message = "^style", group = "Changed" },
{ message = "^test", group = "Testing" },
{ message = "^chore\\(release\\)", skip = true },
{ message = "^chore", group = "Miscellaneous" },
{ message = "^ci", group = "Miscellaneous" },
{ message = "^revert", group = "Reverted" },
{ message = ".*", group = "Other" },
]
filter_commits = false
sort_commits = "oldest"
26 changes: 0 additions & 26 deletions release-plz.toml

This file was deleted.

15 changes: 15 additions & 0 deletions release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# cargo-release: no crates.io publish, tag only, single release commit.
# Changelog + compose image tag are updated in scripts/release-hook.sh (git-cliff + major.minor).

allow-branch = ["main"]
publish = false
tag = true
tag-name = "v{{version}}"

# Sync package.json version (compose.yaml is updated in pre-release-hook to use major.minor tag).
pre-release-replacements = [
{ file = "web/package.json", search = '"version": "[^"]*"', replace = '"version": "{{version}}"' },
]

# Update CHANGELOG with git-cliff and compose.yaml image tag to major.minor.
pre-release-hook = ["bash", "scripts/release-hook.sh"]
18 changes: 18 additions & 0 deletions scripts/release-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Pre-release hook for cargo-release: update compose.yaml image tag to major.minor.
# CHANGELOG is generated in CI by orhun/git-cliff-action before release-pr runs.

set -euo pipefail
cd "${WORKSPACE_ROOT:-.}"

if [[ "${DRY_RUN:-false}" == "true" ]]; then
echo "release-hook: DRY_RUN, skipping compose update"
exit 0
fi

# compose.yaml: image tag = major.minor only (e.g. 0.1 for 0.1.2)
IMAGE_TAG=$(echo "$NEW_VERSION" | sed -E 's/^([0-9]+\.[0-9]+)\.[0-9]+/\1/')
sed -i.bak "s|image: mi7chal/netweave:[^[:space:]]*|image: mi7chal/netweave:${IMAGE_TAG}|" compose.yaml
rm -f compose.yaml.bak

echo "release-hook: compose.yaml updated for v${NEW_VERSION} (image tag: ${IMAGE_TAG})"
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@
"vite": "^7.2.4"
},
"packageManager": "pnpm@9.15.9+sha512.68046141893c66fad01c079231128e9afb89ef87e2691d69e4d40eee228988295fd4682181bae55b58418c3a253bde65a505ec7c5f9403ece5cc3cd37dcf2531"
}
}
Loading