-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (49 loc) · 1.57 KB
/
main.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
name: Create Tag
on:
push:
branches:
- prod
- dev
- master
jobs:
build:
name: Create Tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Git
run: |
git config --global user.name 'github-actions'
- name: Create Tag
id: create_tag
run: |
VERSION_PREFIX="v"
CURRENT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "${VERSION_PREFIX}0.0.0")
echo "CURRENT_TAG: $CURRENT_TAG"
CURRENT_VERSION=${CURRENT_TAG#$VERSION_PREFIX}
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
if [[ "${{ github.ref }}" == "refs/heads/prod" ]]; then
((VERSION_PARTS[0]++))
VERSION_PARTS[1]=0
VERSION_PARTS[2]=0
else
((VERSION_PARTS[1]++))
VERSION_PARTS[2]=0
fi
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
NEW_TAG="$VERSION_PREFIX$NEW_VERSION"
echo "NEW_TAG: $NEW_TAG"
git tag $NEW_TAG
git push origin $NEW_TAG || echo "Failed to push tag"
echo ::set-output name=TAG_NAME::$NEW_TAG
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.create_tag.outputs.TAG_NAME }}
release_name: Release ${{ steps.create_tag.outputs.TAG_NAME }}
draft: false
prerelease: false