-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Expand file tree
/
Copy pathbuildkit-ref
More file actions
executable file
·28 lines (23 loc) · 1.2 KB
/
buildkit-ref
File metadata and controls
executable file
·28 lines (23 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
# This script returns the current BuildKit ref and source repository being used.
# This script will only work with a BuildKit repository hosted on GitHub.
#
# The output of this script may be valid shell script, but is intended for use with
# GitHub Actions' $GITHUB_ENV.
buildkit_pkg=github.com/moby/buildkit
# get buildkit version from go.mod
buildkit_ref=$(go list -mod=mod -u -m -f '{{if .Replace}}{{.Replace.Version}}{{else}}{{.Version}}{{end}}' "$buildkit_pkg")
buildkit_repo=$(go list -mod=mod -u -m -f '{{if .Replace}}{{.Replace.Path}}{{else}}{{.Path}}{{end}}' "$buildkit_pkg")
buildkit_repo=${buildkit_repo#github.com/}
if [[ "${buildkit_ref}" == *-*-* ]]; then
# if pseudo-version, figure out just the uncommon sha (https://github.com/golang/go/issues/34745)
buildkit_ref=$(awk -F"-" '{print $NF}' <<< "$buildkit_ref" | 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
# Needed by v0.25.0-rc1
buildkit_ref="e4d7acb44d7e29b594445a36c5cc28be44740142"
cat << EOF
BUILDKIT_REPO=$buildkit_repo
BUILDKIT_REF=$buildkit_ref
EOF