Skip to content

Commit

Permalink
Merge pull request #3044 from reubenmiller/ci-changelog-generate-from…
Browse files Browse the repository at this point in the history
…-tags

ci: changelog generation from tags and don't fail on errors
  • Loading branch information
reubenmiller authored Aug 1, 2024
2 parents 28a6221 + 2f26431 commit 2e038b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
just generate-changelog
if ! just generate-changelog --from-tags; then
echo "Warning: Failed to generate changelog, but it should not block a release" > _CHANGELOG.md
fi
- name: Release
uses: softprops/action-gh-release@v2
env:
Expand Down
16 changes: 16 additions & 0 deletions ci/changelog/changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ $0 [FROM_VERSION] [TO_VERSION]
Flags
--from-tags Detect from/to versions are detected
from the most recent two git tags (version sorted)
--help | -h Show this help
Examples
$0
# Generate the changelog since the last release
$0 --from-tags
# Generate the changelog from the latest official release (detected from git tags)
$0 1.1.1 HEAD
# Generate the changelog between version 1.1.1 and the current unreleased version (using the new version)
Expand All @@ -27,13 +32,17 @@ EOT

FROM_VERSION=
TO_VERSION=
FROM_TAGS=0

while [ $# -gt 0 ]; do
case "$1" in
--help|-h)
usage
exit 0
;;
--from-tags)
FROM_TAGS=1
;;
--*|-*)
echo "Unknown flag" >&2
usage
Expand Down Expand Up @@ -72,6 +81,13 @@ if [ -z "$GITHUB_TOKEN" ]; then
echo >&2
fi

# Lookup the from/to versions using git --tag (with version sorting)
if [ "$FROM_TAGS" = 1 ]; then
echo "Detecting from/to version from git tags" >&2
FROM_VERSION=$(git tag --list | sort -V | grep "^[0-9]" | tail -n2 | head -n1)
TO_VERSION=$(git tag --list | sort -V | grep "^[0-9]" | tail -n1)
fi

if [ -z "$FROM_VERSION" ]; then
FROM_VERSION=$(git-cliff --context --unreleased | jq -r '.[0].previous.version')
fi
Expand Down

0 comments on commit 2e038b5

Please sign in to comment.