Fix CI APK release process #78
This file contains 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: CI | |
on: [push, pull_request] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 11 | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v2 | |
- name: Build release | |
run: ./gradlew assembleRelease | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: unsigned-app.apk | |
path: app/build/outputs/apk/release/app-release-unsigned.apk | |
if-no-files-found: error | |
deploy: | |
name: Deploy to GitHub Releases | |
needs: build | |
runs-on: ubuntu-22.04 | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Get the APK | |
uses: actions/download-artifact@v2 | |
with: | |
name: unsigned-app.apk | |
path: . | |
- name: Detect latest build tool version | |
shell: bash | |
run: | | |
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) | |
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | |
echo Latest build tool version is: $BUILD_TOOL_VERSION | |
- name: Sign the APK | |
uses: r0adkll/sign-android-release@v1 | |
id: sign_app | |
with: | |
releaseDirectory: . | |
signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }} | |
alias: ${{ secrets.SIGNING_KEY_ALIAS }} | |
keyStorePassword: ${{ secrets.SIGNING_KEY_STORE_PASSWORD }} | |
keyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }} | |
env: | |
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} | |
- name: Publish the APK to GitHub Releases | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
prerelease: true | |
asset_name: httptoolkit.apk | |
file: ${{ steps.sign_app.outputs.signedReleaseFile }} | |
tag: ${{ github.ref }} | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish the APK to Google Play | |
uses: r0adkll/[email protected] | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.PLAY_SERVICE_ACCOUNT_JSON }} | |
packageName: tech.httptoolkit.android.v1 | |
releaseFiles: ${{ steps.sign_app.outputs.signedReleaseFile }} | |
track: production |