linkerd2/bin/docker-pull-binaries

44 lines
966 B
Bash
Executable File

#!/usr/bin/env bash
set -eu
if [ $# -eq 1 ]; then
tag=${1:-}
else
echo "usage: ${0##*/} tag" >&2
exit 64
fi
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
rootdir=$( cd "$bindir"/.. && pwd )
# shellcheck source=_docker.sh
. "$bindir"/_docker.sh
workdir=$rootdir/target/release
mkdir -p "$workdir"
# create shorttag where eventual initial v in tag is stripped
shorttag=${tag#v}
# create the cli-bin container in order to extract the binaries
id=$(docker create "$(docker_repo cli-bin):$tag")
OS="darwin windows linux-amd64"
if [ -n "$DOCKER_MULTIARCH" ]; then
OS+=" linux-arm64 linux-arm"
fi
for os in $OS; do
ext=$os
if [ "$os" = windows ]; then
ext=windows.exe
fi
filepath=$workdir/linkerd2-cli-$shorttag-$ext
docker cp "$id:/out/linkerd-$os" "$filepath"
openssl dgst -sha256 "$filepath" | awk '{print $2}' > "$filepath.sha256"
echo "$filepath"
done
# cleanup the cli-bin container when finished
docker rm "$id" > /dev/null