52 lines
1.5 KiB
YAML
52 lines
1.5 KiB
YAML
name: GitHub Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Release tag (e.g. v0.1.0)'
|
|
required: true
|
|
|
|
concurrency:
|
|
group: github-release-${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
env:
|
|
VERSION: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ env.VERSION }}
|
|
|
|
- name: Extract release notes from CHANGELOG
|
|
id: notes
|
|
run: |
|
|
if awk -v ver="$VERSION" '
|
|
$0 ~ "^## \\[" ver "\\]" { found = 1; next }
|
|
found && /^## \[v/ { exit }
|
|
found { print }
|
|
' CHANGELOG.md > release-body.md && [ -s release-body.md ]; then
|
|
echo "use_changelog=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "use_changelog=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ env.VERSION }}
|
|
name: ${{ env.VERSION }}
|
|
body_path: ${{ steps.notes.outputs.use_changelog == 'true' && 'release-body.md' || '' }}
|
|
generate_release_notes: ${{ steps.notes.outputs.use_changelog != 'true' }}
|
|
draft: false
|
|
prerelease: false
|