Skip to content

Deploy Android

Deploy Android #2

name: "Deploy Android"
on:
workflow_dispatch:
inputs:
next_version:
description: "Version to be used in pubspec.yaml"
type: string
required: true
workflow_call:
inputs:
next_version:
description: "Version to be used in pubspec.yaml"
type: string
required: true
secrets:
ANDROID_APP_KEYSTORE_FILE:
required: true
ANDROID_APP_KEY_PROPERTIES_FILE:
required: true
APP_SYNC_API_KEY:
required: true
GOOGLE_PLAY_CONSOLE_API_KEY_FILE:
required: true
jobs:
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: "Setup empty .env.local"
run: sed 's/APP_SYNC_API_KEY.*/APP_SYNC_API_KEY="${{ secrets.APP_SYNC_API_KEY }}"/' .env > .env.local
- name: "Setup keystore properties"
env:
# 1. `base64 -i key.properties -o key.base64`
# 2. `pbcopy < key.base64` and paste without a newline
ANDROID_APP_KEY_PROPERTIES_FILE: ${{ secrets.ANDROID_APP_KEY_PROPERTIES_FILE }}
run: |
echo $ANDROID_APP_KEY_PROPERTIES_FILE | base64 --decode > ./android/key.properties
- name: "Setup keystore"
env:
# 1. `base64 -i upload-keystore.jks -o upload-keystore.base64`
# 2. `pbcopy < upload-keystore.base64` and paste without a newline
ANDROID_APP_KEYSTORE_FILE: ${{ secrets.ANDROID_APP_KEYSTORE_FILE }}
run: |
echo $ANDROID_APP_KEYSTORE_FILE | base64 --decode > ./android/upload-keystore.jks
- name: "Determine Flutter Version"
id: flutter-version
run: echo "FLUTTER_VERSION=$(jq -r ".flutterSdkVersion" .fvm/fvm_config.json)" >> $GITHUB_OUTPUT
- name: "Setup Flutter"
uses: subosito/[email protected]
with:
flutter-version: ${{ steps.flutter-version.outputs.FLUTTER_VERSION }}
cache: true
- name: "Set build version"
run: yq -i '.version = "${{ inputs.next_version }}"' pubspec.yaml
- name: "Build aab file"
run: flutter build appbundle --release
# TODO maybe also build & upload apk for easier testing
- name: "Upload aab artifact"
uses: actions/[email protected]
with:
name: android-aab
path: build/app/outputs/bundle/release/app-release.aab
deploy:
needs: build
name: "Deploy"
runs-on: ubuntu-latest
# environment:
# name: TODO provide way to test android
# url: TODO link it's url (testing the newest test artifact)
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile
steps:
- name: "Checkout"
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: "Setup Ruby"
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
with:
# using .ruby-version
# installing gems automatically
bundler-cache: true # requires BUNDLE_GEMFILE
- name: "Setup API key"
env:
# 1. `base64 -i play-store-credentials.json -o play-store-credentials.base64`
# 2. `pbcopy < play-store-credentials.base64` and paste without a newline
GOOGLE_PLAY_CONSOLE_API_KEY_FILE: ${{ secrets.GOOGLE_PLAY_CONSOLE_API_KEY_FILE }}
run: |
echo $GOOGLE_PLAY_CONSOLE_API_KEY_FILE | base64 --decode > ./android/play-store-credentials.json
- name: "Download abb artifact"
uses: actions/[email protected]
with:
name: android-aab
- name: "Deploy via Fastlane"
run: bundle exec fastlane android_deploy