Last active
April 14, 2023 20:31
-
-
Save jpeddicord/5710705 to your computer and use it in GitHub Desktop.
Release APK builder that asks for your key passwords interactively, so you don't have to store them in your build script or VCS. For use with the Gradle build system. CC0 license.
This file contains 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
// additional required configuration to hook into the build script | |
android { | |
signingConfigs { | |
release | |
} | |
buildTypes { | |
release { | |
signingConfig signingConfigs.release | |
} | |
} | |
} | |
// specify signing properties on the command line | |
if (hasProperty('storeFile')) { | |
println 'Generating a signed package.' | |
android.signingConfigs.release.storeFile = file(storeFile) | |
android.signingConfigs.release.storePassword = storePassword | |
android.signingConfigs.release.keyAlias = keyAlias | |
android.signingConfigs.release.keyPassword = keyPassword | |
} else { | |
android.buildTypes.release.signingConfig = null | |
} |
This file contains 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
#!/bin/bash | |
if [[ $# -ne 1 ]]; then | |
echo "Usage: $0 keystore" | |
exit 1 | |
fi | |
if [[ ! -f $1 ]]; then | |
echo "$1 doesn't exist or isn't a keystore" | |
exit 1 | |
fi | |
read -s -p "Keystore Password: " STORE_PASS | |
echo | |
read -p "Key Alias: " KEY_ALIAS | |
read -s -p "Key Password: " KEY_PASS | |
echo | |
export ORG_GRADLE_PROJECT_storeFile="$1" | |
export ORG_GRADLE_PROJECT_storePassword="$STORE_PASS" | |
export ORG_GRADLE_PROJECT_keyAlias="$KEY_ALIAS" | |
export ORG_GRADLE_PROJECT_keyPassword="$KEY_PASS" | |
./gradlew signingReport | |
read -p "Is this correct? [y/n] " -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]]; then | |
./gradlew build | |
fi |
Just a note:
In my case it only worked if i used project.hasproperty() instead of only hasproperty()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where should i place release.sh ?