Skip to content

Commit

Permalink
Fix fetch-configlet script
Browse files Browse the repository at this point in the history
Shamelessly dupes @coriolinus' fix: exercism/rust#929

"Looks like Github has recently started returning non-uppercased
HTTP headers, at least some of the time. This broke the script,
which looked for a case-sensitive 'Location' header to find the
newest version. We can see this problem in spurious build failures like this."

"This fixes the script such that it no longer cares whether the initial
L is capital or not, and if it breaks again in the future, it will
give a more informative error."
  • Loading branch information
workingjubilee committed Mar 19, 2020
1 parent 98541c1 commit ca31f71
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bin/fetch-configlet
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -e

LATEST=https://github.com/exercism/configlet/releases/latest

OS=$(
Expand All @@ -26,7 +28,12 @@ case $(uname -m) in
echo 64bit;;
esac)
VERSION="$(curl --head --silent $LATEST | awk -v FS=/ '/Location:/{print $NF}' | tr -d '\r')"
URL=https://github.com/exercism/configlet/releases/download/$VERSION/configlet-$OS-${ARCH}.tgz
VERSION="$(curl --head --silent $LATEST | awk -v FS=/ '/[lL]ocation:/{print $NF}' | tr -d '\r')"
if [ -z "$VERSION" ]; then
echo "Latest configlet release could not be determined; aborting"
exit 1
fi
URL="https://github.com/exercism/configlet/releases/download/$VERSION/configlet-$OS-${ARCH}.tgz"
curl -s --location "$URL" | tar xz -C bin/
curl -sS --location "$URL" | tar xz -C bin/

0 comments on commit ca31f71

Please sign in to comment.