Setup fastlane to build app, release on Google Play and create git tag

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2023-02-02 16:26:23 +01:00
parent bed7449f1d
commit a02624d7e2
No known key found for this signature in database
GPG key ID: 2585783189A62105
3 changed files with 102 additions and 15 deletions

1
.gitignore vendored
View file

@ -8,3 +8,4 @@
/projectFilesBackup/ /projectFilesBackup/
# fastlane # fastlane
/vendor/bundle /vendor/bundle
fastlane/report.xml

View file

@ -1,3 +1,3 @@
source "https://rubygems.org" source "https://rubygems.org"
gem "fastlane" gem "fastlane"

View file

@ -13,23 +13,109 @@
# Uncomment the line if you want fastlane to automatically update itself # Uncomment the line if you want fastlane to automatically update itself
# update_fastlane # update_fastlane
## config
# add following to your shell rc:
# export FASTLANE_NOTES_UPLOAD_STORE_FILE=""
# export FASTLANE_NOTES_UPLOAD_STORE_PASSWORD=""
# export FASTLANE_NOTES_UPLOAD_KEY_ALIAS=""
# export FASTLANE_NOTES_UPLOAD_KEY_PASSWORD=""
# export FASTLANE_NEXTCLOUD_GITHUB_API_TOKEN=""
skip_docs skip_docs
default_platform(:android) default_platform(:android)
platform :android do BUNDLE_PATH = "app/build/outputs/bundle/playRelease/app-play-release.aab"
desc "Submit a new Beta Build to Crashlytics Beta"
lane :beta do platform :android do
gradle(task: "clean assembleRelease") desc "Build app bundle"
crashlytics
lane :releasePhase1 do
# sh "your_script.sh" test()
# You can also use other beta testing services here buildBundle()
end end
lane :test do
gradle(task: "clean testPlayReleaseUnitTest testFdroidReleaseUnitTest")
end
lane :buildBundle do
gradle(
task: 'bundle',
flavor: 'play',
build_type: 'Release',
print_command: false,
properties: {
"android.injected.signing.store.file" => ENV["FASTLANE_NOTES_UPLOAD_STORE_FILE"],
"android.injected.signing.store.password" => ENV["FASTLANE_NOTES_UPLOAD_STORE_PASSWORD"],
"android.injected.signing.key.alias" => ENV["FASTLANE_NOTES_UPLOAD_KEY_ALIAS"],
"android.injected.signing.key.password" => ENV["FASTLANE_NOTES_UPLOAD_KEY_PASSWORD"],
}
)
end
lane :releasePhase2 do
versionInfo = getVersionInfo()
promptVersion(versionInfo)
checkArtifactsExist()
tag(versionInfo)
uploadToPlayStore()
end
desc "Read versions from gradle file"
private_lane :getVersionInfo do
File.open("../app/build.gradle","r") do |file|
text = file.read
versionName = text.match(/versionName "([0-9\.]*)"$/)[1]
versionCode = text.match(/versionCode ([0-9]*)$/)[1]
{ "versionCode" => versionCode, "versionName" => versionName }
end
end
desc "Show versions and prompt for confirmation"
private_lane :promptVersion do |versionInfo|
currentBranch = git_branch()
print "Version code: #{versionInfo["versionCode"]}\n"
print "Version name: #{versionInfo["versionName"]}\n"
print "Current branch: #{currentBranch}\n"
print "Tag (to be created): #{versionInfo["versionName"]}\n"
answer = prompt(text: "is this okay?", boolean: true)
if !answer
exit
end
end
desc "Check if release artifacts exist"
private_lane :checkArtifactsExist do
if !File.exist?("../#{BUNDLE_PATH}")
print "Bundle not found at #{BUNDLE_PATH}\n"
exit
end
end
desc "Create release tag"
private_lane :tag do |versionInfo|
tagName = versionInfo["versionName"]
add_git_tag(
tag: tagName,
sign: true
)
push_git_tags(tag: tagName)
end
desc "Upload release artifacts to Google Play"
private_lane :uploadToPlayStore do
upload_to_play_store(
skip_upload_images: true,
skip_upload_apk: true,
aab: BUNDLE_PATH,
)
end
desc "Deploy a new version to the Google Play"
lane :deploy do
gradle(task: "clean assembleRelease")
upload_to_play_store
end
end end