1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/hack/buildkit-ref
CrazyMax 32f0561715
ci: buildkit integration test
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-03-23 16:07:04 +01:00

24 lines
864 B
Bash
Executable file

#!/usr/bin/env bash
# This script returns the current BuildKit ref being used in moby.
: "${BUILDKIT_REPO=moby/buildkit}"
: "${BUILDKIT_REF=}"
if [ -n "$BUILDKIT_REF" ]; then
echo "$BUILDKIT_REF"
exit 0
fi
# prepare go mod
./hack/go-mod-prepare.sh
# get buildkit version from vendor.mod
BUILDKIT_REF=$(GO111MODULE=on go list -mod=mod -modfile=vendor.mod -u -m -f '{{.Version}}' "github.com/${BUILDKIT_REPO}")
if [[ "${BUILDKIT_REF}" == *-*-* ]]; then
# if pseudo-version, figure out just the uncommon sha (https://github.com/golang/go/issues/34745)
BUILDKIT_REF=$(echo "${BUILDKIT_REF}" | awk -F"-" '{print $NF}' | awk 'BEGIN{FIELDWIDTHS="7"} {print $1}')
# use github api to return full sha to be able to use it as ref
BUILDKIT_REF=$(curl -s "https://api.github.com/repos/${BUILDKIT_REPO}/commits/${BUILDKIT_REF}" | jq -r .sha)
fi
echo "$BUILDKIT_REF"