Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Github API to download binaries. #394

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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