@@ -2,7 +2,7 @@ name: Build and Release Android App
2
2
on :
3
3
push :
4
4
branches :
5
- - master
5
+ - feat/cd-workflow
6
6
tags :
7
7
- v*
8
8
permissions :
41
41
- name : Set tag name
42
42
id : set_tag_name
43
43
run : |
44
- TAG_NAME="v$(date +'%Y%m%d')-${GITHUB_SHA::8}"
45
- echo "::set-output name=tag_name::$TAG_NAME"
44
+ # Determine the latest tag and commit messages since that tag
45
+ LAST_TAG=$(git describe --tags --abbrev=0)
46
+ COMMITS=$(git log --oneline ${LAST_TAG}..HEAD --format="%s")
47
+
48
+ # Initialize version components
49
+ MAJOR=0
50
+ MINOR=0
51
+ PATCH=0
52
+
53
+ # Analyze commit messages to determine version bump
54
+ while read -r line; do
55
+ if [[ "$line" == feat:* ]]; then
56
+ # Increment minor version for feature commits
57
+ ((MINOR++))
58
+ elif [[ "$line" == chore:* ]]; then
59
+ # Increment major version for chore commits
60
+ ((MAJOR++))
61
+ MINOR=0 # Reset minor version
62
+ elif [[ "$line" == fix:* ]]; then
63
+ # Increment patch version for fix commits
64
+ ((PATCH++))
65
+ fi
66
+ done <<< "$COMMITS"
67
+
68
+ # Determine the next version based on commit analysis
69
+ NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}"
70
+
71
+ echo "::set-output name=next_version::$NEXT_VERSION"
46
72
47
73
- name : Upload Release APK
48
74
uses : actions/upload-artifact@v2
56
82
env :
57
83
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
58
84
with :
59
- tag_name : ${{ steps.set_tag_name.outputs.tag_name }}
60
- release_name : Release ${{ github.ref }}
85
+ tag_name : ${{ steps.set_tag_name.outputs.next_version }}
86
+ release_name : Release ${{ steps.set_tag_name.outputs.next_version }}
61
87
draft : false
62
88
prerelease : false
63
89
0 commit comments