Skip to content

Commit 1696cda

Browse files
kylehgcclaude
andcommitted
fix(cd): compute the first fork RC without a tag that does not exist
The first CD run after the release work merged failed: Latest release: fork-v0.0.0 fatal: ambiguous argument 'fork-v0.0.0..HEAD': unknown revision With no fork-v tag yet, the job synthesised "fork-v0.0.0" as a starting point for the version arithmetic and then fed that same string to git log as a ref. It is not one. Every RC would have failed until the first stable release existed — which itself requires a working release path. Separates the two concerns: 0.0.0 is the version baseline, and the commit range is all of history when there is no tag to start from. The prior isolated test of this logic passed because it only exercised the version maths, never the git log that consumes its output. Verified this time by running the real branch logic against the real repository: kylehgc/rtk: base=0.0.0 range=HEAD -> fork-dev-0.1.0-rc.N rtk-ai/rtk: base=0.44.1 range=v0.44.1..HEAD -> dev-0.45.0-rc.N Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 17dd0d3 commit 1696cda

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

‎.github/workflows/cd.yml‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,24 @@ jobs:
9393
# Exclude pre-release tags. Match on '-rc' rather than any '-', because the
9494
# fork prefix itself contains a hyphen.
9595
LATEST_TAG=$(git tag -l "$TAG_GLOB" --sort=-version:refname | grep -v -- '-rc' | head -1)
96-
if [ -z "$LATEST_TAG" ]; then
97-
if [ -n "$TAG_PREFIX" ]; then
98-
LATEST_TAG="${TAG_PREFIX}v0.0.0" # fork has not cut a stable release yet
99-
else
100-
echo "::error::No stable release tag found"
101-
exit 1
102-
fi
96+
if [ -n "$LATEST_TAG" ]; then
97+
LATEST_VERSION="${LATEST_TAG#${TAG_PREFIX}v}"
98+
COMMIT_RANGE="${LATEST_TAG}..HEAD"
99+
echo "Latest release: $LATEST_TAG"
100+
elif [ -n "$TAG_PREFIX" ]; then
101+
# The fork has not cut a stable release yet. 0.0.0 is a starting point for
102+
# the version maths, NOT a ref — `git log 0.0.0..HEAD` would abort — so the
103+
# range has to be all of history.
104+
LATEST_VERSION="0.0.0"
105+
COMMIT_RANGE="HEAD"
106+
echo "No ${TAG_PREFIX}v tag yet; starting the fork's version line at 0.0.0"
107+
else
108+
echo "::error::No stable release tag found"
109+
exit 1
103110
fi
104-
LATEST_VERSION="${LATEST_TAG#${TAG_PREFIX}v}"
105-
echo "Latest release: $LATEST_TAG"
106111
107112
# ── Analyse conventional commits since that tag ──
108-
COMMITS=$(git log "${LATEST_TAG}..HEAD" --format="%s")
113+
COMMITS=$(git log $COMMIT_RANGE --format="%s")
109114
HAS_BREAKING=$(echo "$COMMITS" | grep -cE '^[a-z]+(\(.+\))?!:' || true)
110115
HAS_FEAT=$(echo "$COMMITS" | grep -cE '^feat(\(.+\))?:' || true)
111116
HAS_FIX=$(echo "$COMMITS" | grep -cE '^fix(\(.+\))?:' || true)

0 commit comments

Comments
 (0)