Skip to content

Commit 5cd401f

Browse files
jfrench9claude
andauthored
Refactor tag-release workflow to improve initial release handling (#44)
## Summary This PR refactors the GitHub Actions tag-release workflow to enhance the handling of initial releases and improve overall workflow reliability. ## Key Accomplishments - **Enhanced Initial Release Support**: Improved workflow logic to better handle scenarios where no previous releases exist - **Workflow Optimization**: Refactored existing workflow structure for better maintainability and reliability - **Process Streamlining**: Simplified release tagging logic while maintaining backward compatibility ## Breaking Changes None. This is a workflow improvement that maintains existing functionality while adding better initial release support. ## Testing Notes - Verify that existing release processes continue to work as expected - Test initial release scenarios in repositories without previous releases - Confirm that version tagging and release creation function properly across different project states ## Infrastructure Considerations - This change only affects the automated release workflow and does not impact application code - The workflow improvements should result in more reliable release processes - No changes to deployment or build processes are included in this update --- 🤖 Generated with [Claude Code](https://claude.ai/code) **Branch Info:** - Source: `chore/fix-tag-release` - Target: `main` - Type: feature Co-Authored-By: Claude <noreply@anthropic.com>
2 parents b274e29 + c6c99c3 commit 5cd401f

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

‎.github/workflows/tag-release.yml‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,31 +71,31 @@ jobs:
7171
7272
if [ -z "$LAST_TAG" ]; then
7373
echo "No previous release found, analyzing all commits"
74-
COMMIT_RANGE="$(git rev-list --max-parents=0 HEAD)..HEAD"
7574
LAST_TAG="initial"
75+
# For initial release, use different commands that don't require a range
76+
FILES_CHANGED=$(git ls-files | wc -l)
77+
COMMITS_COUNT=$(git rev-list --count HEAD)
78+
# Get stats by diffing empty tree against HEAD
79+
EMPTY_TREE=$(git hash-object -t tree /dev/null)
80+
ADDITIONS=$(git diff --shortstat "$EMPTY_TREE" HEAD | grep -oE '[0-9]+ insertions?' | grep -oE '[0-9]+' || echo "0")
81+
DELETIONS=$(git diff --shortstat "$EMPTY_TREE" HEAD | grep -oE '[0-9]+ deletions?' | grep -oE '[0-9]+' || echo "0")
82+
COMMIT_MESSAGES=$(git log --oneline --no-color HEAD | head -30)
83+
DETAILED_CHANGES=$(git diff --name-status --no-color "$EMPTY_TREE" HEAD | head -50)
84+
PR_REFS=$(git log --oneline --no-color HEAD | grep -oE '#[0-9]+' | sort -u | head -10 || echo "")
7685
else
77-
COMMIT_RANGE="$LAST_TAG..HEAD"
7886
echo "Analyzing changes since last release: $LAST_TAG"
87+
# Use explicit two-commit diff syntax instead of range syntax
88+
FILES_CHANGED=$(git diff --name-only "$LAST_TAG" HEAD | wc -l)
89+
COMMITS_COUNT=$(git rev-list --count "$LAST_TAG"..HEAD)
90+
ADDITIONS=$(git diff --shortstat "$LAST_TAG" HEAD | grep -oE '[0-9]+ insertions?' | grep -oE '[0-9]+' || echo "0")
91+
DELETIONS=$(git diff --shortstat "$LAST_TAG" HEAD | grep -oE '[0-9]+ deletions?' | grep -oE '[0-9]+' || echo "0")
92+
COMMIT_MESSAGES=$(git log --oneline --no-color "$LAST_TAG"..HEAD | head -30)
93+
DETAILED_CHANGES=$(git diff --name-status --no-color "$LAST_TAG" HEAD | head -50)
94+
PR_REFS=$(git log --oneline --no-color "$LAST_TAG"..HEAD | grep -oE '#[0-9]+' | sort -u | head -10 || echo "")
7995
fi
8096
81-
# Get change statistics
82-
FILES_CHANGED=$(git diff --name-only $COMMIT_RANGE | wc -l)
83-
COMMITS_COUNT=$(git rev-list --count $COMMIT_RANGE)
84-
ADDITIONS=$(git diff --shortstat $COMMIT_RANGE | grep -oE '[0-9]+ insertions?' | grep -oE '[0-9]+' || echo "0")
85-
DELETIONS=$(git diff --shortstat $COMMIT_RANGE | grep -oE '[0-9]+ deletions?' | grep -oE '[0-9]+' || echo "0")
86-
87-
# Get commit messages (limit to prevent memory issues)
88-
COMMIT_MESSAGES=$(git log --oneline --no-color $COMMIT_RANGE | head -30)
89-
90-
# Get file changes (limit to prevent memory issues)
91-
DETAILED_CHANGES=$(git diff --name-status --no-color $COMMIT_RANGE | head -50)
92-
93-
# Get PR references from commit messages
94-
PR_REFS=$(git log --oneline --no-color $COMMIT_RANGE | grep -oE '#[0-9]+' | sort -u | head -10 || echo "")
95-
9697
# Save outputs
9798
echo "last_tag=$LAST_TAG" >> $GITHUB_OUTPUT
98-
echo "commit_range=$COMMIT_RANGE" >> $GITHUB_OUTPUT
9999
echo "files_changed=$FILES_CHANGED" >> $GITHUB_OUTPUT
100100
echo "commits_count=$COMMITS_COUNT" >> $GITHUB_OUTPUT
101101
echo "additions=$ADDITIONS" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)