-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,85 @@ | ||||||
| name: Auto Release on Release Branch | ||||||
|
|
||||||
| on: | ||||||
| pull_request: | ||||||
| types: [ closed ] | ||||||
| branches: [ release ] | ||||||
|
|
||||||
| permissions: | ||||||
| contents: write | ||||||
|
|
||||||
| jobs: | ||||||
| auto-release: | ||||||
| # Only run if PR was merged to release branch (not just closed) | ||||||
| if: github.event.pull_request.merged == true | ||||||
| runs-on: ubuntu-latest | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v4 | ||||||
| with: | ||||||
| fetch-depth: 0 | ||||||
|
|
||||||
| - name: Extract tags from PR labels | ||||||
| id: get_tags_labels | ||||||
| run: | | ||||||
| # Get PR labels and extract version | ||||||
| LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}' | ||||||
| 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:)"; "")') | ||||||
|
|
||||||
| # Look for zeam network tags (devnet0, devnet1, testnet, mainnet) | ||||||
| ZEAM_TAG=$(echo $LABELS | jq -r '.[] | select(test("^(devnet[0-9]+|testnet[0-9]*|mainnet)$"))') | ||||||
|
|
||||||
| if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then | ||||||
| echo "ℹ️ No version label found" | ||||||
| else | ||||||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||||||
| echo "git_tag=v$VERSION" >> $GITHUB_OUTPUT | ||||||
| echo "✅ Version found: $VERSION" | ||||||
| fi | ||||||
|
|
||||||
| if [ -n "$ZEAM_TAG" ] && [ "$ZEAM_TAG" != "null" ]; then | ||||||
| echo "zeam_tag=$ZEAM_TAG" >> $GITHUB_OUTPUT | ||||||
| echo "has_network_tag=true" >> $GITHUB_OUTPUT | ||||||
| echo "✅ Found network tag: $ZEAM_TAG" | ||||||
| else | ||||||
| echo "has_network_tag=false" >> $GITHUB_OUTPUT | ||||||
| echo "ℹ️ No network tag found (optional)" | ||||||
| fi | ||||||
|
|
||||||
| # Require at least one label (version or network) | ||||||
| if { [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; } && { [ -z "$ZEAM_TAG" ] || [ "$ZEAM_TAG" = "null" ]; }; then | ||||||
|
||||||
| if { [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; } && { [ -z "$ZEAM_TAG" ] || [ "$ZEAM_TAG" = "null" ]; }; then | |
| if [ -z "$VERSION" ] && [ -z "$ZEAM_TAG" ]; 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 |
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".