chore: use bash script to download signing key

This commit is contained in:
Akash Yadav
2023-01-07 15:24:25 +05:30
parent def9704fac
commit 57378f878c
2 changed files with 42 additions and 16 deletions
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
set -eu
dest=$1
url=$2
user=$3
pass=$4
if [ "$dest" == "" ]; then
echo "Please specify destination file"
exit 1
fi
if [ "$url" == "" ]; then
echo "Please specify signing key URL"
exit 1
fi
if [ "$user" == "" ]; then
echo "Please specify auth user"
exit 1
fi
if [ "$pass" == "" ]; then
echo "Please specify auth password"
exit 1
fi
if [ -f "$dest" ]; then
echo "Skipping signing key download as $dest already exists"
exit 0
fi
# Download silently to prevent URL/user/pass being exposed
curl -s -u "$user:$pass" --output "$dest" $url
+5 -15
View File
@@ -1,14 +1,11 @@
@file:Suppress("UnstableApiUsage")
import de.undercouch.gradle.tasks.download.DownloadAction
plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-kapt")
id("kotlin-parcelize")
id("com.google.android.gms.oss-licenses-plugin")
id("de.undercouch.download") version "5.3.0"
}
android {
@@ -167,19 +164,12 @@ fun downloadSigningKey() {
val pass = getEnvOrProp(AUTH_PASS) ?: return
logger.info("Downloading signing key...")
DownloadAction(project).apply {
src(url)
dest(signingKey)
username(user)
password(pass)
overwrite(false)
val result = exec {
workingDir(rootProject.projectDir)
commandLine("bash", "./.tools/download_key.sh", signingKey.absolutePath, url, user, pass)
}
// Must be set to true
quiet(true)
}.execute()
// wait for the download to finish
.get()
result.assertNormalExitValue()
}
fun getEnvOrProp(key: String): String? {