Skip to content

Commit

Permalink
Adjust the method to check for Not Found response
Browse files Browse the repository at this point in the history
  • Loading branch information
mallardduck committed Oct 8, 2024
1 parent 9dabd5b commit 48f69c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/pull-scripts
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ if [[ "$OS" == "windows" ]]; then
else
BINARY_NAME="charts-build-scripts_${OS}_${ARCH}"
fi
curl -s -L ${CHARTS_BUILD_SCRIPTS_REPO%.git}/releases/download/${CHARTS_BUILD_SCRIPT_VERSION}/${BINARY_NAME} --output bin/charts-build-scripts
response_code=$(curl -s -o bin/charts-build-scripts -w "%{http_code}" -L "${CHARTS_BUILD_SCRIPTS_REPO%.git}/releases/download/${CHARTS_BUILD_SCRIPT_VERSION}/${BINARY_NAME}")

# Fall back to binary name format from old release scheme
if ! [[ -f bin/charts-build-scripts ]] || [[ $(cat bin/charts-build-scripts) == "Not Found" ]]; then
if ! [[ -f bin/charts-build-scripts ]] || [[ "$response_code" == "404" ]]; then
echo "Falling back to old binary name format..."
rm bin/charts-build-scripts;
if [[ ${OS} == "linux" ]]; then
BINARY_NAME=charts-build-scripts
else
BINARY_NAME=charts-build-scripts-${OS}
fi
curl -s -L ${CHARTS_BUILD_SCRIPTS_REPO%.git}/releases/download/${CHARTS_BUILD_SCRIPT_VERSION}/${BINARY_NAME} --output bin/charts-build-scripts
response_code=$(curl -s -o bin/charts-build-scripts -w "%{http_code}" -L "${CHARTS_BUILD_SCRIPTS_REPO%.git}/releases/download/${CHARTS_BUILD_SCRIPT_VERSION}/${BINARY_NAME}")
fi

# If falling back to old binary name format did not work, fail
if ! [[ -f bin/charts-build-scripts ]] || [[ $(cat bin/charts-build-scripts) == "Not Found" ]]; then
if ! [[ -f bin/charts-build-scripts ]] || [[ "$response_code" == "404" ]]; then
echo "Failed to find charts-build-scripts binary"
rm bin/charts-build-scripts;
exit 1
Expand Down

0 comments on commit 48f69c0

Please sign in to comment.