Created
November 18, 2022 01:01
-
-
Save narenmanoharan/63023f053e66ab759fd9d3ce778fd7d7 to your computer and use it in GitHub Desktop.
CLI script to upload android apks to wolfia
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 | |
set -eo pipefail | |
if [[ -z ${WOLFIA_API_KEY_ID+x} ]]; then | |
echo "Please set WOLFIA_API_KEY_ID in your environment variable. You can learn how to generate an API key here (https://wolfia.com/docs/#generate-an-api-key)" | |
elif [[ -z ${WOLFIA_API_KEY_SECRET+x} ]]; then | |
echo "Please set WOLFIA_API_KEY_SECRET in your environment variable." | |
elif (( $# != 1 )); then | |
echo "Please provide the path of apk to be uploaded (eg. ../Downloads/clubhouse.apk)" | |
echo "Usage ./wolfia.sh ANDROID_APK_PATH (required)" | |
else | |
ANDROID_APK_PATH="$1" | |
echo | |
echo "Uploading apk to wolfia..." | |
MAGIC_LINK=$(curl --progress-bar --show-error --request POST \ | |
--url https://api.wolfia.com/magic-links \ | |
--header "X-Api-Key-Id: $WOLFIA_API_KEY_ID" \ | |
--header "X-Api-Key-Secret: $WOLFIA_API_KEY_SECRET" \ | |
--form "file=@$ANDROID_APK_PATH") | |
echo | |
echo $MAGIC_LINK | grep -o '"link": "[^"]*' | grep -o '[^"]*$' | sed 's/^/Wolfia magic link: /' | |
echo $MAGIC_LINK | grep -o '"packageName": "[^"]*' | grep -o '[^"]*$' | sed 's/^/Package name: /' | |
echo $MAGIC_LINK | grep -o '"versionCode": [^,]*' | grep -oE '[0-9]+' | sed 's/^/Version code: /' | |
echo | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
./wolfia_upload.sh ../../Downloads/clubhouse.apk Uploading apk to wolfia... ############################################################################################### 100.0% Wolfia magic link: https://wolfia.com/magic-link/6fb26888-48ac-4104-98c9-1616d6b1dee0 Package name: com.clubhouse.app Version code: 1017059