Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/auto-release.yml
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:)"; "")')
Copy link

Copilot AI Nov 12, 2025

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".

Suggested change
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:)"; "")')

Copilot uses AI. Check for mistakes.

# 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
Copy link

Copilot AI Nov 12, 2025

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
fi

Since jq already handles null values and would return empty string for non-matches, the "$VERSION" = "null" checks are redundant.

Suggested change
if { [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; } && { [ -z "$ZEAM_TAG" ] || [ "$ZEAM_TAG" = "null" ]; }; then
if [ -z "$VERSION" ] && [ -z "$ZEAM_TAG" ]; then

Copilot uses AI. Check for mistakes.
echo "❌ No usable label found! Please add a version (e.g. v1.0.0) or network tag (e.g. devnet0, testnet, mainnet)"
exit 1
fi

- name: Create and push git tags
run: |
git config user.name "github-actions[bot]"
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
Copy link

Copilot AI Nov 12, 2025

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 }}" ]; then

The same applies to the check on line 36 where || [ "$VERSION" = "null" ] can be removed.

Suggested change
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

Copilot uses AI. Check for mistakes.
if git rev-parse "${{ steps.get_tags_labels.outputs.git_tag }}" >/dev/null 2>&1; then
echo "⚠️ Tag ${{ steps.get_tags_labels.outputs.git_tag }} already exists, skipping"
else
git tag -a "${{ steps.get_tags_labels.outputs.git_tag }}" -m "Release version ${{ steps.get_tags_labels.outputs.version }}"
git push origin "${{ steps.get_tags_labels.outputs.git_tag }}"
echo "✅ Created version tag ${{ steps.get_tags_labels.outputs.git_tag }}"
fi
fi

# Create zeam network tag if network label exists
if [ "${{ steps.get_tags_labels.outputs.has_network_tag }}" = "true" ]; then
ZEAM_GIT_TAG="${{ steps.get_tags_labels.outputs.zeam_tag }}"
if git rev-parse "$ZEAM_GIT_TAG" >/dev/null 2>&1; then
echo "⚠️ Zeam tag $ZEAM_GIT_TAG already exists, skipping"
else
git tag -a "$ZEAM_GIT_TAG" -m "Zeam network tag for ${{ steps.get_tags_labels.outputs.zeam_tag }}"
git push origin "$ZEAM_GIT_TAG"
echo "✅ Created zeam tag $ZEAM_GIT_TAG"
fi
fi