Skip to content

Commit

Permalink
Use non-API requests to fetch GitHub release versions (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
posidron committed Oct 24, 2018
1 parent 8f6bc19 commit fdb23a5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion base/fuzzos/recipes/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ function apt-install-auto () {
}

function get-latest-github-release () {
# Bypass GitHub API RateLimit. Note that we do not follow the redirect.
# shellcheck disable=SC2016
curl -Ls "https://api.github.com/repos/$1/releases/latest" | rg -Nor '$1' '"tag_name": "(.+)"'
retry curl -s "https://github.com/$1/releases/latest" | rg -Nor '$1' 'tag/(.+)"'
}

# In a chrooted 32-bit environment "uname -m" would still return 64-bit.
Expand Down
4 changes: 2 additions & 2 deletions base/fuzzos/recipes/grcov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ source ./recipes/common.sh
#### Install grcov

PLATFORM="linux-x86_64"
LATEST_VERSION=$(get-latest-github-release "marco-c/grcov")
retry curl -LO "https://github.com/marco-c/grcov/releases/download/$LATEST_VERSION/grcov-$PLATFORM.tar.bz2"
LATEST_VERSION=$(get-latest-github-release "mozilla/grcov")
retry curl -LO "https://github.com/mozilla/grcov/releases/download/$LATEST_VERSION/grcov-$PLATFORM.tar.bz2"
tar xf grcov-$PLATFORM.tar.bz2
install grcov /usr/local/bin/grcov
rm grcov grcov-$PLATFORM.tar.bz2
2 changes: 1 addition & 1 deletion base/fuzzos/recipes/rg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source ./recipes/common.sh

#### Install rg (ripgrep)

LATEST_VERSION=$(curl -Ls 'https://api.github.com/repos/BurntSushi/ripgrep/releases/latest' | grep -Po '"tag_name": "\K.*?(?=")')
LATEST_VERSION=$(curl -s "https://github.com/BurntSushi/ripgrep/releases/latest" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}')
retry curl -LO "https://github.com/BurntSushi/ripgrep/releases/download/${LATEST_VERSION}/ripgrep_${LATEST_VERSION}_amd64.deb"
apt install ./"ripgrep_${LATEST_VERSION}_amd64.deb"
rm "ripgrep_${LATEST_VERSION}_amd64.deb"
8 changes: 4 additions & 4 deletions services/linter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ LABEL maintainer Christoph Diehl <cdiehl@mozilla.com>
RUN apk --no-cache add \
curl \
&& HADOLINT_VERSION=$( \
curl -sL 'https://api.github.com/repos/hadolint/hadolint/releases/latest' \
| grep '"tag_name":' \
| sed -E 's/.*"([^"]+)".*/\1/' \
) \
curl -sL "https://github.com/hadolint/hadolint/releases/latest" \
| grep -o 'tag/[v.0-9]*' \
| awk -F/ '{print $2}' \
) \
&& curl -sL -o /bin/hadolint "https://github.com/hadolint/hadolint/releases/download/$HADOLINT_VERSION/hadolint-Linux-x86_64" \
&& chmod +x /bin/hadolint \
&& curl -sL https://storage.googleapis.com/shellcheck/shellcheck-latest.linux.x86_64.tar.xz \
Expand Down

0 comments on commit fdb23a5

Please sign in to comment.