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

Add a script to automate building the CHANGELOG #56

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Config. It’s for thoughtbot employees.

1. Make sure you’re on the `main` branch with a clean working directory.

1. Update the [changelog][changelog], following the guidelines from
[keep a changelog][keep-a-changelog]
1. Run `bin/build-changelog` to put together the entries for the CHANGELOG. You
might wish to edit it or make other minor changes. Then, you can update
`CHANGELOG.md`.

1. Run `npm version [major | minor | patch] --force`

Expand Down
24 changes: 24 additions & 0 deletions bin/build-changelog
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
Loading