-
Notifications
You must be signed in to change notification settings - Fork 48
Adds tag workflow prefix #4691
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
Adds tag workflow prefix #4691
Conversation
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnhances the tag_release workflow to automatically extract an application-specific prefix from the branch name and incorporate it into the release tag, while refining branch resolution and version parsing. Flow diagram for tag prefix extraction and tag creationflowchart TD
A["Get branch name from github.ref"]
B["Extract branch base (3rd segment)"]
C["Extract app prefix (2nd segment after '-')"]
D["Get previous release tag"]
E["Parse minor version"]
F["Increment minor version if needed"]
G["Build tag: r-<app_prefix>.<date>.<minor_version>"]
H["Tag and push to origin"]
A --> B --> C --> G
D --> E --> F --> G
G --> H
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes - here's some feedback:
- Instead of manually parsing github.ref, consider using github.ref_name to get the branch name directly and avoid brittle split logic.
- The APP_PREFIX extraction with cut -d'-' -f2 assumes a single hyphen in branch names—add validation or a fallback for branches that don’t follow that pattern.
- Using git tag --list | tail -1 may not reliably pick the latest tag; consider sorting tags by version or date before selecting the most recent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of manually parsing github.ref, consider using github.ref_name to get the branch name directly and avoid brittle split logic.
- The APP_PREFIX extraction with cut -d'-' -f2 assumes a single hyphen in branch names—add validation or a fallback for branches that don’t follow that pattern.
- Using git tag --list | tail -1 may not reliably pick the latest tag; consider sorting tags by version or date before selecting the most recent.
## Individual Comments
### Comment 1
<location> `.github/workflows/tag_release.yml:28-29` </location>
<code_context>
case $PREV_RELEASE in
*"$DATE"*)
- MINOR_VERSION="$PREV_RELEASE" | cut -d'.' -f5
+ MINOR_VERSION=$(echo "$PREV_RELEASE" | cut -d'.' -f5)
MINOR_VERSION=$((MINOR_VERSION+1))
;;
*)
</code_context>
<issue_to_address>
**suggestion:** Subshell assignment for MINOR_VERSION improves correctness, but check for empty or non-numeric values.
Add a check to ensure MINOR_VERSION is numeric before performing arithmetic expansion to prevent potential failures.
```suggestion
MINOR_VERSION=$(echo "$PREV_RELEASE" | cut -d'.' -f5)
# Ensure MINOR_VERSION is numeric and not empty
if ! [[ "$MINOR_VERSION" =~ ^[0-9]+$ ]]; then
MINOR_VERSION=0
fi
MINOR_VERSION=$((MINOR_VERSION+1))
```
</issue_to_address>
### Comment 2
<location> `.github/workflows/tag_release.yml:35-37` </location>
<code_context>
;;
esac
- TAG="r.$DATE.$MINOR_VERSION"
+ BRANCH_BASE=$( echo $BRANCH | cut -d'/' -f3)
+ APP_PREFIX=$(echo "$BRANCH_BASE" | cut -d'-' -f2)
+ TAG="r-$APP_PREFIX.$DATE.$MINOR_VERSION"
git config --local user.email "[email protected]"
</code_context>
<issue_to_address>
**suggestion:** Parsing branch and app prefix assumes a specific branch naming convention.
This logic may fail if branch names deviate from the expected format. Please add validation or error handling for unexpected branch name structures.
```suggestion
# Validate branch structure
BRANCH_PARTS=$(echo "$BRANCH" | awk -F'/' '{print NF}')
if [ "$BRANCH_PARTS" -lt 3 ]; then
echo "Error: BRANCH variable '$BRANCH' does not have at least three '/'-separated components."
exit 1
fi
BRANCH_BASE=$( echo $BRANCH | cut -d'/' -f3)
APP_PREFIX_PARTS=$(echo "$BRANCH_BASE" | awk -F'-' '{print NF}')
if [ "$APP_PREFIX_PARTS" -lt 2 ]; then
echo "Error: BRANCH_BASE variable '$BRANCH_BASE' does not have at least two '-' separated components."
exit 1
fi
APP_PREFIX=$(echo "$BRANCH_BASE" | cut -d'-' -f2)
TAG="r-$APP_PREFIX.$DATE.$MINOR_VERSION"
```
</issue_to_address>
### Comment 3
<location> `.github/workflows/tag_release.yml:40` </location>
<code_context>
git config --local user.email "[email protected]"
git config --local user.name "Cost Management Release Action"
- git log $(git tag --list | tail -1)..${{ env.BRANCH }} | git tag -a $TAG -F -
+ git log $(git tag --list | tail -1)..$BRANCH_BASE | git tag -a $TAG -F -
git push origin $TAG
shell: bash
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Using $BRANCH_BASE instead of full branch ref may cause issues if branch names are ambiguous.
If $BRANCH_BASE is not unique, git log and tag operations may yield incorrect results. Use the full branch ref or ensure $BRANCH_BASE is unique.
```suggestion
git log $(git tag --list | tail -1)..$BRANCH | git tag -a $TAG -F -
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4691 +/- ##
=======================================
Coverage 87.07% 87.07%
=======================================
Files 480 480
Lines 9078 9078
Branches 2197 2195 -2
=======================================
Hits 7905 7905
Misses 1107 1107
Partials 66 66 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Adds a prefix in tag workflow, helping to identify tags for each app
Summary by Sourcery
Update the GitHub tag release workflow to include an application-specific prefix in tag names by parsing the branch name, and correct branch reference and minor version extraction.
Enhancements:
CI: