-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
eldertek
committed
Dec 28, 2024
1 parent
52562f6
commit 84b2bd2
Showing
6 changed files
with
172 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
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 (everything between the first and second '## ') | ||
LATEST=$(sed -n '1,/^## /{/^## /p; /^## /q}' CHANGELOG.md | sed '1d') | ||
# Extract current version number | ||
CURRENT_VERSION=$(echo "$LATEST" | head -n 1 | sed 's/## \([0-9.]*\).*/\1/') | ||
# Find previous version by getting the second version header | ||
PREVIOUS_VERSION=$(sed -n '/^## [0-9]/{n;/^## /s/^## \([0-9.]*\).*/\1/p;q}' CHANGELOG.md) | ||
# 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 Changes | ||
${LATEST} | ||
# Full Changelog | ||
[Compare v${previous_version}...v${current_version}](${COMPARE_URL})" | ||
# Get release ID | ||
RELEASE_ID=$(gh api \ | ||
--method GET \ | ||
-H "Accept: application/vnd.github+json" \ | ||
/repos/${{ github.repository }}/releases/tags/${{ github.event.release.tag_name }} \ | ||
| jq .id) | ||
# Update release notes | ||
gh api \ | ||
--method PATCH \ | ||
-H "Accept: application/vnd.github+json" \ | ||
/repos/${{ github.repository }}/releases/$RELEASE_ID \ | ||
-f body="$BODY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters