-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to automate building the CHANGELOG (#56)
Taken from Administrate, this helps build a Markdown snippet of the changes since the last known tag, which gets linked to the PR which introduced it. In most cases you do need to do a bit of extra work, but the output can be copy and pasted into the `CHANGELOG.md` file. https://github.com/thoughtbot/administrate/blob/main/bin/build-changelog
- Loading branch information
1 parent
fb14d2c
commit 747e173
Showing
2 changed files
with
27 additions
and
2 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
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,24 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
if ! command -v gh > /dev/null; then | ||
echo "Please install the GitHub CLI: https://cli.github.com/" | ||
exit 1 | ||
fi | ||
|
||
last_release=$(git describe --tag --abbrev=0) | ||
|
||
revision_range="${last_release}..origin/main" | ||
commit_format="--pretty=tformat:%h %s" | ||
commits_since=$(git log --author="^(?!dependabot).*$" --perl-regexp "${revision_range}" "${commit_format}") | ||
|
||
echo "$commits_since" | while read -r line; do | ||
sha=$(echo "${line}" | awk '{print $1}') | ||
commit_message=$(echo "${line}" | awk '{print substr($0, index($0, " ")+1)}') | ||
|
||
pr_number=$(gh pr list --search "$sha" --state merged --json number --jq '.[].number') | ||
trimmed_commit=$(echo "${commit_message}"| sed "s/ (\#$pr_number)//g") | ||
|
||
echo "* ${trimmed_commit} (#${pr_number})" | ||
done |