-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (50 loc) · 1.91 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Generate a New Tag for Release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build:
name: Release to GitHub releases
runs-on: ubuntu-latest
env:
BUG_OR_FEAT: ${{ endsWith(github.event.head_commit.message, '[tag-bug]') && 5 || 6 }}
if: ${{ endsWith(github.event.head_commit.message, '[tag-bug]') || endsWith(github.event.head_commit.message, '[tag-feat]') }}
steps:
- name: Set the Git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Generate tag
run: |
echo $BUG_OR_FEAT
VERSION_MAJOR="1"
VERSION_MINOR=$(git tag --list "${VERSION_MAJOR}.[0-9]*.[0-9]*" --sort=-version:refname | head -n 1 | grep -oE '[0-9]+\.[0-9]+$' | grep -oE '^[0-9]+')
VERSION_PATCH=$(git tag --list "${VERSION_MAJOR}.[0-9]*.[0-9]*" --sort=-version:refname | head -n 1 | grep -oE '[0-9]+$')
if [ $BUG_OR_FEAT -eq 5 ]; then
echo "BUG"
NEW_VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.$((VERSION_PATCH + 1))"
elif [ $BUG_OR_FEAT -eq 6 ]; then
NEW_VERSION="${VERSION_MAJOR}.$((VERSION_MINOR + 1)).0"
echo "FEAT"
else
echo "Critical error..! [1]"
exit 1
fi
echo "Generated version: $NEW_VERSION"
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Push Git Tag
run: |
git tag $NEW_TAG
git tag -a $NEW_VERSION -m "v$NEW_VERSION"
git push origin $NEW_VERSION
- name: Update the v1 tag with the latest code
run: |
git tag -fa v1 -m "Update the v1 tag with the latest code"
git push origin v1 --force