Created
January 13, 2019 19:32
-
-
Save monday8am/45a55bd699e3bc710d80deaceaefd4cc to your computer and use it in GitHub Desktop.
Create signed Android app. Fastlane + Gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Create a signed version of the app" | |
lane :signed_apk do | |
# get version and build number from git | |
# https://blog.uncommon.is/using-git-to-generate-versionname-and-versioncode-for-android-apps-aaa9fc2c96af | |
versionName = sh("git describe --dirty").gsub(/\s+/, "") | |
# +520 to sync version codes with the previous app. | |
versionCode = sh("git rev-list --first-parent --count origin/master").gsub(/\s+/, "").to_i + 520 | |
keyPath ="#{sh("pwd").chomp}/keystore.jks" | |
# build the release variant | |
gradle( | |
task: "assembleRelease", | |
print_command: true, | |
# Gradle properties | |
properties: { | |
"android.injected.signing.store.file" => keyPath, | |
"android.injected.signing.store.password" => ENV['KEYSTORE_PASSWORD'], | |
"android.injected.signing.key.alias" => ENV['KEY_ALIAS'], | |
"android.injected.signing.key.password" => ENV['KEY_PASSWORD'], | |
"versionCode" => versionCode, | |
"versionName" => versionName | |
} | |
) | |
puts "Created signed apk. VersionName: #{versionName}. VersionCode: #{versionCode}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment