File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : create_tag.yml
2+ on :
3+ workflow_dispatch :
4+ inputs :
5+ tag_name :
6+ description : ' Tag name (e.g., v1.2.3)'
7+ required : true
8+ release_message :
9+ description : ' Release message/description'
10+ required : false
11+ default : ' Release'
12+ jobs :
13+ create_tag :
14+ runs-on : ubuntu-latest
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 0 # Needed to fetch all history for tags
20+
21+ - name : Check if commit is already tagged
22+ id : check_tag
23+ run : |
24+ TAG=$(git tag --contains ${{ github.sha }} | head -n 1)
25+ if [ -n "$TAG" ]; then
26+ echo "::set-output name=tagged::true"
27+ echo "::set-output name=existing_tag::$TAG"
28+ echo "Commit ${{ github.sha }} is already tagged with $TAG"
29+ else
30+ echo "::set-output name=tagged::false"
31+ echo "Commit ${{ github.sha }} is not tagged"
32+ fi
33+
34+ - name : Create tag
35+ if : steps.check_tag.outputs.tagged == 'false'
36+ run : |
37+ git config --global user.name 'GitHub Actions'
38+ git config --global user.email 'actions@github.com'
39+ git tag -a ${{ github.event.inputs.tag_name }} ${{ github.sha }} -m "${{ github.event.inputs.release_message }}"
40+ git push origin ${{ github.event.inputs.tag_name }}
41+
42+ - name : Output Existing Tag (if any)
43+ if : steps.check_tag.outputs.tagged == 'true'
44+ run : |
45+ echo "Existing tag: ${{ steps.check_tag.outputs.existing_tag }}"
You can’t perform that action at this time.
0 commit comments