OpenTagViewer Android App v1.0.4 #11
Workflow file for this run
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: Generate APK (Release) | |
| env: | |
| # The name of the main module repository | |
| main_project_module: app | |
| # The name of the App | |
| app_name: OpenTagViewer | |
| KEYSTORE_FILE: release-keystore.jks | |
| ALIAS: upload | |
| on: | |
| release: | |
| types: published | |
| jobs: | |
| build: | |
| environment: 'Android Build Release' | |
| runs-on: ubuntu-latest | |
| # Only run this for 'android-app-v<whatever>' tags! | |
| if: | | |
| github.event_name == 'release' | |
| && (github.event.release.prerelease == true || github.event.release.published_at != null) | |
| && startsWith(github.event.release.tag_name, 'android-app-v') | |
| steps: | |
| - name: Extract Version from Tag | |
| id: extract_version | |
| run: | | |
| # GITHUB_REF for tags is like 'refs/tags/android-app-v1.0.3.1' | |
| FULL_TAG_NAME="${{ github.ref }}" | |
| # Remove 'refs/tags/' prefix to get 'android-app-v1.0.3.1' | |
| TAG_WITHOUT_PREFIX="${FULL_TAG_NAME##refs/tags/}" | |
| # Find the index of '-v' | |
| # This will be 'android-app-' part, then we add 2 to skip '-v' | |
| START_INDEX=$(( $(echo "$TAG_WITHOUT_PREFIX" | awk -F'-v' '{print length($1)}') + 2 )) | |
| # Extract everything from '-v' onwards | |
| # Using cut or substring if available, or just awk | |
| VERSION_STRING=$(echo "$TAG_WITHOUT_PREFIX" | cut -c "$START_INDEX"-) | |
| # Output the extracted version as a step output | |
| echo "Extracted version: $VERSION_STRING" | |
| # !! this is reused below | |
| echo "APP_VERSION=$VERSION_STRING" >> $GITHUB_OUTPUT | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Set Current Date As Env Variable | |
| - name: Set current date as env variable | |
| run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
| # Set Repository Name As Env Variable | |
| - name: Set repository name as env variable | |
| run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV | |
| - name: Set Up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' # See 'Supported distributions' for available options | |
| java-version: '17' | |
| cache: 'gradle' | |
| - name: Change wrapper permissions | |
| run: chmod +x ./gradlew | |
| - name: Create local.properties | |
| run: | | |
| echo "sdk.dir=$ANDROID_HOME" > local.properties | |
| - name: Inject secrets.properties | |
| run: | | |
| echo "MAPS_API_KEY=${{ secrets.MAPS_API_KEY }}" > secrets.properties | |
| - name: Recreate release keystore | |
| run: | | |
| echo "${{ secrets.SIGNING_KEY }}" | base64 --decode > ${{ env.main_project_module }}/${{ env.KEYSTORE_FILE }} | |
| - name: Run gradle tests | |
| run: ./gradlew test | |
| - name: Build gradle project | |
| run: ./gradlew build -x lint | |
| env: | |
| KEYSTORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} | |
| KEY_ALIAS: ${{ env.ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| - name: Build APK Debug | |
| run: | | |
| ./gradlew assembleDebug | |
| # rename debug build | |
| mv ${{ env.main_project_module }}/build/outputs/apk/debug/app-debug.apk ${{ env.main_project_module }}/build/outputs/apk/debug/${{ env.app_name }}-${{ steps.extract_version.outputs.APP_VERSION }}-debug.apk | |
| env: | |
| KEYSTORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} | |
| KEY_ALIAS: ${{ env.ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| - name: Build APK Release | |
| run: | | |
| ./gradlew assembleRelease | |
| # rename release build | |
| mv ${{ env.main_project_module }}/build/outputs/apk/release/app-release.apk ${{ env.main_project_module }}/build/outputs/apk/release/${{ env.app_name }}-${{ steps.extract_version.outputs.APP_VERSION }}.apk | |
| env: | |
| KEYSTORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} | |
| KEY_ALIAS: ${{ env.ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| # Create Bundle AAB Release | |
| # Noted for main module build [main_project_module]:bundleRelease | |
| # - name: Build app bundle release (AAB) - ${{ env.main_project_module }} module | |
| # run: ./gradlew ${{ env.main_project_module }}:bundleRelease | |
| # Upload Artifact Build | |
| # Noted For Output [main_project_module]/build/outputs/apk/debug/ | |
| - name: Upload APK Debug | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.date_today }} - ${{ env.app_name }} - ${{ env.repository_name }} - APK(s) debug generated | |
| path: ${{ env.main_project_module }}/build/outputs/apk/debug/ | |
| # Noted For Output [main_project_module]/build/outputs/apk/release/ | |
| - name: Upload APK Release | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.date_today }} - ${{ env.app_name }} - ${{ env.repository_name }} - APK(s) release generated | |
| path: ${{ env.main_project_module }}/build/outputs/apk/release/ | |
| - name: Upload APK Release Asset to GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| if: github.event_name == 'release' | |
| with: | |
| files: ${{ env.main_project_module }}/build/outputs/apk/release/${{ env.app_name }}-${{ steps.extract_version.outputs.APP_VERSION }}.apk | |
| name: ${{ env.app_name }} Android App ${{ steps.extract_version.outputs.APP_VERSION }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.ANDROID_BUILD_RELEASE_GITHUB_TOKEN }} | |
| # Noted For Output [main_project_module]/build/outputs/bundle/release/ | |
| # - name: Upload AAB (App Bundle) Release - ${{ env.repository_name }} | |
| # uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: ${{ env.date_today }} - ${{ env.app_name }} - ${{ env.repository_name }} - App bundle(s) AAB release generated | |
| # path: ${{ env.main_project_module }}/build/outputs/bundle/release/ |