Last active
January 9, 2023 10:18
-
-
Save shakir915/77575eb4b0877f661a2850ddf08713aa to your computer and use it in GitHub Desktop.
upload apk from gradle curl (put inside android{ } block)
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
//upload Signed Build to testfairy | |
//https://gist.github.com/shakir915/77575eb4b0877f661a2850ddf08713aa | |
gradle.buildFinished { | |
def uploaded_urls = [] | |
def folders = [] | |
def apksPaths = [] | |
try { | |
gradle.startParameter.taskNames.forEach { task -> | |
if (task.contains("assemble") && task.contains("Release")) { | |
android.applicationVariants.all { variant -> | |
if (task.toLowerCase().contains(variant.name.toLowerCase())) { | |
variant.outputs.each { output -> | |
apksPaths.add("${output.outputFile}") | |
} | |
} | |
} | |
folders.add(rootProject.name + (task.replaceAll("app:", "").replaceAll("assemble", "").replaceAll("Release", "").replaceAll(":", ""))) | |
} | |
} | |
println("Trying APK Upload...") | |
def api_key = ['curl', "-v", "https://api.jsonbin.io/v3/b/638883ff7966e84526d11177",].execute().text.split("\"KEY\":\"")[1].split("\"}")[0] | |
apksPaths.eachWithIndex { apksPath, index -> | |
println("${index + 1} APK Upload...${folders[index]} $apksPath") | |
def jsonString = ['curl', "-v", "https://upload.testfairy.com/api/upload", '-F', api_key, "-F", "folder_name=${folders[index]}", "-F", "file=@$apksPath "].execute().text | |
println("jsonString $jsonString") | |
uploaded_urls.add(jsonString.split("landing_page_url\":\"")[1].split("\"}")[0]) | |
} | |
} catch (e) { | |
e.printStackTrace() | |
} | |
println("\n\n\n") | |
uploaded_urls.eachWithIndex { url, index -> | |
println("» ${folders[index]} ${url}") | |
} | |
println("\n") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment