-
Notifications
You must be signed in to change notification settings - Fork 16
auto github release #35
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
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 adds an automated GitHub release workflow that triggers when pull requests are merged to the release branch. The workflow extracts version and network information from PR labels and creates corresponding git tags.
- Implements automatic git tag creation based on PR labels (version tags like "v1.0.0" and network tags like "devnet0", "testnet", "mainnet")
- Validates that at least one usable label (version or network) is present before proceeding
- Handles existing tags gracefully by skipping tag creation if they already exist
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fi | ||
|
|
||
| # Require at least one label (version or network) | ||
| if { [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; } && { [ -z "$ZEAM_TAG" ] || [ "$ZEAM_TAG" = "null" ]; }; then |
Copilot
AI
Nov 12, 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 conditional check uses repetitive logic with multiple OR conditions that could be simplified. The expression { [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; } && { [ -z "$ZEAM_TAG" ] || [ "$ZEAM_TAG" = "null" ]; } is complex and harder to maintain.
Consider simplifying by using a function or combining the checks more cleanly:
if [ -z "$VERSION" ] && [ -z "$ZEAM_TAG" ]; then
echo "❌ No usable label found! Please add a version (e.g. v1.0.0) or network tag (e.g. devnet0, testnet, mainnet)"
exit 1
fiSince jq already handles null values and would return empty string for non-matches, the "$VERSION" = "null" checks are redundant.
| if { [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; } && { [ -z "$ZEAM_TAG" ] || [ "$ZEAM_TAG" = "null" ]; }; then | |
| if [ -z "$VERSION" ] && [ -z "$ZEAM_TAG" ]; then |
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| # Create version tag if version label exists | ||
| if [ -n "${{ steps.get_tags_labels.outputs.version }}" ] && [ "${{ steps.get_tags_labels.outputs.version }}" != "null" ]; then |
Copilot
AI
Nov 12, 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 redundant null checks throughout the tag creation step are unnecessary. Since jq with the -r flag returns an empty string (not the literal string "null") when no match is found, checking for != "null" is redundant after already checking for non-empty with -n.
Simplify line 65 to:
if [ -n "${{ steps.get_tags_labels.outputs.version }}" ]; thenThe same applies to the check on line 36 where || [ "$VERSION" = "null" ] can be removed.
| if [ -n "${{ steps.get_tags_labels.outputs.version }}" ] && [ "${{ steps.get_tags_labels.outputs.version }}" != "null" ]; then | |
| if [ -n "${{ steps.get_tags_labels.outputs.version }}" ]; then |
| echo "PR Labels: $LABELS" | ||
|
|
||
| # Look for version label (e.g., "v1.0.0", "version:1.0.0", etc.) | ||
| VERSION=$(echo $LABELS | jq -r '.[] | select(test("^(v|version:)?[0-9]+\\.[0-9]+\\.[0-9]+")) | gsub("^(v|version:)"; "")') |
Copilot
AI
Nov 12, 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 regex pattern has an issue with escaping. In the shell context, the backslashes need to be doubled or the string should be properly quoted. The current pattern "^(v|version:)?[0-9]+\\.[0-9]+\\.[0-9]+" may not work as intended because the backslashes before the dots might not be properly escaped for jq's regex engine.
Consider using:
VERSION=$(echo $LABELS | jq -r '.[] | select(test("^(v|version:)?[0-9]+\\.[0-9]+\\.[0-9]+$")) | gsub("^(v|version:)"; "")')Also note that adding $ at the end of the pattern would ensure exact matching and prevent matching labels like "v1.0.0-beta".
| VERSION=$(echo $LABELS | jq -r '.[] | select(test("^(v|version:)?[0-9]+\\.[0-9]+\\.[0-9]+")) | gsub("^(v|version:)"; "")') | |
| VERSION=$(echo $LABELS | jq -r '.[] | select(test("^(v|version:)?[0-9]+\\\\.[0-9]+\\\\.[0-9]+$")) | gsub("^(v|version:)"; "")') |
No description provided.