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

ci: add steps to auto update changelog in kickoff PR #32

Merged
merged 1 commit into from
Oct 3, 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
25 changes: 25 additions & 0 deletions .github/scripts/group-commit-message.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/awk -f

function add_to_group(key, value) {
groups[key] = groups[key] "- " value "\n"
}

{
if (NF > 0) { # Skip empty lines
if (tolower($1) == "feat:") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work with messages with a slightly different format, such as feat(<something>): <message>, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this only works for feat:. As this repo is only for the apollo extension, we don't have other components.

add_to_group("Features:", substr($0, index($0, $2)))
} else if (tolower($1) == "fix:") {
add_to_group("Fixes:", substr($0, index($0, $2)))
} else {
next
}
}
}

END {
for (group in groups) {
print "\n### " group
print groups[group]
}
print "\n"
}
30 changes: 29 additions & 1 deletion .github/workflows/kick-off-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Checkout Code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: main
fetch-depth: 0

- name: Bump versions to ${{ env.RELEASE_VERSION }}
run: |
Expand All @@ -56,6 +56,34 @@ jobs:
git push origin HEAD
shell: bash

- name: Generate CHANGELOG
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
shell: bash
run: |
LOGS=$(git log --pretty=format:%s origin/release..HEAD | awk -F '\n' '{print $1}')
GROUPED_LOGS=$(echo $LOGS | ./.github/scripts/group-commit-message.awk)
awk -v date=$(date +"%Y-%m-%d") \
-v version="$RELEASE_VERSION" '
NR == 2 {
print "\n"
print "## " version " - (" date ")"
while (getline line < "/dev/stdin") {
print line
}
next
}
{print}
' CHANGELOG.md < <(echo "$GROUPED_LOGS") > temp && mv temp CHANGELOG.md

- name: Create CHANGELOG commit
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
run: |
git add CHANGELOG.md
git commit -m "chore: update CHANGELOG for $RELEASE_VERSION"
git push origin HEAD

- name: Create Pull Request
env:
GH_TOKEN: ${{ github.token }}
Expand Down