Skip to content

Commit fd5a47b

Browse files
authored
feat: Add continuous deployment for Android with Fastlane.
2 parents de26881 + cb2946a commit fd5a47b

9 files changed

Lines changed: 450 additions & 3 deletions

File tree

.github/workflows/cd.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CD
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
FASTLANE_SUPPLY_JSON_KEY: ${{ secrets.FASTLANE_SUPPLY_JSON_KEY }}
9+
PROD_BASE_URL: ${{ secrets.PROD_BASE_URL }}
10+
RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }}
11+
RELEASE_KEYSTORE_PROPERTIES: ${{ secrets.RELEASE_KEYSTORE_PROPERTIES }}
12+
RELEASE_TYPE: ${{ contains(github.event.release.tag_name, 'internal') && 'internal' || contains(github.event.release.tag_name, 'beta') && 'beta' || 'prod' }}
13+
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
14+
15+
jobs:
16+
deploy:
17+
# This job will run on ubuntu virtual machine
18+
runs-on: ubuntu-latest
19+
# This job will run if the release is based on master branch
20+
if: github.event.release.target_commitish == 'master'
21+
steps:
22+
# Setup Java environment in order to build the Android app.
23+
- uses: actions/checkout@v1
24+
- uses: actions/setup-java@v1
25+
with:
26+
java-version: "12.x"
27+
28+
# Setup Ruby for Fastlane
29+
- uses: ruby/setup-ruby@v1
30+
with:
31+
ruby-version: '2.7.2'
32+
bundler-cache: true
33+
34+
# Setup the flutter environment.
35+
- uses: subosito/flutter-action@v1
36+
with:
37+
channel: "stable"
38+
39+
# Get flutter dependencies.
40+
- run: flutter pub get
41+
42+
# Check for any formatting issues in the code.
43+
- run: flutter format --set-exit-if-changed .
44+
45+
# Statically analyze the Dart code for any errors.
46+
- run: flutter analyze .
47+
48+
# Save supply json key for fastlane
49+
- run: echo "${FASTLANE_SUPPLY_JSON_KEY}" | base64 --decode > android/supply_json_key.json
50+
51+
# Save release props for signing
52+
- run: echo "${RELEASE_KEYSTORE_PROPERTIES}" | base64 --decode > android/key.properties
53+
54+
# Save release keystore for signing
55+
- run: echo "${RELEASE_KEYSTORE}" | base64 --decode > android/app/upload-keystore.jks
56+
57+
# Build appbundle.
58+
- name: 'Development Appbundle'
59+
if: "contains(env.RELEASE_TYPE, 'internal')"
60+
run: flutter build appbundle --flavor development -t lib/main_development.dart --dart-define=SENTRY_DSN=${SENTRY_DSN}
61+
62+
- name: 'Production Appbundle'
63+
if: "!contains(env.RELEASE_TYPE, 'internal')"
64+
run: flutter build appbundle --flavor production -t lib/main_production.dart --dart-define=SENTRY_DSN=${SENTRY_DSN} --dart-define=BASE_URL=${PROD_BASE_URL}
65+
66+
# Run fastlane internal
67+
- uses: maierj/fastlane-action@v2.2.0
68+
with:
69+
lane: ${{ env.RELEASE_TYPE }}
70+
subdirectory: android

android/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ GeneratedPluginRegistrant.java
88

99
# Remember to never publicly share your keystore.
1010
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11+
supply_json_key.json
1112
key.properties
1213
**/*.keystore
1314
**/*.jks

android/Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source "https://rubygems.org"
2+
3+
gem "fastlane"

