Skip to content

Commit 0a4de1e

Browse files
committed
upd
1 parent 8362c4e commit 0a4de1e

File tree

2 files changed

+116
-23
lines changed

2 files changed

+116
-23
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Auto Tag and Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
jobs:
10+
auto-tag-and-release:
11+
# Only run if the PR was merged and has the version-bump label
12+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'version-bump')
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
actions: write
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
ref: main
22+
fetch-depth: 0
23+
24+
- name: Get version from version.txt
25+
id: get-version
26+
run: |
27+
VERSION=$(cat version.txt | tr -d '[:space:]')
28+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
29+
echo "tag=v${VERSION}" >> $GITHUB_OUTPUT
30+
echo "Version from version.txt: ${VERSION}"
31+
echo "Will create tag: v${VERSION}"
32+
33+
- name: Check if tag already exists
34+
id: check-tag
35+
run: |
36+
TAG="v${{ steps.get-version.outputs.version }}"
37+
if git rev-parse "$TAG" >/dev/null 2>&1; then
38+
echo "exists=true" >> $GITHUB_OUTPUT
39+
echo "⚠️ Tag $TAG already exists"
40+
else
41+
echo "exists=false" >> $GITHUB_OUTPUT
42+
echo "✓ Tag $TAG does not exist yet"
43+
fi
44+
45+
- name: Create and push tag
46+
if: steps.check-tag.outputs.exists == 'false'
47+
env:
48+
GH_TOKEN: ${{ github.token }}
49+
run: |
50+
TAG="v${{ steps.get-version.outputs.version }}"
51+
52+
# Configure git
53+
git config --local user.name "github-actions[bot]"
54+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
55+
56+
# Create annotated tag
57+
git tag -a "$TAG" -m "Release $TAG"
58+
59+
# Push tag
60+
git push origin "$TAG"
61+
62+
echo "✅ Created and pushed tag: $TAG"
63+
64+
- name: Trigger release workflow
65+
if: steps.check-tag.outputs.exists == 'false'
66+
env:
67+
GH_TOKEN: ${{ secrets.FLASHINFER_BOT_TOKEN }}
68+
run: |
69+
TAG="v${{ steps.get-version.outputs.version }}"
70+
71+
# Trigger the release workflow
72+
gh workflow run release.yml \
73+
-f tag="$TAG"
74+
75+
echo "✅ Triggered release workflow for tag: $TAG"
76+
77+
- name: Summary
78+
run: |
79+
echo "## Auto Tag and Release Summary" >> $GITHUB_STEP_SUMMARY
80+
echo "" >> $GITHUB_STEP_SUMMARY
81+
82+
if [ "${{ steps.check-tag.outputs.exists }}" = "true" ]; then
83+
echo "⚠️ Tag v${{ steps.get-version.outputs.version }} already exists, skipped" >> $GITHUB_STEP_SUMMARY
84+
else
85+
echo "✅ Successfully created tag and triggered release workflow" >> $GITHUB_STEP_SUMMARY
86+
echo "" >> $GITHUB_STEP_SUMMARY
87+
echo "- **Version**: ${{ steps.get-version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
88+
echo "- **Tag**: v${{ steps.get-version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
89+
echo "- **PR**: #${{ github.event.pull_request.number }}" >> $GITHUB_STEP_SUMMARY
90+
echo "" >> $GITHUB_STEP_SUMMARY
91+
echo "🔗 [View Release Workflow Runs](../../actions/workflows/release.yml)" >> $GITHUB_STEP_SUMMARY
92+
fi
93+
94+
- name: Tag already exists
95+
if: steps.check-tag.outputs.exists == 'true'
96+
run: |
97+
echo "Tag v${{ steps.get-version.outputs.version }} already exists, skipping tag creation and release"
98+
exit 0

.github/workflows/bump-version.yml

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,23 @@ jobs:
189189
# Read key changes
190190
KEY_CHANGES=$(cat /tmp/key_changes.txt || echo "")
191191
192+
# Prepare variables
193+
BUMP_TYPE_UPPER=$(echo $BUMP_TYPE | tr '[:lower:]' '[:upper:]')
194+
if [ -n "$AI_PROVIDER" ]; then
195+
AI_PROVIDER_TEXT=" (using $AI_PROVIDER)"
196+
else
197+
AI_PROVIDER_TEXT=""
198+
fi
199+
192200
# Generate PR body
193-
cat > /tmp/pr_body.md << 'EOF'
194-
## Version Bump: v$CURRENT_VERSION → v$NEW_VERSION
201+
cat > /tmp/pr_body.md << EOF
202+
## Version Bump: v${CURRENT_VERSION} → v${NEW_VERSION}
195203

196-
This PR bumps the version from **v$CURRENT_VERSION** to **v$NEW_VERSION** ($BUMP_TYPE_UPPER bump).
204+
This PR bumps the version from **v${CURRENT_VERSION}** to **v${NEW_VERSION}** (${BUMP_TYPE_UPPER} bump).
197205

198-
### AI Analysis$AI_PROVIDER_TEXT
206+
### AI Analysis${AI_PROVIDER_TEXT}
199207

200-
$REASONING
208+
${REASONING}
201209

202210
EOF
203211

@@ -210,7 +218,7 @@ EOF
210218
done < /tmp/key_changes.txt
211219
fi
212220

213-
cat >> /tmp/pr_body.md << 'EOF'
221+
cat >> /tmp/pr_body.md << EOF
214222

215223
### Semantic Versioning Rules
216224

@@ -223,28 +231,15 @@ According to our [CONTRIBUTING.md](../blob/main/CONTRIBUTING.md):
223231
### Next Steps
224232

225233
After merging this PR:
226-
1. Create a git tag: `git tag v$NEW_VERSION`
227-
2. Run the [release workflow](../actions/workflows/release.yml) with tag `v$NEW_VERSION`
234+
- The [auto-tag-and-release workflow](../actions/workflows/auto-tag-and-release.yml) will automatically:
235+
1. Create git tag \`v${NEW_VERSION}\` on the main branch
236+
2. Trigger the [release workflow](../actions/workflows/release.yml) to build and publish the release
228237

229238
---
230239

231-
🤖 Auto-generated by [bump-version workflow](../actions/runs/$RUN_ID)
240+
🤖 Auto-generated by [bump-version workflow](../actions/runs/${{ github.run_id }})
232241
EOF
233242

234-
# Replace variables
235-
sed -i "s/\$CURRENT_VERSION/$CURRENT_VERSION/g" /tmp/pr_body.md
236-
sed -i "s/\$NEW_VERSION/$NEW_VERSION/g" /tmp/pr_body.md
237-
sed -i "s/\$BUMP_TYPE_UPPER/$(echo $BUMP_TYPE | tr '[:lower:]' '[:upper:]')/g" /tmp/pr_body.md
238-
sed -i "s|\$REASONING|$REASONING|g" /tmp/pr_body.md
239-
sed -i "s/\$RUN_ID/${{ github.run_id }}/g" /tmp/pr_body.md
240-
241-
# Add AI provider info if available
242-
if [ -n "$AI_PROVIDER" ]; then
243-
sed -i "s/\$AI_PROVIDER_TEXT/ (using $AI_PROVIDER)/g" /tmp/pr_body.md
244-
else
245-
sed -i "s/\$AI_PROVIDER_TEXT//g" /tmp/pr_body.md
246-
fi
247-
248243
cat /tmp/pr_body.md
249244

250245
- name: Create Pull Request

0 commit comments

Comments
 (0)