Build Release APK #46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Release APK | |
| on: | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| build: | |
| name: Build Release APK | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Java and Android SDK | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Decode Keystore | |
| id: decode_keystore | |
| uses: timheuer/base64-to-file@v1 | |
| with: | |
| fileName: 'keystore/key.jks' | |
| encodedString: ${{ secrets.SIGN_KEY }} | |
| - name: Build GitHub Release APK | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew clean assembleProdRelease --no-build-cache --no-configuration-cache --no-daemon --rerun-tasks | |
| env: | |
| SIGNING_KEY_ALIAS: ${{ secrets.ALIAS }} | |
| SIGNING_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| SIGNING_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} | |
| - name: Extract Version Name and Version Code | |
| run: | | |
| # Extract versionName and versionCode from build.gradle | |
| VERSION_NAME=$(cat app/build.gradle | grep -oP 'versionName "\K[^"]*') | |
| VERSION_CODE=$(cat app/build.gradle | grep -oP 'versionCode \K\d+') | |
| echo "Version Name: $VERSION_NAME" | |
| echo "Version Code: $VERSION_CODE" | |
| # Set these values as environment variables for later steps | |
| echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV | |
| echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV | |
| - name: Set Tag | |
| run: | | |
| TAG=$(echo ${{ env.VERSION_NAME }} | tr '[:upper:]' '[:lower:]') | |
| echo "TAG=${TAG}" >> $GITHUB_ENV | |
| echo "Tag: ${TAG}" # Print tag to console | |
| - name: Archive APKs | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.VERSION_NAME }} APKs | |
| path: app/build/outputs/apk/prod/release/app-prod-release.apk | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| app/**/prod/release/*.apk | |
| name: ${{ env.VERSION_NAME }} # Use the original case for the release name | |
| tag_name: ${{ env.TAG }} # Use lowercase for the tag | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |