Files
nadir-webui/.gitea/workflows/release.yaml
T
2026-06-26 10:40:34 +02:00

42 lines
1.8 KiB
YAML

# Auto-create a Gitea release when a vX.Y.Z tag is pushed.
# Image build/push is handled by Komodo, so this only cuts the release.
name: release
on:
push:
tags:
- "v*"
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # need full history to diff against the previous tag
- name: Create release from tag
run: |
TAG="${{ github.ref_name }}"
PREV=$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || true)
RANGE="${PREV:+$PREV..}$TAG"
LOG=$(git log --pretty='format:%s|%h' "$RANGE")
group() { echo "$LOG" | awk -F'|' -v re="$1" '$1 ~ re { sub(re, "", $1); printf "- %s (%s)\n", $1, $2 }'; }
BREAKING=$(group '^[a-z]+[^:]*!: ')
FEATS=$(group '^feat[^:]*: ')
FIXES=$(group '^fix[^:]*: ')
OTHER=$(echo "$LOG" | awk -F'|' '$1 !~ /^(feat|fix)[^:]*!?: / { printf "- %s (%s)\n", $1, $2 }')
BODY=""
[ -n "$BREAKING" ] && BODY="$BODY### Breaking"$'\n'"$BREAKING"$'\n\n'
[ -n "$FEATS" ] && BODY="$BODY### Features"$'\n'"$FEATS"$'\n\n'
[ -n "$FIXES" ] && BODY="$BODY### Fixes"$'\n'"$FIXES"$'\n\n'
[ -n "$OTHER" ] && BODY="$BODY### Other"$'\n'"$OTHER"$'\n\n'
[ -n "$PREV" ] && BODY="$BODY**Full changelog:** ${{ github.server_url }}/${{ github.repository }}/compare/$PREV...$TAG"
jq -n --arg tag "$TAG" --arg body "$BODY" \
'{tag_name:$tag, name:$tag, body:$body}' \
| curl -fsSL -X POST "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
--data @-