ci: add Release workflow triggered by v* tags
Pushing a tag matching v* now creates / updates a GitHub release with install.sh and install.ps1 attached, plus auto-generated changelog (commit log between prev and current tag) and standard install snippets in the body. Idempotent: re-pushing a tag updates the existing release rather than failing. For routine patch releases this replaces the manual `gh release create` flow. For larger releases that need a hand-written narrative, you can still overwrite the body via `gh release edit` afterward.
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Resolve versions
|
||||
id: versions
|
||||
run: |
|
||||
tag="${GITHUB_REF_NAME}"
|
||||
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
|
||||
prev=$(git tag --sort=-version:refname | grep -v "^${tag}$" | head -n1)
|
||||
echo "prev=${prev}" >> "$GITHUB_OUTPUT"
|
||||
if [ -n "$prev" ]; then
|
||||
echo "range=${prev}..${tag}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "range=${tag}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Build release notes
|
||||
id: notes
|
||||
run: |
|
||||
tag="${{ steps.versions.outputs.tag }}"
|
||||
prev="${{ steps.versions.outputs.prev }}"
|
||||
range="${{ steps.versions.outputs.range }}"
|
||||
{
|
||||
echo "## Changes"
|
||||
echo
|
||||
if [ -n "$prev" ]; then
|
||||
git log --pretty='- %s (%h)' "$range"
|
||||
else
|
||||
git log --pretty='- %s (%h)' "$tag"
|
||||
fi
|
||||
echo
|
||||
echo "## Install"
|
||||
echo
|
||||
echo '**macOS / Linux:**'
|
||||
echo '```bash'
|
||||
echo "curl -fsSL https://github.com/${{ github.repository }}/releases/latest/download/install.sh | bash"
|
||||
echo '```'
|
||||
echo
|
||||
echo '**Windows (PowerShell):**'
|
||||
echo '```powershell'
|
||||
echo "irm https://github.com/${{ github.repository }}/releases/latest/download/install.ps1 | iex"
|
||||
echo '```'
|
||||
if [ -n "$prev" ]; then
|
||||
echo
|
||||
echo "**Full changelog:** https://github.com/${{ github.repository }}/compare/${prev}...${tag}"
|
||||
fi
|
||||
} > release-notes.md
|
||||
|
||||
- name: Create GitHub release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
tag="${{ steps.versions.outputs.tag }}"
|
||||
# Idempotent: if the release exists (e.g. tag was re-pushed), update it.
|
||||
if gh release view "$tag" >/dev/null 2>&1; then
|
||||
gh release edit "$tag" \
|
||||
--title "ClawGod $tag" \
|
||||
--notes-file release-notes.md
|
||||
gh release upload "$tag" install.sh install.ps1 --clobber
|
||||
else
|
||||
gh release create "$tag" install.sh install.ps1 \
|
||||
--title "ClawGod $tag" \
|
||||
--notes-file release-notes.md
|
||||
fi
|
||||
Reference in New Issue
Block a user