From 2e1b2bf8158459981e705a51dd4bcc16bed8bd63 Mon Sep 17 00:00:00 2001 From: Owen Littlejohns Date: Tue, 23 Sep 2025 16:18:24 -0400 Subject: [PATCH] TRT-315: Append commit history to release notes. --- .github/workflows/publish_to_pypi.yml | 4 +++- .github/workflows/run_tests.yml | 2 +- CHANGELOG.md | 8 ++++++++ bin/extract-release-notes.sh | 25 ++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml index 11db4ac..a08ac34 100644 --- a/.github/workflows/publish_to_pypi.yml +++ b/.github/workflows/publish_to_pypi.yml @@ -22,7 +22,9 @@ jobs: steps: - name: Checkout earthdata-hashdiff repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 + with: + fetch-depth: 0 - name: Set up Python 3.12 uses: actions/setup-python@v5 diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 9845d42..cefc439 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout earthdata-hashdiff repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 diff --git a/CHANGELOG.md b/CHANGELOG.md index b6db7b3..03f9053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [vX.Y.Z] - Unreleased + +### Changed + +- Release notes published in GitHub should now also contain a list of commit + messages since the last release. These will omit commits from pre-commit-ci. + ## [v1.1.0] - 2025-08-19 ### Added @@ -46,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - pre-commit CI/CD checks, including mypy and ruff. - CI/CD workflows as GitHub actions. +[v1.1.0]: https://github.com/nasa/earthdata-hashdiff/releases/tag/1.1.0 [v1.0.2]: https://github.com/nasa/earthdata-hashdiff/releases/tag/1.0.2 [v1.0.1]: https://github.com/nasa/earthdata-hashdiff/releases/tag/1.0.1 [v1.0.0]: https://github.com/nasa/earthdata-hashdiff/releases/tag/1.0.0 diff --git a/bin/extract-release-notes.sh b/bin/extract-release-notes.sh index 448df0f..114d7fd 100755 --- a/bin/extract-release-notes.sh +++ b/bin/extract-release-notes.sh @@ -9,6 +9,7 @@ # 2024-01-03: Copied from HOSS repository to the Swath Projector. # 2024-01-23: Copied and modified from Swath Projector repository to HyBIG. # 2025-07-15: Copied and modified from HyBIG to earthdata-hashdiff. +# 2025-09-22: Append git commit messages to release notes. # ############################################################################### @@ -28,5 +29,27 @@ LINK_PATTERN="^\[.*\]:.*https://github.com/nasa" # VERSION_PATTERN result=$(awk "/$VERSION_PATTERN/{c++; if(c==2) exit;} c==1" "$CHANGELOG_FILE") +# Get all commit messages since the last release (marked with a git tag). If +# there are no tags, get the full commit history of the repository. +if [[ $(git tag) ]] +then + # There are git tags, so get the most recent one + GIT_REF=$(git describe --tags --abbrev=0) +else + # There are not git tags, so get the initial commit of the repository + GIT_REF=$(git rev-list --max-parents=0 HEAD) +fi + +# Retrieve the title line of all commit messages since $GIT_REF, filtering out +# those from the pre-commit-ci[bot] author and any containing the string +# "nasa/pre-commit-ci-update-config", which may result from merge commits. +GIT_COMMIT_MESSAGES=$(git log --oneline --format="%s" --perl-regexp --author='^(?!pre-commit-ci\[bot\]).*$' --grep="nasa\/pre-commit-ci-update-config" --invert-grep ${GIT_REF}..HEAD) + +# Append git commit messages to the release notes: +if [[ ${GIT_COMMIT_MESSAGES} ]] +then + result+="\n\n## Commits\n\n${GIT_COMMIT_MESSAGES}" +fi + # Print the result -echo "$result" | grep -v "$VERSION_PATTERN" | grep -v "$LINK_PATTERN" +echo -e "$result" | grep -v "$VERSION_PATTERN" | grep -v "$LINK_PATTERN"