android/Gemfile.lock

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
CFPropertyList (3.0.5)
5+
rexml
6+
addressable (2.8.0)
7+
public_suffix (>= 2.0.2, < 5.0)
8+
artifactory (3.0.15)
9+
atomos (0.1.3)
10+
aws-eventstream (1.2.0)
11+
aws-partitions (1.595.0)
12+
aws-sdk-core (3.131.1)
13+
aws-eventstream (~> 1, >= 1.0.2)
14+
aws-partitions (~> 1, >= 1.525.0)
15+
aws-sigv4 (~> 1.1)
16+
jmespath (~> 1, >= 1.6.1)
17+
aws-sdk-kms (1.57.0)
18+
aws-sdk-core (~> 3, >= 3.127.0)
19+
aws-sigv4 (~> 1.1)
20+
aws-sdk-s3 (1.114.0)
21+
aws-sdk-core (~> 3, >= 3.127.0)
22+
aws-sdk-kms (~> 1)
23+
aws-sigv4 (~> 1.4)
24+
aws-sigv4 (1.5.0)
25+
aws-eventstream (~> 1, >= 1.0.2)
26+
babosa (1.0.4)
27+
claide (1.1.0)
28+
colored (1.2)
29+
colored2 (3.1.2)
30+
commander (4.6.0)
31+
highline (~> 2.0.0)
32+
declarative (0.0.20)
33+
digest-crc (0.6.4)
34+
rake (>= 12.0.0, < 14.0.0)
35+
domain_name (0.5.20190701)
36+
unf (>= 0.0.5, < 1.0.0)
37+
dotenv (2.7.6)
38+
emoji_regex (3.2.3)
39+
excon (0.92.3)
40+
faraday (1.10.0)
41+
faraday-em_http (~> 1.0)
42+
faraday-em_synchrony (~> 1.0)
43+
faraday-excon (~> 1.1)
44+
faraday-httpclient (~> 1.0)
45+
faraday-multipart (~> 1.0)
46+
faraday-net_http (~> 1.0)
47+
faraday-net_http_persistent (~> 1.0)
48+
faraday-patron (~> 1.0)
49+
faraday-rack (~> 1.0)
50+
faraday-retry (~> 1.0)
51+
ruby2_keywords (>= 0.0.4)
52+
faraday-cookie_jar (0.0.7)
53+
faraday (>= 0.8.0)
54+
http-cookie (~> 1.0.0)
55+
faraday-em_http (1.0.0)
56+
faraday-em_synchrony (1.0.0)
57+
faraday-excon (1.1.0)
58+
faraday-httpclient (1.0.1)
59+
faraday-multipart (1.0.3)
60+
multipart-post (>= 1.2, < 3)
61+
faraday-net_http (1.0.1)
62+
faraday-net_http_persistent (1.2.0)
63+
faraday-patron (1.0.0)
64+
faraday-rack (1.0.0)
65+
faraday-retry (1.0.3)
66+
faraday_middleware (1.2.0)
67+
faraday (~> 1.0)
68+
fastimage (2.2.6)
69+
fastlane (2.206.2)
70+
CFPropertyList (>= 2.3, < 4.0.0)
71+
addressable (>= 2.8, < 3.0.0)
72+
artifactory (~> 3.0)
73+
aws-sdk-s3 (~> 1.0)
74+
babosa (>= 1.0.3, < 2.0.0)
75+
bundler (>= 1.12.0, < 3.0.0)
76+
colored
77+
commander (~> 4.6)
78+
dotenv (>= 2.1.1, < 3.0.0)
79+
emoji_regex (>= 0.1, < 4.0)
80+
excon (>= 0.71.0, < 1.0.0)
81+
faraday (~> 1.0)
82+
faraday-cookie_jar (~> 0.0.6)
83+
faraday_middleware (~> 1.0)
84+
fastimage (>= 2.1.0, < 3.0.0)
85+
gh_inspector (>= 1.1.2, < 2.0.0)
86+
google-apis-androidpublisher_v3 (~> 0.3)
87+
google-apis-playcustomapp_v1 (~> 0.1)
88+
google-cloud-storage (~> 1.31)
89+
highline (~> 2.0)
90+
json (< 3.0.0)
91+
jwt (>= 2.1.0, < 3)
92+
mini_magick (>= 4.9.4, < 5.0.0)
93+
multipart-post (~> 2.0.0)
94+
naturally (~> 2.2)
95+
optparse (~> 0.1.1)
96+
plist (>= 3.1.0, < 4.0.0)
97+
rubyzip (>= 2.0.0, < 3.0.0)
98+
security (= 0.1.3)
99+
simctl (~> 1.6.3)
100+
terminal-notifier (>= 2.0.0, < 3.0.0)
101+
terminal-table (>= 1.4.5, < 2.0.0)
102+
tty-screen (>= 0.6.3, < 1.0.0)
103+
tty-spinner (>= 0.8.0, < 1.0.0)
104+
word_wrap (~> 1.0.0)
105+
xcodeproj (>= 1.13.0, < 2.0.0)
106+
xcpretty (~> 0.3.0)
107+
xcpretty-travis-formatter (>= 0.0.3)
108+
gh_inspector (1.1.3)
109+
google-apis-androidpublisher_v3 (0.21.0)
110+
google-apis-core (>= 0.4, < 2.a)
111+
google-apis-core (0.5.0)
112+
addressable (~> 2.5, >= 2.5.1)
113+
googleauth (>= 0.16.2, < 2.a)
114+
httpclient (>= 2.8.1, < 3.a)
115+
mini_mime (~> 1.0)
116+
representable (~> 3.0)
117+
retriable (>= 2.0, < 4.a)
118+
rexml
119+
webrick
120+
google-apis-iamcredentials_v1 (0.10.0)
121+
google-apis-core (>= 0.4, < 2.a)
122+
google-apis-playcustomapp_v1 (0.7.0)
123+
google-apis-core (>= 0.4, < 2.a)
124+
google-apis-storage_v1 (0.14.0)
125+
google-apis-core (>= 0.4, < 2.a)
126+
google-cloud-core (1.6.0)
127+
google-cloud-env (~> 1.0)
128+
google-cloud-errors (~> 1.0)
129+
google-cloud-env (1.6.0)
130+
faraday (>= 0.17.3, < 3.0)
131+
google-cloud-errors (1.2.0)
132+
google-cloud-storage (1.36.2)
133+
addressable (~> 2.8)
134+
digest-crc (~> 0.4)
135+
google-apis-iamcredentials_v1 (~> 0.1)
136+
google-apis-storage_v1 (~> 0.1)
137+
google-cloud-core (~> 1.6)
138+
googleauth (>= 0.16.2, < 2.a)
139+
mini_mime (~> 1.0)
140+
googleauth (1.1.3)
141+
faraday (>= 0.17.3, < 3.a)
142+
jwt (>= 1.4, < 3.0)
143+
memoist (~> 0.16)
144+
multi_json (~> 1.11)
145+
os (>= 0.9, < 2.0)
146+
signet (>= 0.16, < 2.a)
147+
highline (2.0.3)
148+
http-cookie (1.0.5)
149+
domain_name (~> 0.5)
150+
httpclient (2.8.3)
151+
jmespath (1.6.1)
152+
json (2.6.2)
153+
jwt (2.3.0)
154+
memoist (0.16.2)
155+
mini_magick (4.11.0)
156+
mini_mime (1.1.2)
157+
multi_json (1.15.0)
158+
multipart-post (2.0.0)
159+
nanaimo (0.3.0)
160+
naturally (2.2.1)
161+
optparse (0.1.1)
162+
os (1.1.4)
163+
plist (3.6.0)
164+
public_suffix (4.0.7)
165+
rake (13.0.6)
166+
representable (3.2.0)
167+
declarative (< 0.1.0)
168+
trailblazer-option (>= 0.1.1, < 0.2.0)
169+
uber (< 0.2.0)
170+
retriable (3.1.2)
171+
rexml (3.2.5)
172+
rouge (2.0.7)
173+
ruby2_keywords (0.0.5)
174+
rubyzip (2.3.2)
175+
security (0.1.3)
176+
signet (0.16.1)
177+
addressable (~> 2.8)
178+
faraday (>= 0.17.5, < 3.0)
179+
jwt (>= 1.5, < 3.0)
180+
multi_json (~> 1.10)
181+
simctl (1.6.8)
182+
CFPropertyList
183+
naturally
184+
terminal-notifier (2.0.0)
185+
terminal-table (1.8.0)
186+
unicode-display_width (~> 1.1, >= 1.1.1)
187+
trailblazer-option (0.1.2)
188+
tty-cursor (0.7.1)
189+
tty-screen (0.8.1)
190+
tty-spinner (0.9.3)
191+
tty-cursor (~> 0.7)
192+
uber (0.1.0)
193+
unf (0.1.4)
194+
unf_ext
195+
unf_ext (0.0.8.2)
196+
unicode-display_width (1.8.0)
197+
webrick (1.7.0)
198+
word_wrap (1.0.0)
199+
xcodeproj (1.21.0)
200+
CFPropertyList (>= 2.3.3, < 4.0)
201+
atomos (~> 0.1.3)
202+
claide (>= 1.0.2, < 2.0)
203+
colored2 (~> 3.1)
204+
nanaimo (~> 0.3.0)
205+
rexml (~> 3.2.4)
206+
xcpretty (0.3.0)
207+
rouge (~> 2.0.7)
208+
xcpretty-travis-formatter (1.0.1)
209+
xcpretty (~> 0.2, >= 0.0.7)
210+
211+
PLATFORMS
212+
x86_64-linux
213+
214+
DEPENDENCIES
215+
fastlane
216+
217+
BUNDLED WITH
218+
2.3.15

