Skip to content

Commit

Permalink
chore: define new job in release process for updating header of chang…
Browse files Browse the repository at this point in the history
…elog
  • Loading branch information
AgustinBettati committed Apr 10, 2024
1 parent 5a7d85c commit 0703d2b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
20 changes: 19 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,27 @@ jobs:
atlas_cloud_env: "qa"
ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || github.ref }}

update-changelog-header:
needs: [ run-qa-acceptance-tests ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
fetch-depth: 0
- run: ./scripts/update-changelog-header-for-release.sh ${{inputs.version_number}}
- run: |
if [[ $(git status --porcelain) ]]; then
MSG="Update CHANGELOG.md header for ${{inputs.version_number}} release"
git config --local user.email [email protected]
git config --local user.name changelogbot
git add CHANGELOG.md
git commit -m "$MSG"
git push
fi
release:
runs-on: ubuntu-latest
needs: [ validate-version-input, run-qa-acceptance-tests ]
needs: [ validate-version-input, run-qa-acceptance-tests, update-changelog-header ]
if: ${{ always() && needs.validate-version-input.result == 'success' && (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') }}
steps:
- name: Checkout
Expand Down
25 changes: 25 additions & 0 deletions scripts/update-changelog-header-for-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail

: "${1?"Tag of new release must be provided"}"

CHANGELOG_FILE_PATH=CHANGELOG.md
RELEASE_TAG=$1
RELEASE_NUMBER=$(echo "${RELEASE_TAG}" | tr -d v)

# exit out if changelog already has the header updated with version number being released.
if grep -q "## $RELEASE_NUMBER (" "$CHANGELOG_FILE_PATH"; then
echo "CHANGELOG already has a header defined for $RELEASE_NUMBER, no changes made to changelog."
exit 0
fi

# Prepare the new version header
TODAYS_DATE=$(date "+%B %d, %Y") # Format the date as "Month day, Year"
NEW_RELEASE_HEADER="## $RELEASE_NUMBER ($TODAYS_DATE)"

# Insert the new version header after the "(Unreleased)" line
sed -i "" -e "/(Unreleased)/a \\
\\
$NEW_RELEASE_HEADER" $CHANGELOG_FILE_PATH

echo "Changelog updated successfully defining header for new $RELEASE_TAG release."

0 comments on commit 0703d2b

Please sign in to comment.