blob: 07d59dd63e4f78ff8d735fc7eb229a0d4b776663 [file] [log] [blame]
name: Create Release
on:
push:
tags:
- 'v*.*.*'
- 'KorAP-Tokenizer-*'
jobs:
release:
name: Create GitHub release from Changelog
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- name: Determine version from tag
id: version
run: |
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
VERSION="${VERSION#KorAP-Tokenizer-}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Extract release notes from CHANGELOG.md
id: changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
ESCAPED_VERSION=$(printf '%s' "$VERSION" | sed 's/[.[\*^$()+?{|]/\\&/g')
awk -v ver="$ESCAPED_VERSION" '
BEGIN { found = 0 }
/^## / {
if (found) exit
if ($0 ~ "^## " ver "([^0-9.]|$)") { found = 1 }
next
}
found { print }
' CHANGELOG.md | sed -e '/./,$!d' -e ':a' -e '/^\n*$/{$d;N;ba' -e '}' > release_notes.md
if [ ! -s release_notes.md ]; then
echo "::error::No CHANGELOG.md section found for version $VERSION (tag $GITHUB_REF_NAME)"
exit 1
fi
echo "Release notes for $VERSION:"
cat release_notes.md
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
body_path: release_notes.md
draft: false
prerelease: false