Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve script to prepare changelog for release #2657

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions dev/add-shortlog.sh → dev/prepare-release-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
set -e
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../

# Get the current date in the format YYYY-MM-DD
current_date=$(date +"%Y-%m-%d")

tags=$(git tag --sort=-v:refname)
new_version=$1
old_version=$(echo "$tags" | sed -n '1p')
Expand All @@ -14,8 +17,8 @@ thanks="\n### Thanks to our contributors\n\nWe would like to give our special th
# Check if the token exists in the markdown file
if ! grep -q "$token" doc/source/ref-changelog.md; then
# If the token does not exist in the markdown file, append the new content after the version
awk -v version="$new_version" -v text="$thanks" \
'{print} $0 ~ "## " version {print text}' doc/source/ref-changelog.md > temp.md && mv temp.md doc/source/ref-changelog.md
awk -v version="$new_version" -v date="$current_date" -v text="$thanks" \
'{ if ($0 ~ "## Unreleased") print "## " version " (" date ")\n" text; else print $0 }' doc/source/ref-changelog.md > temp.md && mv temp.md doc/source/ref-changelog.md
else
# If the token exists, replace the line containing the token with the new shortlog
awk -v token="$token" -v newlog="$shortlog $token" '{ if ($0 ~ token) print newlog; else print $0 }' doc/source/ref-changelog.md > temp.md && mv temp.md doc/source/ref-changelog.md
Expand Down