- Flutter Production
- Step 1 Generate Keystores
- Step 2 Base64 encode & decode
- Step 3 Gradle Configuration
- Step 4 Automation (Optional)
A guide to prepare release configuration for flutter.
Covering how to make signed app to publish on PlayStore / using Google related API. It's also cover how to setup secure release automation for Github Action.
keytool -genkey -v -keystore ~/debug.keystore -storepass android -keypass android -alias androiddebugkey -dname "CN=Android Debug,O=Android,C=US"
keytool -genkey -v -keystore debug-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias androiddebugkey -storetype JKS
keytool -genkey -v -keystore ~/release.keystore -alias androidreleasekey
keytool -genkey -v -keystore release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias androidreleasekey -storetype JKS
# encode .jks file
openssl base64 -in key.jks
# decode base64 file (windows)
type base64.txt | openssl base64 -d > output.jks
# decode base64 file (UNIX)
base64 -d <<< base64.txt > output.jks
// apply from...
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
// defaultConfig{}...
signingConfigs {
debug {
storeFile file('debug-key.jks')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
storeFile file('release-key.jks'
storePassword "$System.env.KEY_PASSWORD"
keyAlias 'androidreleasekey'
keyPassword "$System.env.ALIAS_PASSWORD"
}
}
Github action for flutter release.
- Build apk and appbundle package
- Upload artifacts of apk and appbundle
- Push to "release" branch
Path: /.github/workflows/release.yml
name: ✔ Flutter Release
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_android_mobile:
name: 🛠 Build Flutter (Android)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "11"
- uses: subosito/flutter-action@v2
with:
flutter-version: "2.8.0"
- run: flutter clean
- run: flutter pub get
- name: 🔧 Build APK
env:
KEY_JKS: ${{ secrets.KEY_JKS }}
KEY_PASSWORD: ${{ secrets.ALIAS_PASSWORD }}
ALIAS_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: base64 -d <<< $KEY_JKS > ./android/app/release-key.jks && flutter build apk --release -v
- name: 🔧 Build AppBundle
env:
KEY_JKS: ${{ secrets.KEY_JKS }}
KEY_PASSWORD: ${{ secrets.ALIAS_PASSWORD }}
ALIAS_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: base64 -d <<< $KEY_JKS > ./android/app/release-key.jks && flutter build appbundle --release -v
- name: 📦 Upload apk artifact
uses: actions/upload-artifact@v2
with:
name: apk
path: build/app/outputs/apk/release/app-release.apk
- name: 📦 Upload appbundle artifact
uses: actions/upload-artifact@v2
with:
name: appbundle
path: build/app/outputs/bundle/release/app-release.aab
- name: 🚛 Upload to Release Branch
uses: s0/git-publish-subdir-action@develop
env:
REPO: self
BRANCH: release
FOLDER: build/app/outputs/apk/release
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MESSAGE: "Build: ({sha}) {msg}"