Skip to content

Commit 325263e

Browse files
committed
fix: Resolve release workflow git tag issues
- Handle case when no existing tags are present - Fix git log commands that fail with nonexistent tag ranges - Add proper fallback for changelog generation - Bootstrap versioning with initial v0.1.0 tag This resolves the 'fatal: ambiguous argument v0.0.0..HEAD' error in GitHub Actions.
1 parent d4ecdd1 commit 325263e

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,22 @@ jobs:
5656
exit 0
5757
fi
5858
59-
# Get commits since last tag
60-
COMMITS=$(git log ${LAST_TAG}..HEAD --oneline)
61-
62-
if [ -z "$COMMITS" ]; then
63-
echo "No new commits since last tag"
64-
echo "should_release=false" >> $GITHUB_OUTPUT
65-
exit 0
59+
# Get commits since last tag or all commits if no tags exist
60+
if git describe --tags --abbrev=0 >/dev/null 2>&1; then
61+
# There are existing tags
62+
COMMITS=$(git log ${LAST_TAG}..HEAD --oneline)
63+
if [ -z "$COMMITS" ]; then
64+
echo "No new commits since last tag"
65+
echo "should_release=false" >> $GITHUB_OUTPUT
66+
exit 0
67+
fi
68+
echo "New commits since $LAST_TAG:"
69+
else
70+
# No existing tags, get all commits
71+
COMMITS=$(git log --oneline)
72+
echo "No existing tags found. All commits:"
6673
fi
67-
68-
echo "New commits since $LAST_TAG:"
74+
6975
echo "$COMMITS"
7076
7177
# Determine version bump based on commit messages
@@ -172,12 +178,24 @@ jobs:
172178
173179
EOF
174180
175-
# Get commits since last tag
176-
git log ${LAST_TAG}..HEAD --pretty=format:"- %s (%h)" >> $CHANGELOG_FILE
181+
# Get commits since last tag or all commits if no tags exist
182+
if git describe --tags --abbrev=0 >/dev/null 2>&1; then
183+
# There are existing tags
184+
git log ${LAST_TAG}..HEAD --pretty=format:"- %s (%h)" >> $CHANGELOG_FILE
185+
else
186+
# No existing tags, get all commits
187+
git log --pretty=format:"- %s (%h)" >> $CHANGELOG_FILE
188+
fi
177189
178190
echo "" >> $CHANGELOG_FILE
179191
echo "" >> $CHANGELOG_FILE
180-
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${LAST_TAG}...${NEW_VERSION}" >> $CHANGELOG_FILE
192+
193+
# Generate appropriate changelog link
194+
if git describe --tags --abbrev=0 >/dev/null 2>&1; then
195+
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${LAST_TAG}...${NEW_VERSION}" >> $CHANGELOG_FILE
196+
else
197+
echo "**Full Changelog**: https://github.com/${{ github.repository }}/commits/${NEW_VERSION}" >> $CHANGELOG_FILE
198+
fi
181199
182200
# Read changelog content for the release
183201
CHANGELOG_CONTENT=$(cat $CHANGELOG_FILE)

0 commit comments

Comments
 (0)