Flutter Android Release Build on GitHub Actions
๐ท๏ธ
Photo by Richy Great on Unsplash
workflow.yml
ใปใใจๅ็ดใง keystore ใ็จๆใใฆ๏ผใใใใ local.properties ใไฝๆใใฆ build ใใฆใใใ ใใงใใญ๏ผ
flavor ใ่ใใใจใคใใใงใใ่ชๅใฎใฑใผในใฎๅ ดๅใฏ โ dart-define=<foo=bar> ใงๆธใใฑใผในใใปใจใใฉใงใ๏ผ
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
channel: 'stable'
- run: echo "${{secrets.ANDROID_RELEASE_BASE64_KEY}}" | base64 -d > ./keystore.jks
- run: echo "keyAlias=keystore" >> android/key.properties
- run: echo "keyPassword=${{secrets.ANDROID_RELEASE_KEY_PASSWORD}}" >> android/key.properties
- run: echo "storeFile=`pwd`/keystore.jks" >> android/key.properties
- run: echo "storePassword=${{secrets.ANDROID_RELEASE_STORE_PASSWORD}}" >> android/key.properties
- name: build apk
run: flutter build apk --build-number ${GITHUB_RUN_NUMBER}
- name: deploygate
run: |
curl \
-H "Authorization: token ${{secrets.DEPLOYGATE_API_KEY}}" \
-F "file=@build/app/outputs/flutter-apk/app-release.apk" \
"https://deploygate.com/api/users/{username}/apps"
android/app/build.gradle
ไธใงไฝๆใใ key.properties ใ่ชญใใใใซใใพใ๏ผ
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(newFileInputStream(keystorePropertiesFile))
}signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}