Release Deployment #17
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 | |
| concurrency: | |
| group: deploy-release | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| VERSION_NAME: ${{ steps.version.outputs.VERSION_NAME }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: "temurin" | |
| cache: gradle | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Run Android Lint | |
| run: ./gradlew lintRelease --no-daemon | |
| - name: Run Unit Tests | |
| run: ./gradlew testReleaseUnitTest --no-daemon | |
| - 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 and Bundle | |
| run: ./gradlew assembleRelease bundleRelease --no-daemon --parallel --build-cache | |
| - name: Sign APK for GitHub release | |
| uses: r0adkll/sign-android-release@v1 | |
| with: | |
| releaseDirectory: app/build/outputs/apk/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 APK for GitHub release | |
| run: mv app/build/outputs/apk/release/app-release-unsigned-signed.apk app/build/outputs/apk/release/app-release.apk | |
| - name: Upload APK to GitHub release artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: github-release-apk | |
| path: app/build/outputs/apk/release/app-release.apk | |
| - name: Sign bundle for Google Play release | |
| uses: r0adkll/sign-android-release@v1 | |
| with: | |
| releaseDirectory: app/build/outputs/bundle/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: Upload bundle to GitHub release artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: google-play-bundle | |
| path: app/build/outputs/bundle/release/app-release.aab | |
| publish: | |
| permissions: | |
| contents: write | |
| needs: ["build"] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Download APK from GitHub release artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: github-release-apk | |
| path: . | |
| - name: Download bundle from GitHub release artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: google-play-bundle | |
| path: . | |
| - name: Create GitHub release using release-drafter | |
| id: create_release | |
| uses: release-drafter/release-drafter@v6 | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| tag: v${{ needs.build.outputs.VERSION_NAME }} | |
| name: v${{ needs.build.outputs.VERSION_NAME }} | |
| - name: Upload APK to GitHub release | |
| 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/vnd.android.package-archive | |
| 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 | |
| env: | |
| SERVICE_ACCOUNT_JSON: ${{ secrets.SERVICE_ACCOUNT_JSON }} | |
| run: printf '%s' "$SERVICE_ACCOUNT_JSON" > service_account.json | |
| - name: Publish bundle to Google Play | |
| uses: r0adkll/upload-google-play@v1.1.3 | |
| with: | |
| serviceAccountJson: service_account.json | |
| packageName: com.doubleangels.redact | |
| releaseFiles: app-release.aab | |
| track: production | |
| whatsNewDirectory: whatsnew | |
| - name: Set up Ruby for Fastlane | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.3" | |
| - name: Install Fastlane | |
| run: gem install fastlane | |
| - name: Push Fastlane metadata to Play Store | |
| run: fastlane supply --skip_upload_apk true --skip_upload_aab true --json_key service_account.json --package_name com.doubleangels.redact --track production | |
| delete-workflow-runs: | |
| permissions: | |
| actions: write | |
| needs: ["build", "publish"] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Delete workflow runs | |
| uses: Mattraks/delete-workflow-runs@v2.1.0 | |
| with: | |
| token: ${{ github.token }} | |
| repository: ${{ github.repository }} | |
| retain_days: 30 | |
| keep_minimum_runs: 5 |