Skip to content

Commit a02624d

Browse files
committed
Setup fastlane to build app, release on Google Play and create git tag
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
1 parent bed7449 commit a02624d

3 files changed

Lines changed: 102 additions & 15 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
/projectFilesBackup/
99
# fastlane
1010
/vendor/bundle
11+
fastlane/report.xml

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
source "https://rubygems.org"
22

3-
gem "fastlane"
3+
gem "fastlane"

fastlane/Fastfile

Lines changed: 100 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,109 @@
1313
# Uncomment the line if you want fastlane to automatically update itself
1414
# update_fastlane
1515

16+
## config
17+
# add following to your shell rc:
18+
# export FASTLANE_NOTES_UPLOAD_STORE_FILE=""
19+
# export FASTLANE_NOTES_UPLOAD_STORE_PASSWORD=""
20+
# export FASTLANE_NOTES_UPLOAD_KEY_ALIAS=""
21+
# export FASTLANE_NOTES_UPLOAD_KEY_PASSWORD=""
22+
# export FASTLANE_NEXTCLOUD_GITHUB_API_TOKEN=""
23+
24+
1625
skip_docs
1726

1827
default_platform(:android)
1928

29+
BUNDLE_PATH = "app/build/outputs/bundle/playRelease/app-play-release.aab"
30+
2031
platform :android do
21-
desc "Submit a new Beta Build to Crashlytics Beta"
22-
lane :beta do
23-
gradle(task: "clean assembleRelease")
24-
crashlytics
25-
26-
# sh "your_script.sh"
27-
# You can also use other beta testing services here
28-
end
29-
30-
desc "Deploy a new version to the Google Play"
31-
lane :deploy do
32-
gradle(task: "clean assembleRelease")
33-
upload_to_play_store
34-
end
32+
desc "Build app bundle"
33+
34+
lane :releasePhase1 do
35+
test()
36+
buildBundle()
37+
end
38+
39+
lane :test do
40+
gradle(task: "clean testPlayReleaseUnitTest testFdroidReleaseUnitTest")
41+
end
42+
43+
lane :buildBundle do
44+
gradle(
45+
task: 'bundle',
46+
flavor: 'play',
47+
build_type: 'Release',
48+
print_command: false,
49+
properties: {
50+
"android.injected.signing.store.file" => ENV["FASTLANE_NOTES_UPLOAD_STORE_FILE"],
51+
"android.injected.signing.store.password" => ENV["FASTLANE_NOTES_UPLOAD_STORE_PASSWORD"],
52+
"android.injected.signing.key.alias" => ENV["FASTLANE_NOTES_UPLOAD_KEY_ALIAS"],
53+
"android.injected.signing.key.password" => ENV["FASTLANE_NOTES_UPLOAD_KEY_PASSWORD"],
54+
}
55+
)
56+
end
57+
58+
lane :releasePhase2 do
59+
versionInfo = getVersionInfo()
60+
promptVersion(versionInfo)
61+
checkArtifactsExist()
62+
tag(versionInfo)
63+
uploadToPlayStore()
64+
end
65+
66+
desc "Read versions from gradle file"
67+
private_lane :getVersionInfo do
68+
File.open("../app/build.gradle","r") do |file|
69+
text = file.read
70+
versionName = text.match(/versionName "([0-9\.]*)"$/)[1]
71+
versionCode = text.match(/versionCode ([0-9]*)$/)[1]
72+
73+
{ "versionCode" => versionCode, "versionName" => versionName }
74+
end
75+
end
76+
77+
desc "Show versions and prompt for confirmation"
78+
private_lane :promptVersion do |versionInfo|
79+
currentBranch = git_branch()
80+
print "Version code: #{versionInfo["versionCode"]}\n"
81+
print "Version name: #{versionInfo["versionName"]}\n"
82+
print "Current branch: #{currentBranch}\n"
83+
print "Tag (to be created): #{versionInfo["versionName"]}\n"
84+
85+
86+
answer = prompt(text: "is this okay?", boolean: true)
87+
88+
if !answer
89+
exit
90+
end
91+
end
92+
93+
desc "Check if release artifacts exist"
94+
private_lane :checkArtifactsExist do
95+
if !File.exist?("../#{BUNDLE_PATH}")
96+
print "Bundle not found at #{BUNDLE_PATH}\n"
97+
exit
98+
end
99+
end
100+
101+
102+
desc "Create release tag"
103+
private_lane :tag do |versionInfo|
104+
tagName = versionInfo["versionName"]
105+
add_git_tag(
106+
tag: tagName,
107+
sign: true
108+
)
109+
push_git_tags(tag: tagName)
110+
end
111+
112+
desc "Upload release artifacts to Google Play"
113+
private_lane :uploadToPlayStore do
114+
upload_to_play_store(
115+
skip_upload_images: true,
116+
skip_upload_apk: true,
117+
aab: BUNDLE_PATH,
118+
)
119+
end
120+
35121
end

0 commit comments

Comments
 (0)