diff --git a/.github/workflows/build-workflow.yml b/.github/workflows/build-workflow.yml index 4260f59e534..e3a4aba0bd1 100644 --- a/.github/workflows/build-workflow.yml +++ b/.github/workflows/build-workflow.yml @@ -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: diff --git a/ci/changelog/changelog.sh b/ci/changelog/changelog.sh index 4f0102d15f5..017c0b13012 100755 --- a/ci/changelog/changelog.sh +++ b/ci/changelog/changelog.sh @@ -10,6 +10,8 @@ $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 @@ -17,6 +19,9 @@ 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) @@ -27,6 +32,7 @@ EOT FROM_VERSION= TO_VERSION= +FROM_TAGS=0 while [ $# -gt 0 ]; do case "$1" in @@ -34,6 +40,9 @@ while [ $# -gt 0 ]; do usage exit 0 ;; + --from-tags) + FROM_TAGS=1 + ;; --*|-*) echo "Unknown flag" >&2 usage @@ -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