Skip to content

Commit 857db80

Browse files
Create create_tag.yml
1 parent a79526d commit 857db80

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

.github/workflows/create_tag.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 }}"

0 commit comments

Comments
 (0)