Skip to content

Commit 701e8db

Browse files
authored
Merge pull request #35 from blockblaz/docker-ci
auto github release with label testnet0
2 parents 70bfc05 + 54ad097 commit 701e8db

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

.github/workflows/auto-release.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Auto Release on Release Branch
2+
3+
on:
4+
pull_request:
5+
types: [ closed ]
6+
branches: [ release ]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
auto-release:
13+
# Only run if PR was merged to release branch (not just closed)
14+
if: github.event.pull_request.merged == true
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Extract tags from PR labels
24+
id: get_tags_labels
25+
run: |
26+
# Get PR labels and extract version
27+
LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}'
28+
echo "PR Labels: $LABELS"
29+
30+
# Look for version label (e.g., "v1.0.0", "version:1.0.0", etc.)
31+
VERSION=$(echo $LABELS | jq -r '.[] | select(test("^(v|version:)?[0-9]+\\.[0-9]+\\.[0-9]+")) | gsub("^(v|version:)"; "")')
32+
33+
# Look for zeam network tags (devnet0, devnet1, testnet, mainnet)
34+
ZEAM_TAG=$(echo $LABELS | jq -r '.[] | select(test("^(devnet[0-9]+|testnet[0-9]*|mainnet)$"))')
35+
36+
if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then
37+
echo "ℹ️ No version label found"
38+
else
39+
echo "version=$VERSION" >> $GITHUB_OUTPUT
40+
echo "git_tag=v$VERSION" >> $GITHUB_OUTPUT
41+
echo "✅ Version found: $VERSION"
42+
fi
43+
44+
if [ -n "$ZEAM_TAG" ] && [ "$ZEAM_TAG" != "null" ]; then
45+
echo "zeam_tag=$ZEAM_TAG" >> $GITHUB_OUTPUT
46+
echo "has_network_tag=true" >> $GITHUB_OUTPUT
47+
echo "✅ Found network tag: $ZEAM_TAG"
48+
else
49+
echo "has_network_tag=false" >> $GITHUB_OUTPUT
50+
echo "ℹ️ No network tag found (optional)"
51+
fi
52+
53+
# Require at least one label (version or network)
54+
if { [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; } && { [ -z "$ZEAM_TAG" ] || [ "$ZEAM_TAG" = "null" ]; }; then
55+
echo "❌ No usable label found! Please add a version (e.g. v1.0.0) or network tag (e.g. devnet0, testnet, mainnet)"
56+
exit 1
57+
fi
58+
59+
- name: Create and push git tags
60+
run: |
61+
git config user.name "github-actions[bot]"
62+
git config user.email "github-actions[bot]@users.noreply.github.com"
63+
64+
# Create version tag if version label exists
65+
if [ -n "${{ steps.get_tags_labels.outputs.version }}" ] && [ "${{ steps.get_tags_labels.outputs.version }}" != "null" ]; then
66+
if git rev-parse "${{ steps.get_tags_labels.outputs.git_tag }}" >/dev/null 2>&1; then
67+
echo "⚠️ Tag ${{ steps.get_tags_labels.outputs.git_tag }} already exists, skipping"
68+
else
69+
git tag -a "${{ steps.get_tags_labels.outputs.git_tag }}" -m "Release version ${{ steps.get_tags_labels.outputs.version }}"
70+
git push origin "${{ steps.get_tags_labels.outputs.git_tag }}"
71+
echo "✅ Created version tag ${{ steps.get_tags_labels.outputs.git_tag }}"
72+
fi
73+
fi
74+
75+
# Create zeam network tag if network label exists
76+
if [ "${{ steps.get_tags_labels.outputs.has_network_tag }}" = "true" ]; then
77+
ZEAM_GIT_TAG="${{ steps.get_tags_labels.outputs.zeam_tag }}"
78+
if git rev-parse "$ZEAM_GIT_TAG" >/dev/null 2>&1; then
79+
echo "⚠️ Zeam tag $ZEAM_GIT_TAG already exists, skipping"
80+
else
81+
git tag -a "$ZEAM_GIT_TAG" -m "Zeam network tag for ${{ steps.get_tags_labels.outputs.zeam_tag }}"
82+
git push origin "$ZEAM_GIT_TAG"
83+
echo "✅ Created zeam tag $ZEAM_GIT_TAG"
84+
fi
85+
fi

0 commit comments

Comments
 (0)