Add workflow to create GitHub releases from CHANGELOG on tag push
Pushing a version tag (v*.*.* or KorAP-Tokenizer-*) now creates a
GitHub release whose notes are the matching CHANGELOG.md section.
Since update-zenodo.yml already listens on release:published, this
also triggers the Zenodo upload.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: Iac22f106ea6c64a14e851f5b9ffb8a906328eeea
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..07d59dd
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,55 @@
+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