name: GitHub Release
on:
push:
tags:
- 'v*'
workflow_call:
inputs:
tag:
description: Tag to release (e.g. v0.14.0)
required: true
type: string
permissions:
contents: write
jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
env:
TAG: ${{ inputs.tag || github.ref_name }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
- name: Extract changelog section for this tag
id: notes
run: |
VERSION=${TAG#v}
# Pull lines between '## [VERSION]' and the next '## [' heading.
awk -v ver="$VERSION" '
$0 ~ "^## \\[" ver "\\]" { capture=1; next }
capture && /^## \[/ { exit }
capture { print }
' CHANGELOG.md > release-notes.md
if [ ! -s release-notes.md ]; then
echo "No changelog section found for [$VERSION]" >&2
exit 1
fi
echo "Release notes for $VERSION:"
cat release-notes.md
- name: Create release
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b with:
tag_name: ${{ env.TAG }}
name: ${{ env.TAG }}
body_path: release-notes.md