Files
gedcom-to-markdown/.github/workflows/release.yml
AlexKucera 126600255f Adapts release workflow to accept semantic versions
Updates the release workflow to correctly identify semantic versions and removes the assumption of a 'v' prefix on release tags.
This change allows the workflow to trigger on any tag that follows the semantic versioning format *.*.*, providing greater flexibility in versioning schemes.
2025-11-02 20:10:01 +01:00

59 lines
1.5 KiB
YAML

name: Release
on:
push:
tags:
- '*.*.*'
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: |
# Extract version number from tag (no 'v' prefix)
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Extract changelog for this version
id: changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
# Extract the section for this version from CHANGELOG.md
# This captures everything between ## [VERSION] and the next ## [ or end of file
CHANGELOG=$(awk -v ver="$VERSION" '
/^## \['"$VERSION"'\]/ { found=1; next }
found && /^## \[/ { exit }
found { print }
' CHANGELOG.md)
# If changelog is empty, provide a default message
if [ -z "$CHANGELOG" ]; then
CHANGELOG="See [CHANGELOG.md](CHANGELOG.md) for details."
fi
# Write to output using heredoc to handle multiline content
{
echo 'notes<<EOF'
echo "$CHANGELOG"
echo EOF
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.version.outputs.version }}
body: ${{ steps.changelog.outputs.notes }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}