diff --git a/.editorconfig b/.editorconfig index 4f8f79ce..e9711746 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/.gitattributes b/.gitattributes index 79531b9c..1b5239d4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a6c9c339..553299d3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 050a1f06..1d830bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/get-changelog.sh b/get-changelog.sh new file mode 100755 index 00000000..315596c7 --- /dev/null +++ b/get-changelog.sh @@ -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