-
Notifications
You must be signed in to change notification settings - Fork 39
47 lines (37 loc) · 1.47 KB
/
tag-patches.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
name: Tag new patch releases on branch push
on:
push:
branches: [ stable ]
workflow_dispatch:
jobs:
build:
name: Tag new patch release
runs-on: ubuntu-latest
if: "github.event_name == 'workflow_dispatch' || startsWith(github.event.head_commit.message, 'New translations') || startsWith(github.event.head_commit.message, 'New Crowdin updates') "
concurrency: tag-patches
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 #we need to fetch tags to calculate new patch number
- name: Tag new version
run: |
BASE_VERSION="2.22"
PREVIOUS_TAG=$(git tag --list | awk -v s="$BASE_VERSION." 'index($0, s) == 1' | sort -r --version-sort | head -n1)
echo "Previous tag is $PREVIOUS_TAG"
PREVIOUS_PATCH=$(echo "$PREVIOUS_TAG" | cut -d. -f3)
regex='^[0-9]+$'
if [[ "$PREVIOUS_PATCH" =~ ^[0-9]+$ ]]; then
PATCH_VERSION="$(($PREVIOUS_PATCH+1))"
elif [[ "$PREVIOUS_PATCH" == "" ]]; then
PATCH_VERSION="0"
else
echo "Can't calculate next patch number from tag $PREVIOUS_TAG"
exit 1
fi
FULL_VERSION="$BASE_VERSION.$PATCH_VERSION"
echo "Tagging version $FULL_VERSION"
git config user.name github-actions
git config user.email [email protected]
git tag "$FULL_VERSION"
- name: Push changes
run: git push origin --tags