Skip to content

Commit

Permalink
Automatically update GitHub release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
flenny authored May 6, 2024
2 parents 923590a + 7a2bd31 commit b0b804b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

[CHANGELOG.md]
end_of_line = lf

[*.{cs,sql,config,csx,fsx}]
; https://github.com/editorconfig/editorconfig/issues/297
charset = utf-8-bom
Expand Down
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@
*.svg text eol=lf

# *nix shell scripts always use LF (see .editorconfig)
*.sh eol=lf
*.sh text eol=lf
CHANGELOG.md text eol=lf
11 changes: 10 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

patch-changelog:
runs-on: ubuntu-latest
name: Patch CHANGELOG.md
name: Patch CHANGELOG.md and update GitHub release notes

steps:
- name: Checkout repository
Expand All @@ -74,6 +74,15 @@ jobs:
run: |
echo GIT_BRANCH_NAME=mark-version-${TAG_NAME#v}-as-released >> $GITHUB_ENV
echo GIT_COMMIT_MESSAGE=Mark version ${TAG_NAME#v} as released >> $GITHUB_ENV
echo RELEASE_ID=$(gh api -H "Accept: application/vnd.github+json" /repos/${GITHUB_REPOSITORY}/releases/tags/${TAG_NAME} | jq '.id') >> $GITHUB_ENV
- name: Get changelog for this specific release and update release notes
run: |
gh api \
--method PATCH \
--header "Accept: application/vnd.github+json" \
/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID} \
-f body="$(./get-changelog.sh)"
- name: Checkout new branch and patch changelog
run: |
Expand Down
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

## [Unreleased]

### Added

- When releasing a GitHub pre-release, the release notes are automatically updated with the corresponding entries from the `CHANGELOG.md` file.

## v1.0.87 - 2024-04-26

### Added

- Add licensing information to the about page
- Add licensing information to the about page.

### Changed

- Sort delivery mandates alphabetically
- Sort delivery mandates alphabetically.

### Fixed

- Spatial extent in STAC browser
- Spatial extent in STAC browser.
23 changes: 23 additions & 0 deletions get-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# This script gets all changelog entries from CHANGELOG.md since last release.

set -e

tempDir="$(mktemp -d)"
tempFile=$tempDir/gh_release_notes.md

# Get changelog entries since last release
cat CHANGELOG.md | \
grep -Pazo '(?s)(?<=\#{2} \[Unreleased\]\n{2}).*?(?=\n\#{2} v|$)' \
> $tempFile

# Improve readability and add some icons
sed -i -E 's/(###) (Added)/\1 🚀 \2/' $tempFile
sed -i -E 's/(###) (Changed)/\1 🔨 \2/' $tempFile
sed -i -E 's/(###) (Fixed)/\1 🐛 \2/' $tempFile
sed -i 's/\x0//g' $tempFile

cat $tempFile

# Cleanup temporary files
trap 'rm -rf -- "$tempDir"' EXIT

0 comments on commit b0b804b

Please sign in to comment.