diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index e5e639c..89760be 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -2,7 +2,7 @@ name: Build and Release Android App on: push: branches: - - master + - feat/cd-workflow tags: - v* permissions: @@ -41,8 +41,34 @@ jobs: - name: Set tag name id: set_tag_name run: | - TAG_NAME="v$(date +'%Y%m%d')-${GITHUB_SHA::8}" - echo "::set-output name=tag_name::$TAG_NAME" + # Determine the latest tag and commit messages since that tag + LAST_TAG=$(git describe --tags --abbrev=0) + COMMITS=$(git log --oneline ${LAST_TAG}..HEAD --format="%s") + + # Initialize version components + MAJOR=0 + MINOR=0 + PATCH=0 + + # Analyze commit messages to determine version bump + while read -r line; do + if [[ "$line" == feat:* ]]; then + # Increment minor version for feature commits + ((MINOR++)) + elif [[ "$line" == chore:* ]]; then + # Increment major version for chore commits + ((MAJOR++)) + MINOR=0 # Reset minor version + elif [[ "$line" == fix:* ]]; then + # Increment patch version for fix commits + ((PATCH++)) + fi + done <<< "$COMMITS" + + # Determine the next version based on commit analysis + NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}" + + echo "::set-output name=next_version::$NEXT_VERSION" - name: Upload Release APK uses: actions/upload-artifact@v2 @@ -56,8 +82,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ steps.set_tag_name.outputs.tag_name }} - release_name: Release ${{ github.ref }} + tag_name: ${{ steps.set_tag_name.outputs.next_version }} + release_name: Release ${{ steps.set_tag_name.outputs.next_version }} draft: false prerelease: false