Skip to content

Commit 697c53c

Browse files
committed
GH Auto Tag
1 parent c10fe54 commit 697c53c

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/auto-tag.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Auto Tag
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
create-tag:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Get version from package.json
20+
id: package-version
21+
uses: actions/github-script@v7
22+
with:
23+
script: |
24+
const fs = require('fs');
25+
const packageJson = JSON.parse(fs.readFileSync('Assets/UnityEventTimeline/package.json', 'utf8'));
26+
return packageJson.version;
27+
result-encoding: string
28+
29+
- name: Check if tag exists
30+
id: check-tag
31+
run: |
32+
if [ $(git tag -l "v${{ steps.package-version.outputs.result }}") ]; then
33+
echo "Tag v${{ steps.package-version.outputs.result }} already exists"
34+
echo "exists=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "exists=false" >> $GITHUB_OUTPUT
37+
fi
38+
39+
- name: Create and push tag
40+
if: steps.check-tag.outputs.exists == 'false'
41+
run: |
42+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
43+
git config --local user.name "github-actions[bot]"
44+
git tag -a "v${{ steps.package-version.outputs.result }}" -m "Release v${{ steps.package-version.outputs.result }}"
45+
git push origin "v${{ steps.package-version.outputs.result }}"

0 commit comments

Comments
 (0)