From 1104faeee3077625a4fce687a1b55ecab0e2685a Mon Sep 17 00:00:00 2001 From: sherwinski Date: Fri, 15 May 2026 16:01:30 -0700 Subject: [PATCH] ci: fix Release workflow failing on empty changelog pipelines The bump-version composite action's changelog pipelines fail under `bash -e -o pipefail` whenever `grep` finds no matching lines and exits 1, which aborts the step before the `if [ -z "$ENTRIES" ]` fallbacks can run. This caused the Release (v3) workflow to fail at the `echo "$ENTRIES" > /tmp/changelog_entries.txt` line for the v3.9.0 release. Two compounding causes: 1. The `bump` job's checkout uses default `fetch-depth: 1`/`fetch-tags: false`, so `git describe` finds no tags and `git log HEAD --merges` is empty (squash merges have one parent and don't show under `--merges`). 2. `grep -v '^$'` and `grep -iv '^release\|^chore(release)'` exit 1 on empty input, which propagates through `pipefail` and trips `set -e`. Fix: - release.yml / release-v2.yml: add `fetch-depth: 0` and `fetch-tags: true` to the bump job's checkout so the changelog script has full history. - bump-version/action.yml: append `|| true` to both changelog pipelines so empty results fall through to the existing fallbacks, and switch the file write to `printf` for safer multi-line output. --- .github/actions/bump-version/action.yml | 12 ++++++------ .github/workflows/release-v2.yml | 2 ++ .github/workflows/release.yml | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/actions/bump-version/action.yml b/.github/actions/bump-version/action.yml index 660127f..1f5bf98 100644 --- a/.github/actions/bump-version/action.yml +++ b/.github/actions/bump-version/action.yml @@ -24,28 +24,28 @@ runs: RANGE="HEAD" fi - # Extract changelog lines from merge commit PR titles (strip conventional prefix for readability) + # `|| true` keeps an empty pipeline (e.g. grep finding no matches) from + # tripping `set -e -o pipefail` before the fallbacks below can run. ENTRIES=$(git log "$RANGE" --merges --pretty=format:"%s" \ | sed -n 's/^Merge pull request #[0-9]* from .*//p; s/^.*: //p' \ | grep -v '^$' \ | grep -iv '^release\|^chore(release)' \ | head -20 \ - | sed 's/^/- /') + | sed 's/^/- /' || true) if [ -z "$ENTRIES" ]; then - # Fallback: use non-merge commit subjects + # Fallback: use non-merge commit subjects (covers squash merges) ENTRIES=$(git log "$RANGE" --no-merges --pretty=format:"%s" \ | grep -v '^chore(release)' \ | head -20 \ - | sed 's/^/- /') + | sed 's/^/- /' || true) fi if [ -z "$ENTRIES" ]; then ENTRIES="- See release notes" fi - # Write to file to preserve newlines across steps - echo "$ENTRIES" > /tmp/changelog_entries.txt + printf '%s\n' "$ENTRIES" > /tmp/changelog_entries.txt - name: Bump version shell: bash diff --git a/.github/workflows/release-v2.yml b/.github/workflows/release-v2.yml index 4559830..d2a553f 100644 --- a/.github/workflows/release-v2.yml +++ b/.github/workflows/release-v2.yml @@ -26,6 +26,8 @@ jobs: with: ref: ${{ needs.prep.outputs.release_branch }} token: ${{ github.token }} + fetch-depth: 0 + fetch-tags: true - uses: ./.github/actions/bump-version with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 44bd3e3..ff83a8f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,8 @@ jobs: with: ref: ${{ needs.prep.outputs.release_branch }} token: ${{ github.token }} + fetch-depth: 0 + fetch-tags: true - uses: ./.github/actions/bump-version with: