Skip to content

Commit 9889ec9

Browse files
fix: CD for android apk
1 parent a4822b2 commit 9889ec9

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

.github/workflows/android-build.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build and Release Android App
22
on:
33
push:
44
branches:
5-
- master
5+
- feat/cd-workflow
66
tags:
77
- v*
88
permissions:
@@ -41,8 +41,34 @@ jobs:
4141
- name: Set tag name
4242
id: set_tag_name
4343
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"
4672
4773
- name: Upload Release APK
4874
uses: actions/upload-artifact@v2
@@ -56,8 +82,8 @@ jobs:
5682
env:
5783
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5884
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 }}
6187
draft: false
6288
prerelease: false
6389

0 commit comments

Comments
 (0)