mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
fix: Handle first release when no Git tags exist
- Fix git log commands when no previous tags exist - Handle v0.0.0 as starting point for first release - Add proper error handling for missing tags - Improve logging for debugging Now unified-release.yml should work for the first release: ✅ No tags? Start from v0.0.0 and analyze all commits ✅ Has tags? Analyze commits since last tag ✅ Proper semantic versioning from the beginning
This commit is contained in:
@@ -41,8 +41,15 @@ jobs:
|
||||
- name: Get Last Release
|
||||
id: last_release
|
||||
run: |
|
||||
# Try to get the latest tag, fallback to v0.0.0 if none exist
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
|
||||
echo "Latest tag: $LATEST_TAG"
|
||||
|
||||
# If no tags exist, create a dummy starting point
|
||||
if [ "$LATEST_TAG" == "v0.0.0" ]; then
|
||||
echo "No tags found, starting from v0.0.0"
|
||||
fi
|
||||
|
||||
- name: Analyze Commits and Calculate Version
|
||||
id: version
|
||||
@@ -50,20 +57,54 @@ jobs:
|
||||
LAST_TAG="${{ steps.last_release.outputs.tag }}"
|
||||
CURRENT_VERSION=${LAST_TAG#v}
|
||||
|
||||
# Get commits from main repo and submodules
|
||||
MAIN_COMMITS=$(git log $LAST_TAG..HEAD --oneline --no-merges)
|
||||
echo "Current version: $CURRENT_VERSION"
|
||||
|
||||
cd swingmusic-desktop && git fetch --tags && DESKTOP_COMMITS=$(git log $LAST_TAG..HEAD --oneline --no-merges 2>/dev/null || echo "") && cd ..
|
||||
cd swingmusic-android && git fetch --tags && ANDROID_COMMITS=$(git log $LAST_TAG..HEAD --oneline --no-merges 2>/dev/null || echo "") && cd ..
|
||||
cd src/swingmusic && git fetch --tags && BACKEND_COMMITS=$(git log $LAST_TAG..HEAD --oneline --no-merges 2>/dev/null || echo "") && cd ../..
|
||||
# Get commits from main repo and submodules
|
||||
if [ "$LAST_TAG" == "v0.0.0" ]; then
|
||||
# No previous tag, get all commits
|
||||
MAIN_COMMITS=$(git log --oneline --no-merges)
|
||||
echo "No previous tag found, analyzing all commits"
|
||||
else
|
||||
# Get commits since last tag
|
||||
MAIN_COMMITS=$(git log $LAST_TAG..HEAD --oneline --no-merges 2>/dev/null || echo "")
|
||||
echo "Analyzing commits since $LAST_TAG"
|
||||
fi
|
||||
|
||||
# Get commits from submodules
|
||||
cd swingmusic-desktop && git fetch --tags &&
|
||||
if [ "$LAST_TAG" == "v0.0.0" ]; then
|
||||
DESKTOP_COMMITS=$(git log --oneline --no-merges 2>/dev/null || echo "")
|
||||
else
|
||||
DESKTOP_COMMITS=$(git log $LAST_TAG..HEAD --oneline --no-merges 2>/dev/null || echo "")
|
||||
fi && cd ..
|
||||
|
||||
cd swingmusic-android && git fetch --tags &&
|
||||
if [ "$LAST_TAG" == "v0.0.0" ]; then
|
||||
ANDROID_COMMITS=$(git log --oneline --no-merges 2>/dev/null || echo "")
|
||||
else
|
||||
ANDROID_COMMITS=$(git log $LAST_TAG..HEAD --oneline --no-merges 2>/dev/null || echo "")
|
||||
fi && cd ..
|
||||
|
||||
cd src/swingmusic && git fetch --tags &&
|
||||
if [ "$LAST_TAG" == "v0.0.0" ]; then
|
||||
BACKEND_COMMITS=$(git log --oneline --no-merges 2>/dev/null || echo "")
|
||||
else
|
||||
BACKEND_COMMITS=$(git log $LAST_TAG..HEAD --oneline --no-merges 2>/dev/null || echo "")
|
||||
fi && cd ../..
|
||||
|
||||
# Count commit types
|
||||
ALL_COMMITS="$MAIN_COMMITS $DESKTOP_COMMITS $ANDROID_COMMITS $BACKEND_COMMITS"
|
||||
|
||||
echo "All commits: $ALL_COMMITS"
|
||||
|
||||
MAJOR_COUNT=$(echo "$ALL_COMMITS" | grep -iE "BREAKING CHANGE|major|!:|breaking" | wc -l || echo "0")
|
||||
MINOR_COUNT=$(echo "$ALL_COMMITS" | grep -iE "feat|feature|add|new|enhance" | wc -l || echo "0")
|
||||
PATCH_COUNT=$(echo "$ALL_COMMITS" | grep -iE "fix|bug|patch|update|improve|refactor|docs|style|test|chore" | wc -l || echo "0")
|
||||
|
||||
echo "Major changes: $MAJOR_COUNT"
|
||||
echo "Minor changes: $MINOR_COUNT"
|
||||
echo "Patch changes: $PATCH_COUNT"
|
||||
|
||||
# Calculate next version
|
||||
IFS='.' read -ra PARTS <<< "$CURRENT_VERSION"
|
||||
MAJOR=${PARTS[0]:-0}
|
||||
|
||||
Reference in New Issue
Block a user