android/app/build.gradle

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ if (flutterVersionName == null) {
2121
flutterVersionName = '1.0'
2222
}
2323

24+
// keystore configuration
25+
def keystoreProperties = new Properties()
26+
def keystorePropertiesFile = rootProject.file('key.properties')
27+
if (keystorePropertiesFile.exists()) {
28+
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
29+
}
30+
2431
apply plugin: 'com.android.application'
2532
apply plugin: 'kotlin-android'
2633
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
@@ -50,11 +57,24 @@ android {
5057
versionName flutterVersionName
5158
}
5259

60+
signingConfigs {
61+
release {
62+
if (keystorePropertiesFile.exists()) {
63+
keyAlias keystoreProperties['keyAlias']
64+
keyPassword keystoreProperties['keyPassword']
65+
storeFile file(keystoreProperties['storeFile'])
66+
storePassword keystoreProperties['storePassword']
67+
}
68+
}
69+
}
70+
5371
buildTypes {
5472
release {
55-
// TODO: Add your own signing config for the release build.
56-
// Signing with the debug keys for now, so `flutter run --release` works.
57-
signingConfig signingConfigs.debug
73+
if(keystorePropertiesFile.exists()){
74+
signingConfig signingConfigs.release
75+
}else{
76+
signingConfig signingConfigs.debug
77+
}
5878
}
5979
}
6080

