Skip to content

Commit 2d07d6e

Browse files
fix: report new version when commit is false and no version files update
`outputs.version` is sourced from `cz version --project` after the bump. When `commit: false` is combined with a `version_provider` that does not write to any tracked file (notably `version_provider = "scm"`), the bump does not update any version file and does not create a git tag, so `cz version --project` keeps reporting the previous version. The action then exposes the old version on `outputs.version`, `outputs.next_version` and the major/minor variants, even though the bump command itself printed `bump: version X -> Y` correctly. Capture the next version with `cz bump --get-next` before running the actual bump (it is a calculation, no state change), and use it as a fallback when `cz version --project` still equals the previous version after the bump. Major/minor are derived from the same value so they match. Failures of `--get-next` (e.g. no bumpable commits) are tolerated and leave the existing behaviour untouched. Closes #94 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 338bbd8 commit 2d07d6e

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

entrypoint.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ fi
9494
if [[ $INPUT_MANUAL_VERSION ]]; then
9595
CZ_CMD+=("$INPUT_MANUAL_VERSION")
9696
fi
97+
98+
# Capture the would-be next version BEFORE running the actual bump.
99+
# This is used as a fallback for the version output when `cz version --project`
100+
# does not reflect the bump (e.g. version_provider=scm combined with
101+
# commit:false, where neither version files nor git tags are updated).
102+
# Failures (no bumpable commits, etc.) are tolerated and produce an empty value.
103+
NEXT_REV_PRE="$("${CZ_CMD[@]}" --get-next 2>/dev/null || true)"
104+
97105
if [[ $INPUT_CHANGELOG_INCREMENT_FILENAME ]]; then
98106
CZ_CMD+=('--changelog-to-stdout')
99107
echo "${CZ_CMD[@]}" ">$INPUT_CHANGELOG_INCREMENT_FILENAME"
@@ -109,17 +117,29 @@ else
109117
fi
110118

111119
REV="$(cz version --project)"
120+
NEXT_REV_MAJOR="$(cz version --project --major)"
121+
NEXT_REV_MINOR="$(cz version --project --minor)"
122+
123+
# Fall back to the pre-computed --get-next value when `cz version --project`
124+
# did not reflect the bump. This happens with version_provider=scm and
125+
# commit:false, where the bump does not update any tracked files and no
126+
# tag is created, so the project's reported version remains unchanged.
127+
if [[ $REV == "$PREV_REV" && -n "$NEXT_REV_PRE" && "$NEXT_REV_PRE" != "$PREV_REV" ]]; then
128+
REV="$NEXT_REV_PRE"
129+
NEXT_REV_MAJOR="${REV%%.*}"
130+
NEXT_REV_REST="${REV#*.}"
131+
NEXT_REV_MINOR="${NEXT_REV_REST%%.*}"
132+
fi
133+
112134
if [[ $REV == "$PREV_REV" ]]; then
113135
INPUT_PUSH='false'
114136
fi
115137
echo "REVISION=${REV}" >>"$GITHUB_ENV"
116138
echo "version=${REV}" >>"$GITHUB_OUTPUT"
117139
echo "next_version=${REV}" >>"$GITHUB_OUTPUT"
118140

119-
NEXT_REV_MAJOR="$(cz version --project --major)"
120141
echo "NEXT_REVISION_MAJOR=${NEXT_REV_MAJOR}" >>"$GITHUB_ENV"
121142
echo "next_version_major=${NEXT_REV_MAJOR}" >>"$GITHUB_OUTPUT"
122-
NEXT_REV_MINOR="$(cz version --project --minor)"
123143
echo "NEXT_REVISION_MINOR=${NEXT_REV_MINOR}" >>"$GITHUB_ENV"
124144
echo "next_version_minor=${NEXT_REV_MINOR}" >>"$GITHUB_OUTPUT"
125145

0 commit comments

Comments
 (0)