Skip to content

Commit cc723a8

Browse files
authored
Merge pull request #27 from AztecProtocol/add-create-tag-workflow
Add GitHub Actions workflow for creating tags and releases
2 parents 2437d51 + edeca4d commit cc723a8

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

.github/workflows/create-tag.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Create Tag
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_name:
7+
description: 'Tag name (e.g., v1.0.0)'
8+
required: true
9+
type: string
10+
branch:
11+
description: 'Branch to create tag from'
12+
required: true
13+
type: string
14+
default: 'main'
15+
tag_message:
16+
description: 'Tag message/description'
17+
required: false
18+
type: string
19+
default: ''
20+
21+
jobs:
22+
create-tag:
23+
name: Create Tag
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v5
31+
with:
32+
ref: ${{ inputs.branch }}
33+
fetch-depth: 0
34+
35+
- name: Validate tag name
36+
run: |
37+
TAG_NAME="${{ inputs.tag_name }}"
38+
if [[ ! "$TAG_NAME" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?$ ]]; then
39+
echo "⚠️ Warning: Tag name '$TAG_NAME' doesn't follow semantic versioning (vX.Y.Z)"
40+
fi
41+
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
42+
echo "❌ Error: Tag '$TAG_NAME' already exists"
43+
exit 1
44+
fi
45+
echo "✅ Tag name '$TAG_NAME' is available"
46+
47+
- name: Configure Git
48+
run: |
49+
git config user.name "github-actions[bot]"
50+
git config user.email "github-actions[bot]@users.noreply.github.com"
51+
52+
- name: Create and push tag
53+
run: |
54+
TAG_NAME="${{ inputs.tag_name }}"
55+
TAG_MESSAGE="${{ inputs.tag_message }}"
56+
57+
if [ -n "$TAG_MESSAGE" ]; then
58+
git tag -a "$TAG_NAME" -m "$TAG_MESSAGE"
59+
else
60+
git tag -a "$TAG_NAME" -m "Release $TAG_NAME"
61+
fi
62+
63+
git push origin "$TAG_NAME"
64+
echo "✅ Successfully created and pushed tag '$TAG_NAME'"
65+
66+
- name: Output tag info
67+
run: |
68+
echo "## Tag Created Successfully" >> $GITHUB_STEP_SUMMARY
69+
echo "" >> $GITHUB_STEP_SUMMARY
70+
echo "- **Tag:** ${{ inputs.tag_name }}" >> $GITHUB_STEP_SUMMARY
71+
echo "- **Branch:** ${{ inputs.branch }}" >> $GITHUB_STEP_SUMMARY
72+
echo "- **Commit:** $(git rev-parse HEAD)" >> $GITHUB_STEP_SUMMARY
73+
TAG_MESSAGE="${{ inputs.tag_message }}"
74+
echo "- **Message:** ${TAG_MESSAGE:-Release ${{ inputs.tag_name }}}" >> $GITHUB_STEP_SUMMARY
75+
76+
- name: Create GitHub Release
77+
uses: softprops/action-gh-release@v2
78+
with:
79+
tag_name: ${{ inputs.tag_name }}
80+
name: ${{ inputs.tag_name }}
81+
body: ${{ inputs.tag_message || format('Release {0}', inputs.tag_name) }}
82+
draft: false
83+
prerelease: ${{ contains(inputs.tag_name, '-') }}

0 commit comments

Comments
 (0)