github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/hack/buildkit-ref (about) 1 #!/usr/bin/env bash 2 # This script returns the current BuildKit ref and source repository being used. 3 # This script will only work with a BuildKit repository hosted on GitHub. 4 # 5 # The output of this script may be valid shell script, but is intended for use with 6 # GitHub Actions' $GITHUB_ENV. 7 8 buildkit_pkg=github.com/moby/buildkit 9 10 # get buildkit version from vendor.mod 11 buildkit_ref=$(./hack/with-go-mod.sh go list -mod=mod -modfile=vendor.mod -u -m -f '{{if .Replace}}{{.Replace.Version}}{{else}}{{.Version}}{{end}}' "$buildkit_pkg") 12 buildkit_repo=$(./hack/with-go-mod.sh go list -mod=mod -modfile=vendor.mod -u -m -f '{{if .Replace}}{{.Replace.Path}}{{else}}{{.Path}}{{end}}' "$buildkit_pkg") 13 buildkit_repo=${buildkit_repo#github.com/} 14 15 if [[ "${buildkit_ref}" == *-*-* ]]; then 16 # if pseudo-version, figure out just the uncommon sha (https://github.com/golang/go/issues/34745) 17 buildkit_ref=$(awk -F"-" '{print $NF}' <<< "$buildkit_ref" | awk 'BEGIN{FIELDWIDTHS="7"} {print $1}') 18 # use github api to return full sha to be able to use it as ref 19 buildkit_ref=$(curl -s "https://api.github.com/repos/${buildkit_repo}/commits/${buildkit_ref}" | jq -r .sha) 20 fi 21 22 cat << EOF 23 BUILDKIT_REPO=$buildkit_repo 24 BUILDKIT_REF=$buildkit_ref 25 EOF