Skip to content

Commit

Permalink
Use Github API to download binaries.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmatias committed Sep 20, 2022
1 parent 32680d4 commit bf3af3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
11 changes: 3 additions & 8 deletions global_install_scripts/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ function run() {
}
export -f echo_success

function collect_version_artifact_download_urls() {
curl -Ls -w %{url_effective} "https://github.com/${INSTALL_ORG_REPO}/releases/latest" | grep -Eo '/'${INSTALL_ORG_REPO}'/releases/download/.+/[^/"]+' | sed 's/^/https:\/\/github.com/' >${TEMP_DIR}/download_urls
echo_debug "All release artifact download urls can be found at ${TEMP_DIR}/download_urls:"
[[ -z "${DEBUG}" ]] && return
cat ${TEMP_DIR}/download_urls
}

function operating_system() {
OS=$(uname -s)
Expand Down Expand Up @@ -135,7 +129,9 @@ function run() {

function download() {
OBJECT=$1
DOWNLOAD_URL=$(grep 'http.*'${OBJECT}'$' ${TEMP_DIR}/download_urls)
DOWNLOAD_URL=$(curl -Ls https://api.github.com/repos/"$INSTALL_ORG_REPO"/releases/latest |
grep download_url | awk '{print $2}' | tr -d '"' | grep "$OBJECT")

echo_debug "Downloading ${OBJECT} from ${DOWNLOAD_URL}"
curl --location --silent ${DOWNLOAD_URL} >${TEMP_DIR}/${OBJECT}
}
Expand Down Expand Up @@ -399,7 +395,6 @@ END_OF_SCRIPT
# would be good to create a separate script which does the upgrade and the initial install
if [[ ! -x ${TALISMAN_SETUP_DIR}/${TALISMAN_BINARY_NAME} || ! -x ${TALISMAN_HOOK_SCRIPT_PATH} || -n ${FORCE_DOWNLOAD} ]]; then
echo "Downloading talisman binary"
collect_version_artifact_download_urls
download_talisman_binary
echo
echo "Setting up talisman binary and helper script in $HOME/.talisman"
Expand Down
11 changes: 3 additions & 8 deletions global_install_scripts/update_talisman.bash
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ function run() {
}
export -f echo_success

function collect_version_artifact_download_urls() {
curl -Ls -w %{url_effective} "https://github.com/${INSTALL_ORG_REPO}/releases/latest" | grep -Eo '/'${INSTALL_ORG_REPO}'/releases/download/.+/[^/"]+' | sed 's/^/https:\/\/github.com/' >${TEMP_DIR}/download_urls
echo_debug "All release artifact download urls can be found at ${TEMP_DIR}/download_urls:"
[[ -z "${DEBUG}" ]] && return
cat ${TEMP_DIR}/download_urls
}

function operating_system() {
OS=$(uname -s)
Expand Down Expand Up @@ -113,7 +107,9 @@ function run() {
function download() {
echo_debug "Running download()"
OBJECT=$1
DOWNLOAD_URL=$(grep 'http.*'${OBJECT}'$' ${TEMP_DIR}/download_urls)
DOWNLOAD_URL=$(curl -Ls https://api.github.com/repos/"$INSTALL_ORG_REPO"/releases/latest |
grep download_url | awk '{print $2}' | tr -d '"' | grep "$OBJECT")

echo_debug "Downloading ${OBJECT} from ${DOWNLOAD_URL}"
curl --location --silent ${DOWNLOAD_URL} >${TEMP_DIR}/${OBJECT}
}
Expand Down Expand Up @@ -177,7 +173,6 @@ function run() {

set_talisman_binary_name
echo "Downloading latest talisman binary..."
collect_version_artifact_download_urls
download_talisman_binary
setup_talisman
if [ -z "$UPDATE_TYPE" ]; then
Expand Down

0 comments on commit bf3af3f

Please sign in to comment.