@@ -2,8 +2,6 @@ name: Release
22
33on :
44 push :
5- tags :
6- - ' v*'
75 branches :
86 - main
97 paths :
@@ -50,10 +48,11 @@ jobs:
5048 uses : actions/checkout@v4
5149 with :
5250 fetch-depth : 2 # Need history for version comparison
51+ token : ${{ secrets.GITHUB_TOKEN }}
5352
54- - name : Check if version changed (for config.gradle trigger)
53+ - name : Check version change
5554 id : check_version
56- if : github.event_name == 'push' && contains(github.event.head_commit.modified, 'config.gradle')
55+ if : github.event_name == 'push'
5756 run : |
5857 # Get current version from config.gradle
5958 CURRENT_VERSION=$(grep versionName config.gradle | sed -E 's/.*versionName:\s*"([^"]+)".*/\1/')
@@ -84,15 +83,11 @@ jobs:
8483 echo "✅ Version increased from $PREV_VERSION to $CURRENT_VERSION"
8584 echo "should_release=true" >> $GITHUB_OUTPUT
8685 echo "version=v$CURRENT_VERSION" >> $GITHUB_OUTPUT
87-
88- # Check if tag already exists
89- if git ls-remote --tags origin | grep -q "refs/tags/v${CURRENT_VERSION}$"; then
90- echo "⚠️ Tag v$CURRENT_VERSION already exists, skipping release"
91- echo "should_release=false" >> $GITHUB_OUTPUT
92- fi
86+ echo "version_code=$CURRENT_CODE" >> $GITHUB_OUTPUT
9387 else
94- echo "ℹ️ No version increase detected or invalid version "
88+ echo "ℹ️ No version increase detected"
9589 echo "should_release=false" >> $GITHUB_OUTPUT
90+ exit 0
9691 fi
9792
9893 - name : Determine version
@@ -103,29 +98,32 @@ jobs:
10398 echo "should_release=true" >> $GITHUB_OUTPUT
10499 elif [ "${{ steps.check_version.outputs.should_release }}" = "true" ]; then
105100 VERSION="${{ steps.check_version.outputs.version }}"
106- elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
107- VERSION="${{ github.ref_name }}"
108- echo "should_release=true" >> $GITHUB_OUTPUT
109101 else
110- VERSION="v0.0.0 "
111- echo "should_release=false" >> $GITHUB_OUTPUT
102+ echo "No release needed "
103+ exit 0
112104 fi
113105 echo "version=$VERSION" >> $GITHUB_OUTPUT
114106 echo "Version: $VERSION"
115107
116108 - name : Extract version code
117109 id : version_info
118110 run : |
119- # Extract version code from config.gradle - handle both formats
111+ # Extract version code from config.gradle
120112 VERSION_CODE=$(grep "versionCode:" config.gradle | sed -E 's/.*versionCode:\s*([0-9]+).*/\1/')
121113 echo "version_code=$VERSION_CODE" >> $GITHUB_OUTPUT
122114 echo "Version Code: $VERSION_CODE"
123115
124- - name : Create tag if version changed
125- if : steps.check_version.outputs.should_release == 'true' && github.event_name == 'push' && contains(github.event.head_commit.modified, 'config.gradle')
116+ - name : Create and push tag
117+ if : steps.check_version.outputs.should_release == 'true' && github.event_name == 'push'
126118 run : |
127119 TAG_NAME="${{ steps.version.outputs.version }}"
128120
121+ # Check if tag already exists
122+ if git ls-remote --tags origin | grep -q "refs/tags/${TAG_NAME}$"; then
123+ echo "⚠️ Tag $TAG_NAME already exists"
124+ exit 0
125+ fi
126+
129127 git config user.name "github-actions[bot]"
130128 git config user.email "github-actions[bot]@users.noreply.github.com"
131129
@@ -138,7 +136,7 @@ jobs:
138136 build-apk :
139137 name : Build Release APK
140138 needs : prepare
141- if : needs.prepare.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
139+ if : needs.prepare.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch'
142140 runs-on : ubuntu-latest
143141
144142 steps :
@@ -214,7 +212,7 @@ jobs:
214212 build-aab :
215213 name : Build Release Bundle
216214 needs : prepare
217- if : needs.prepare.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
215+ if : needs.prepare.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch'
218216 runs-on : ubuntu-latest
219217
220218 steps :
@@ -277,7 +275,7 @@ jobs:
277275 release :
278276 name : Create GitHub Release
279277 needs : [prepare, build-apk, build-aab]
280- if : needs.prepare.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
278+ if : needs.prepare.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch'
281279 runs-on : ubuntu-latest
282280
283281 steps :
@@ -351,7 +349,7 @@ jobs:
351349 play-store-upload :
352350 name : Upload to Play Store
353351 needs : [prepare, build-aab]
354- if : ${{ (needs.prepare.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') ) && vars.ENABLE_PLAY_STORE_UPLOAD == 'true' && vars.ENABLE_SIGNING == 'true' }}
352+ if : ${{ (needs.prepare.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch') && vars.ENABLE_PLAY_STORE_UPLOAD == 'true' && vars.ENABLE_SIGNING == 'true' }}
355353 runs-on : ubuntu-latest
356354
357355 steps :
@@ -461,7 +459,7 @@ jobs:
461459 download-signed-apk :
462460 name : Download Google Play Signed APK
463461 needs : [prepare, play-store-upload]
464- if : ${{ (needs.prepare.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') ) && vars.ENABLE_PLAY_STORE_UPLOAD == 'true' && vars.ENABLE_SIGNING == 'true' }}
462+ if : ${{ (needs.prepare.outputs.should_release == 'true' || github.event_name == 'workflow_dispatch') && vars.ENABLE_PLAY_STORE_UPLOAD == 'true' && vars.ENABLE_SIGNING == 'true' }}
465463 runs-on : ubuntu-latest
466464
467465 steps :
0 commit comments