Skip to content

Release Notes

Release Notes #2

Workflow file for this run

name: Release Notes
on:
release:
types: [created]
jobs:
update-release-notes:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Extract latest changelog and version
id: extract_changelog
run: |
# Get the latest version section
LATEST=$(sed -n '1,/^## /{p}' CHANGELOG.md | head -n -1)
# Extract current version number (first line, remove everything except version)
CURRENT_VERSION=$(head -n 1 CHANGELOG.md | grep -oP '## \K[0-9]+\.[0-9]+\.[0-9]+')
# Get the second version number
PREVIOUS_VERSION=$(grep -oP '## \K[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md | head -n 2 | tail -n 1)
# Prepare the content for GitHub Actions
echo "latest<<EOF" >> $GITHUB_ENV
echo "$LATEST" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "current_version=$CURRENT_VERSION" >> $GITHUB_ENV
echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_ENV
- name: Update Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Combine latest release notes with comparison URL
REPO_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}"
COMPARE_URL="${REPO_URL}/compare/v${previous_version}...v${current_version}"
BODY="
${LATEST}
## Full Changelog
[Compare v${previous_version}...v${current_version}](${COMPARE_URL})"
# Get release ID and update it
gh api \
--method GET \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/releases/tags/${{ github.event.release.tag_name }} \
--jq .id \
| xargs -I {} gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/releases/{} \
-f body="$BODY"