@@ -85,6 +105,7 @@ flutter {
85105

86106
dependencies {
87107
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
108+
implementation 'com.google.android.material:material:1.6.1'
88109
}
89110

90111
apply plugin: 'com.google.gms.google-services'

android/fastlane/Appfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
json_key_file("supply_json_key.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
2+
package_name("in.ac.iitr.mdg.codephile") # e.g. com.krausefx.app

android/fastlane/Fastfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This file contains the fastlane.tools configuration
2+
# You can find the documentation at https://docs.fastlane.tools
3+
#
4+
# For a list of all available actions, check out
5+
#
6+
# https://docs.fastlane.tools/actions
7+
#
8+
# For a list of all available plugins, check out
9+
#
10+
# https://docs.fastlane.tools/plugins/available-plugins
11+
#
12+
13+
# Uncomment the line if you want fastlane to automatically update itself
14+
# update_fastlane
15+
16+
default_platform(:android)
17+
18+
platform :android do
19+
desc "Push a new internal build to Play Store"
20+
lane :internal do
21+
upload_to_play_store(
22+
track: "internal",
23+
aab: "../build/app/outputs/bundle/developmentRelease/app-development-release.aab"
24+
)
25+
end
26+
27+
desc "Push a new beta build to Play Store"
28+
lane :beta do
29+
upload_to_play_store(
30+
track: "beta",
31+
aab: "../build/app/outputs/bundle/productionRelease/app-production-release.aab"
32+
)
33+
end
34+
35+
desc "Push a new production build to Play Store"
36+
lane :prod do
37+
upload_to_play_store(
38+
track: "production",
39+
aab: "../build/app/outputs/bundle/productionRelease/app-production-release.aab"
40+
)
41+
end
42+
end

0 commit comments

Comments
 (0)