buildkit-ref 864 B

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