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: changelog generation from tags and don't fail on errors #3044

Merged
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
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