Skip to content

Commit

Permalink
Merge pull request #3718 from saschagrunert/krel-sources
Browse files Browse the repository at this point in the history
Build krel from sources when not using default `TOOL_*` values
  • Loading branch information
k8s-ci-robot authored Aug 21, 2024
2 parents 9650471 + 1de3359 commit a53bb39
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
3 changes: 3 additions & 0 deletions gcb/fast-forward/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ steps:
dir: go/src/k8s.io/release
env:
- KREL_OUTPUT_PATH=/workspace/bin/krel
- "TOOL_ORG=${_TOOL_ORG}"
- "TOOL_REPO=${_TOOL_REPO}"
- "TOOL_REF=${_TOOL_REF}"
args:
- ./hack/get-krel

Expand Down
3 changes: 3 additions & 0 deletions gcb/obs-release/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ steps:
dir: go/src/k8s.io/release
env:
- KREL_OUTPUT_PATH=/workspace/bin/krel
- "TOOL_ORG=${_TOOL_ORG}"
- "TOOL_REPO=${_TOOL_REPO}"
- "TOOL_REF=${_TOOL_REF}"
args:
- ./hack/get-krel

Expand Down
3 changes: 3 additions & 0 deletions gcb/obs-stage/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ steps:
dir: go/src/k8s.io/release
env:
- KREL_OUTPUT_PATH=/workspace/bin/krel
- "TOOL_ORG=${_TOOL_ORG}"
- "TOOL_REPO=${_TOOL_REPO}"
- "TOOL_REF=${_TOOL_REF}"
args:
- ./hack/get-krel

Expand Down
3 changes: 3 additions & 0 deletions gcb/release/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ steps:
dir: go/src/k8s.io/release
env:
- KREL_OUTPUT_PATH=/workspace/bin/krel
- "TOOL_ORG=${_TOOL_ORG}"
- "TOOL_REPO=${_TOOL_REPO}"
- "TOOL_REF=${_TOOL_REF}"
args:
- ./hack/get-krel

Expand Down
3 changes: 3 additions & 0 deletions gcb/stage/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ steps:
dir: go/src/k8s.io/release
env:
- KREL_OUTPUT_PATH=/workspace/bin/krel
- "TOOL_ORG=${_TOOL_ORG}"
- "TOOL_REPO=${_TOOL_REPO}"
- "TOOL_REF=${_TOOL_REF}"
args:
- ./hack/get-krel

Expand Down
24 changes: 18 additions & 6 deletions hack/get-krel
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,29 @@ curl_retry() {
curl -sSfL --retry 5 --retry-delay 3 "$@"
}

DEFAULT_TOOL_ORG=kubernetes
DEFAULT_TOOL_REPO=release
DEFAULT_TOOL_REF=master

TOOL_ORG=${TOOL_ORG:-${DEFAULT_TOOL_ORG}}
TOOL_REPO=${TOOL_REPO:-${DEFAULT_TOOL_REPO}}
TOOL_REF=${TOOL_REF:-${DEFAULT_TOOL_REF}}
KREL_OUTPUT_PATH=${KREL_OUTPUT_PATH:-bin/krel}
echo "Using output path: $KREL_OUTPUT_PATH"
mkdir -p "$(dirname "$KREL_OUTPUT_PATH")"

LATEST_RELEASE=$(curl_retry https://api.github.com/repos/kubernetes/release/releases/latest | jq -r .tag_name)
echo "Using krel release: $LATEST_RELEASE"
if [[ "$TOOL_ORG" == "$DEFAULT_TOOL_ORG" && "$TOOL_REPO" == "$DEFAULT_TOOL_REPO" && "$TOOL_REF" == "$DEFAULT_TOOL_REF" ]]; then
LATEST_RELEASE=$(curl_retry https://api.github.com/repos/kubernetes/release/releases/latest | jq -r .tag_name)
echo "Using krel release: $LATEST_RELEASE"

echo "Downloading krel from GCB bucket…"
GCB_URL="https://storage.googleapis.com/k8s-artifacts-sig-release/kubernetes/release/$LATEST_RELEASE/krel-amd64-linux"
curl_retry "$GCB_URL" -o "$KREL_OUTPUT_PATH"
chmod +x "$KREL_OUTPUT_PATH"
echo "Downloading krel from GCB bucket…"
GCB_URL="https://storage.googleapis.com/k8s-artifacts-sig-release/kubernetes/release/$LATEST_RELEASE/krel-amd64-linux"
curl_retry "$GCB_URL" -o "$KREL_OUTPUT_PATH"
chmod +x "$KREL_OUTPUT_PATH"
else
echo "Building krel from sources"
go build -o "$KREL_OUTPUT_PATH" ./cmd/krel
fi

echo "Done, output of 'krel version':"
"$KREL_OUTPUT_PATH" version

0 comments on commit a53bb39

Please sign in to comment.