-
Notifications
You must be signed in to change notification settings - Fork 0
Bugfix/version not updated on beta merge #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Detect squash merges by checking for PR number in commit message - Query GitHub API to get source branch for squash merges - Update both update-version and sync_branches jobs - Fix version calculation to handle squash merges - Resolves issue where beta->main squash merge didn't update VERSION
The beta->main PR merge was a squash merge, so the workflow didn't detect it and failed to update VERSION. This commit corrects the VERSION file manually while the workflow fix ensures future squash merges are handled properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where the VERSION file was not being updated correctly when beta branches were merged to main using squash merges. The fix includes correcting the VERSION file format (removing leading whitespace) and improving the workflow's merge detection logic to properly handle both regular merge commits and squash merges.
- Fixes VERSION file format by removing leading spaces and updating from
1.0.0-alphato1.0.0-beta - Refactors branch type detection logic to use GitHub API as a fallback for both merge commits and squash merges
- Adds explicit squash merge detection in VERSION update and branch sync jobs
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| VERSION | Corrects file format by removing leading spaces and updates version from 1.0.0-alpha to 1.0.0-beta |
| .github/workflows/ci-cd-versioned.yml | Refactors merge detection logic to properly handle squash merges; moves GitHub API fallback outside conditional blocks; adds squash merge detection to VERSION update and branch sync jobs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| echo "🔍 Detected PR #${PR_NUMBER}, querying GitHub API for source branch..." | ||
| PR_INFO=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
| "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER") | ||
| LAST_PR_BRANCH=$(echo "$PR_INFO" | grep -oP '"ref":\s*"\K[^"]+' | head -1) |
Copilot
AI
Dec 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The grep pattern '"ref":\s*"\K[^"]+' will match any "ref" field in the JSON response. The GitHub PR API returns multiple "ref" fields (for both head.ref and base.ref). Using | head -1 to get the first match is unreliable because JSON field ordering is not guaranteed. This could potentially extract the base (target) branch instead of the head (source) branch.
Consider using a more specific pattern or using jq to parse the JSON properly:
LAST_PR_BRANCH=$(echo "$PR_INFO" | jq -r '.head.ref')Or with grep, be more specific:
LAST_PR_BRANCH=$(echo "$PR_INFO" | grep -oP '"head":[^}]*"ref":\s*"\K[^"]+')| LAST_PR_BRANCH=$(echo "$PR_INFO" | grep -oP '"ref":\s*"\K[^"]+' | head -1) | |
| LAST_PR_BRANCH=$(echo "$PR_INFO" | jq -r '.head.ref') |
| echo "merge_type=merge" >> $GITHUB_OUTPUT | ||
| echo "✅ This is a merge commit (2 parents)" | ||
| else | ||
| echo "is_merge=false" >> $GITHUB_OUTPUT | ||
| echo "ℹ️ This is a direct commit, skipping VERSION update" | ||
| # Check if this is a squash merge by looking for PR number | ||
| COMMIT_MSG=$(git log -1 --pretty=%B) | ||
| if [[ "$COMMIT_MSG" =~ \(#[0-9]+\) ]]; then | ||
| echo "is_merge=true" >> $GITHUB_OUTPUT | ||
| echo "merge_type=squash" >> $GITHUB_OUTPUT | ||
| echo "✅ This is a squash merge (PR found in commit message)" | ||
| else | ||
| echo "is_merge=false" >> $GITHUB_OUTPUT | ||
| echo "merge_type=none" >> $GITHUB_OUTPUT |
Copilot
AI
Dec 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The merge_type output variable is set but never used by any subsequent steps or jobs. If this is intended for debugging purposes only, consider removing it or documenting its purpose. If it's intended for future use, consider adding a comment explaining the planned usage.
If not needed, you can remove these lines to reduce clutter:
echo "merge_type=merge" >> $GITHUB_OUTPUT # line 497
echo "merge_type=squash" >> $GITHUB_OUTPUT # line 504
echo "merge_type=none" >> $GITHUB_OUTPUT # line 508
No description provided.