59 lines
2.7 KiB
YAML
59 lines
2.7 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 @-
|
|
|
|
- name: Trigger Komodo build
|
|
env:
|
|
KOMODO_WEBHOOK_URL: https://komodo.urania.dev/listener/github/build/urania_builder_nadir
|
|
KOMODO_WEBHOOK_SECRET: ${{ secrets.KOMODO_WEBHOOK_SECRET }}
|
|
run: |
|
|
# Komodo's GitHub listener requires `ref` + a matching HMAC signature.
|
|
BODY=$(jq -nc --arg sha "$GITHUB_SHA" \
|
|
'{ref:"refs/heads/main", after:$sha,
|
|
repository:{full_name:"${{ github.repository }}",
|
|
clone_url:"${{ github.server_url }}/${{ github.repository }}.git"}}')
|
|
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$KOMODO_WEBHOOK_SECRET" -hex | awk '{print $NF}')
|
|
curl -fsSL -X POST "$KOMODO_WEBHOOK_URL" \
|
|
-H "Content-Type: application/json" \
|
|
-H "X-GitHub-Event: push" \
|
|
-H "X-Hub-Signature-256: sha256=$SIG" \
|
|
-d "$BODY"
|