Skip to content

Commit 3f1243d

Browse files
authored
Publish signed android build to GooglePlay Console (#1728)
* [CI] add first draft to publish to playconsole from Github Actions * fix melos command for building the playconsole binary * try fix release binary location and log output directory * add cupertino icons to fix warning * try fix build location * [CI] properly setup google play console upload * setup code signing for android release builds * rename workflow * fix keystore path * polish android release workflow * don't sign f-droid builds * try forcing f-droid flavors to not sign * try fixing signing * Revert "try fixing signing" This reverts commit a2a0f64. * try fixing signing * add `noSign` signing config * fix `noSign` signing config * avoid null error for unused signing config * remove redundant android_build.yml, and add some documentation * remove empty.keystore approach - it is not needed after all
1 parent b3333e8 commit 3f1243d

File tree

7 files changed

+97
-52
lines changed

7 files changed

+97
-52
lines changed

.github/workflows/android_build.yml

-38
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Android Build and Deploy
2+
3+
on:
4+
push:
5+
branches: [ master, beta ]
6+
tags:
7+
- "*"
8+
pull_request:
9+
branches: [ master, beta ]
10+
11+
# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is
12+
# triggered (ref https://stackoverflow.com/a/72408109)
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build-and-deploy:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Keystore
26+
env:
27+
KEYSTORE_BASE64: ${{ secrets.GOOGLE_PLAY_KEYSTORE_BASE64 }}
28+
run: |
29+
echo "$KEYSTORE_BASE64" | base64 --decode > app/android/app/my-release-key.jks
30+
31+
- name: Create key.properties
32+
# Keystore has only one key, hence the storePassword and the keyPassword are the same.
33+
run: |
34+
cat <<EOF > app/android/key.properties
35+
storePassword=${{ secrets.GOOGLE_PLAY_KEYSTORE_PASSWORD }}
36+
keyPassword=${{ secrets.GOOGLE_PLAY_KEYSTORE_PASSWORD }}
37+
keyAlias=${{ secrets.GOOGLE_PLAY_KEY_ALIAS }}
38+
storeFile=my-release-key.jks
39+
EOF
40+
41+
- name: Install flutter wrapper
42+
run: ./scripts/install_flutter_wrapper.sh
43+
44+
- name: Get dependencies (i.e., melos)
45+
run: .flutter/bin/dart pub get
46+
47+
- name: Melos Bootstrap
48+
run: .flutter/bin/dart run melos bootstrap
49+
50+
- name: Build Android AppBundle
51+
run: |
52+
.flutter/bin/dart run melos build-appbundle-play
53+
echo "Check release files"
54+
ls app/build/app/outputs/bundle/playRelease
55+
56+
- name: Deploy to Google Play (Beta)
57+
# Only deploy if we are on beta
58+
if: github.ref == 'refs/heads/beta'
59+
uses: r0adkll/upload-google-play@v1
60+
with:
61+
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_JSON }}
62+
packageName: org.encointer.wallet
63+
releaseFiles: app/build/app/outputs/bundle/playRelease/app-play-release.aab
64+
track: beta # Publish to the beta track

.github/workflows/fdroid.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ jobs:
1717
runs-on: ubuntu-latest
1818
timeout-minutes: 30
1919
steps:
20-
# Setup Environment
2120
- uses: actions/checkout@v4
2221

22+
# The following steps are executed with those scripts, as this is how we build
23+
# the app in the f-droid pipeline too.
2324
- name: Check fdroid setup
2425
run: ./scripts/fdroid_init.sh
2526

app/android/app/build.gradle

+20-11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ if (localPropertiesFile.exists()) {
1212
}
1313
}
1414

15+
def keystoreProperties = new Properties()
16+
def keystorePropertiesFile = rootProject.file("key.properties")
17+
if (keystorePropertiesFile.exists()) {
18+
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
19+
}
20+
1521
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1622
if (flutterVersionCode == null) {
1723
flutterVersionCode = '1'
@@ -59,18 +65,22 @@ android {
5965
versionName flutterVersionName
6066
}
6167

68+
signingConfigs {
69+
play {
70+
keyAlias keystoreProperties['keyAlias']
71+
keyPassword keystoreProperties['keyPassword']
72+
// Avoid null error if file doesn't exist, as gradle evaluates the statements even
73+
// if the signing config is not used.
74+
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
75+
storePassword keystoreProperties['storePassword']
76+
}
77+
}
78+
6279
buildTypes {
6380
release {
64-
// AppCenter will take care of signing, so the bundle may not be signed here.
65-
// uncomment the following line if you need to sign locally and provide all
66-
// credentials and jsk file path in ../key.properties
67-
// also uncomment the signing config referenced
68-
//signingConfig signingConfigs.release
69-
70-
// To run `flutter run --release` locally, uncomment the following line
71-
//signingConfig signingConfigs.debug
72-
7381
minifyEnabled true
82+
shrinkResources true
83+
debuggable false
7484
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
7585
}
7686
}
@@ -79,7 +89,6 @@ android {
7989
productFlavors {
8090
dev {
8191
dimension "deploy"
82-
signingConfig signingConfigs.debug
8392
versionNameSuffix "-dev"
8493
}
8594
fdroid {
@@ -89,7 +98,7 @@ android {
8998
}
9099
play {
91100
dimension "deploy"
92-
//signingConfig signingConfigs.release
101+
signingConfig signingConfigs.play
93102
versionNameSuffix ""
94103
}
95104
}

app/pubspec.lock

+8
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,14 @@ packages:
305305
url: "https://pub.dev"
306306
source: hosted
307307
version: "1.0.0"
308+
cupertino_icons:
309+
dependency: "direct main"
310+
description:
311+
name: cupertino_icons
312+
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
313+
url: "https://pub.dev"
314+
source: hosted
315+
version: "1.0.8"
308316
dart_geohash:
309317
dependency: "direct main"
310318
description:

app/pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ environment:
2525
dependencies:
2626
collection: ^1.18.0
2727
convert: ^3.1.1
28+
cupertino_icons: ^1.0.8
2829
latlong2: ^0.9.0
2930
# intl - format numbers
3031
intl: ^0.18.1

melos.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ scripts:
111111
run: cd app && flutter build apk --split-per-abi --flavor dev
112112
description: "Build an APK file"
113113

114-
build-appbundle-release:
115-
run: cd app && flutter build appbundle --release
114+
build-appbundle-play:
115+
run: cd app && flutter build appbundle --release --flavor play
116116
description: "Build an appbundle file ready to be submitted to the google play console"
117117

118118
build-ipa-release:

0 commit comments

Comments
 (0)