exercism / v2-configlet

Tool to assist in managing Exercism language tracks.
MIT License
16 stars 23 forks source link

fetch-configlet: Unrecognized Archive Format #188

Closed Stargator closed 3 years ago

Stargator commented 3 years ago

I am running a MacOS.

I have tar and this is the output of tar --version:

bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.6

Output when I run fetch-configlet:

./bin/fetch-configlet tar: Error opening archive: Unrecognized archive format

I am able to run fetch-canonical_data_syncer with no issues. Probably because it uses a zip file and not tgz

SleeplessByte commented 3 years ago

The old script was broken for all repositories without telling anyone.

Here is the new script:

NOTE That this will download 3.9.2: https://github.com/exercism/configlet/releases/tag/v3.9.2

Stargator commented 3 years ago

@SleeplessByte Thanks, but that still gives me the same issue, but the newest version in master as of October 13th works properly. I guess I didn't realize I had an outdated version.

#!/usr/bin/env bash

set -eo pipefail

readonly LATEST='https://api.github.com/repos/exercism/configlet/releases/latest'

case "$(uname)" in
    (Darwin*)   OS='mac'     ;;
    (Linux*)    OS='linux'   ;;
    (Windows*)  OS='windows' ;;
    (MINGW*)    OS='windows' ;;
    (MSYS_NT-*) OS='windows' ;;
    (*)         OS='linux'   ;;
esac

case "$OS" in
    (windows*) EXT='zip' ;;
    (*)        EXT='tgz' ;;
esac

case "$(uname -m)" in
    (*64*)  ARCH='64bit' ;;
    (*686*) ARCH='32bit' ;;
    (*386*) ARCH='32bit' ;;
    (*)     ARCH='64bit' ;;
esac

if [ -z "${GITHUB_TOKEN}" ]
then
    HEADER=''
else
    HEADER="authorization: Bearer ${GITHUB_TOKEN}"
fi

FILENAME="configlet-${OS}-${ARCH}.${EXT}"

get_url () {
    curl --header "$HEADER" -s "$LATEST" |
        awk -v filename=$FILENAME '$1 ~ /browser_download_url/ && $2 ~ filename { print $2 }' |
        tr -d '"'
}

URL=$(get_url)

case "$EXT" in
    (*zip)
        curl --header "$HEADER" -s --location "$URL" -o bin/latest-configlet.zip
        unzip bin/latest-configlet.zip -d bin/
        rm bin/latest-configlet.zip
        ;;
    (*) curl --header "$HEADER" -s --location "$URL" | tar xz -C bin/ ;;
esac
SleeplessByte commented 3 years ago

Ah I might have copied the wrong one. Sorry! But you got there 🤗