fix(release): declare SECTION_TITLES as associative array#48
Merged
dawright22 merged 2 commits intoAzure:mainfrom May 5, 2026
Merged
fix(release): declare SECTION_TITLES as associative array#48dawright22 merged 2 commits intoAzure:mainfrom
dawright22 merged 2 commits intoAzure:mainfrom
Conversation
Without 'declare -A', SECTION_TITLES=([feat]=...) is parsed as an indexed array, so bash evaluates the keys as arithmetic expressions. Under 'set -u' the lookup of unset names like 'feat' fails with 'unbound variable' and the workflow exits 1 before generating release notes. Also collapse 'declare -A SECTIONS' + reassignment into a single 'declare -A SECTIONS=(...)' for symmetry with SECTION_TITLES. Verified locally on bash 5.3.9 (homebrew): - Original form: 'feat: unbound variable' under set -euo pipefail. - Fixed form: parses sample 'feat(plugin): ...' commit and emits '### Features' with the formatted bullet line. Repro of the failure: https://github.com/Azure/git-ape/actions/runs/25362438095
On workflow_dispatch with versions already aligned, the prior
'Commit version bump' step is skipped and the tag is never created
locally. The release-notes step then ran 'git log v0.0.1' against a
non-existent ref, silently producing an empty changelog.
Verified locally with act:
act workflow_dispatch -W .github/workflows/git-ape-release.yml \
-e event.json -s GITHUB_TOKEN=... \
-P ubuntu-latest=catthehacker/ubuntu:act-latest
After the fix, the release notes step emits the full conventional-
commit-grouped changelog walking from the first commit through HEAD.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the failure in run #25362438095 and a second latent bug discovered when re-running the workflow locally with
act.Bug 1 —
feat: unbound variableIn the
Generate release notesstep,SECTION_TITLESwas declared withoutdeclare -A:SECTION_TITLES=( [feat]="Features" ... )Without
declare -A, bash treats this as an indexed array assignment, so the keys[feat],[fix]etc. are evaluated as arithmetic expressions. Underset -u, the lookup of unset names likefeatfails withunbound variableand the script exits before any release notes are written.Fix: Add
declare -AtoSECTION_TITLES. Also collapsedSECTIONSinto a singledeclare -A SECTIONS=(...)for symmetry.Bug 2 — empty changelog on
workflow_dispatch(caught locally withact)After Bug 1 was fixed, running the workflow locally surfaced a second issue:
On
workflow_dispatchwith versions already aligned,bump.outputs.changed == 'false', so theCommit version bumpstep is skipped — meaning the tag is never created locally. The release-notes step then rangit log v0.0.1against a non-existent ref, silently producing release notes with an empty changelog (just title + install footer).This would have shipped a vacuous v0.0.1 release without anyone noticing in CI, because:
git logruns inside process substitution (< <(git log ...)), which doesn't propagatepipefailgit describealready had a|| echo ""fallback, masking the missing refFix: Probe the ref with
git rev-parse --verifyand fall back toHEADwhen the tag does not yet exist:Verification
Bug 1 — bash repro
Reproduced locally on
bash 5.3.9(homebrew) — same major.minor as the GitHub Actions runner:declare -AonSECTION_TITLES)feat: unbound variable— exits 1declare -A SECTION_TITLES=(...))feat(plugin): ...commit and emits### Featureswith the formatted bulletBug 2 —
actend-to-endRe-ran the full workflow locally with
act:Before fix:
Generate release notessucceeds but emits empty changelog.After fix: full conventional-commit-grouped changelog walking from the first commit through HEAD, with sections for Features, Bug Fixes, Documentation, Other Changes, etc.
Excerpt from the local
actrun on the fixed branch:The
Create GitHub releasestep does fail inactwithgh: command not found, but that is a knownactlimitation (noghCLI in the container). It is unrelated to the fix and runs fine on real GitHub-hosted runners.actionlint -color .github/workflows/git-ape-release.ymlis clean.Next step
After merge, re-run Actions → Git-Ape: Plugin Release → workflow_dispatch with version
0.0.1to cut the first release.