Release Deployment #147
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: Release Deployment | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-gms-flavor: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| VERSION_NAME: ${{ steps.version.outputs.VERSION_NAME }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Android Environment | |
| uses: ./.github/actions/setup-android-env | |
| - name: Extract versionName | |
| id: version | |
| run: | | |
| VERSION_NAME=$(grep -oP 'versionName\s+"\K[^"]+' app/build.gradle || echo "0.0.0") | |
| echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_OUTPUT | |
| - name: Build APK & Bundle for Github and Google Play | |
| run: ./gradlew assembleGmsRelease bundleGmsRelease --no-daemon --parallel --build-cache --configuration-cache | |
| - name: Sign APK for Github release | |
| uses: r0adkll/sign-android-release@v1 | |
| with: | |
| releaseDirectory: app/build/outputs/apk/gms/release | |
| signingKeyBase64: ${{ secrets.SIGNING_KEY }} | |
| alias: ${{ secrets.ALIAS }} | |
| keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | |
| keyPassword: ${{ secrets.KEY_PASSWORD }} | |
| env: | |
| BUILD_TOOLS_VERSION: "34.0.0" | |
| - name: Rename Github APK file | |
| run: mv app/build/outputs/apk/gms/release/app-gms-release-unsigned-signed.apk app/build/outputs/apk/gms/release/app-release.apk | |
| - name: Upload APK to Github release artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: github-release-apk | |
| path: app/build/outputs/apk/gms/release/app-release.apk | |
| - name: Sign bundle for Google Play release | |
| uses: r0adkll/sign-android-release@v1 | |
| with: | |
| releaseDirectory: app/build/outputs/bundle/gmsRelease | |
| signingKeyBase64: ${{ secrets.SIGNING_KEY }} | |
| alias: ${{ secrets.ALIAS }} | |
| keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | |
| keyPassword: ${{ secrets.KEY_PASSWORD }} | |
| - name: Rename Google Play bundle file | |
| run: mv app/build/outputs/bundle/gmsRelease/app-gms-release.aab app/build/outputs/bundle/gmsRelease/app-release.aab | |
| - name: Upload bundle to Github release artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: google-play-bundle | |
| path: app/build/outputs/bundle/gmsRelease/app-release.aab | |
| build-foss-flavor: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Android Environment | |
| uses: ./.github/actions/setup-android-env | |
| - name: Build APK for Github release | |
| run: ./gradlew assembleFossRelease --no-daemon --parallel --build-cache --configuration-cache | |
| - name: Sign APK for Github release | |
| uses: r0adkll/sign-android-release@v1 | |
| with: | |
| releaseDirectory: app/build/outputs/apk/foss/release | |
| signingKeyBase64: ${{ secrets.SIGNING_KEY }} | |
| alias: ${{ secrets.ALIAS }} | |
| keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | |
| keyPassword: ${{ secrets.KEY_PASSWORD }} | |
| env: | |
| BUILD_TOOLS_VERSION: "34.0.0" | |
| - name: Rename Github APK file | |
| run: mv app/build/outputs/apk/foss/release/app-foss-release-unsigned-signed.apk app/build/outputs/apk/foss/release/app-release-foss.apk | |
| - name: Upload APK to Github release artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: github-foss-release-apk | |
| path: app/build/outputs/apk/foss/release/app-release-foss.apk | |
| publish-built-files: | |
| permissions: | |
| contents: write | |
| needs: | |
| [ | |
| "build-gms-flavor", | |
| "build-foss-flavor" | |
| ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Download APK from Github release artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: github-release-apk | |
| path: . | |
| - name: Download foss APK from Github release artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: github-foss-release-apk | |
| path: . | |
| - name: Download Google Play bundle from Github release artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: google-play-bundle | |
| path: . | |
| - name: Create Github release using release-drafter | |
| id: create_release | |
| uses: release-drafter/release-drafter@v7 | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| tag: v${{ needs.build-gms-flavor.outputs.VERSION_NAME }} | |
| name: v${{ needs.build-gms-flavor.outputs.VERSION_NAME }} | |
| - name: Upload APK to Github release | |
| id: upload_release_asset | |
| uses: shogo82148/actions-upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: app-release.apk | |
| asset_name: app-release.apk | |
| asset_content_type: application/zip | |
| overwrite: true | |
| - name: Upload foss APK to Github release | |
| id: upload_foss_release_asset | |
| uses: shogo82148/actions-upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: app-release-foss.apk | |
| asset_name: app-release-foss.apk | |
| asset_content_type: application/zip | |
| overwrite: true | |
| - name: Publish Github release | |
| uses: eregon/publish-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| release_id: ${{ steps.create_release.outputs.id }} | |
| - name: Create service_account.json for Google Play release | |
| run: echo '${{ secrets.SERVICE_ACCOUNT_JSON }}' > service_account.json | |
| - name: Publish bundle to Google Play | |
| uses: r0adkll/upload-google-play@v1 | |
| with: | |
| serviceAccountJson: service_account.json | |
| packageName: com.doubleangels.nextdnsmanagement | |
| releaseFiles: app-release.aab | |
| track: production | |
| whatsNewDirectory: whatsnew | |
| delete-workflow-runs: | |
| permissions: | |
| actions: write | |
| needs: | |
| [ | |
| "build-gms-flavor", | |
| "publish-built-files" | |
| ] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Delete workflow runs | |
| uses: Mattraks/delete-workflow-runs@v2 | |
| with: | |
| token: ${{ github.token }} | |
| repository: ${{ github.repository }} | |
| retain_days: 30 | |
| keep_minimum_runs: 5 |