mirror of https://github.com/k3s-io/k3s
Publish a gs://kubernetes-release/release/latest.txt when we publish a build
Adds a kube::release::gcs::publish_latest_official that checks the current contents of this file in GCS, verifies that we're pushing a newer build, and updates it if so. (i.e. it handles the case of pushing a 0.13.1 and then later pushing a 0.12.3.) This follows the pattern of the ci/ build, which Jenkins just updates unconditionally. I already updated the file for 0.13.1. After this we can update the get-k8s script, so we don't have to keep updating it.pull/6/head
parent
2c97522692
commit
3458246c10
|
@ -833,3 +833,53 @@ function kube::release::gcs::publish_latest() {
|
|||
echo "+++ gsutil cat ${latest_file_dst}:"
|
||||
gsutil cat ${latest_file_dst}
|
||||
}
|
||||
|
||||
# Publish a new latest.txt, but only if the release we're dealing with
|
||||
# is newer than the contents in GCS.
|
||||
function kube::release::gcs::publish_latest_official() {
|
||||
local -r new_version=${KUBE_GCS_LATEST_CONTENTS}
|
||||
local -r latest_file_dst="gs://${KUBE_GCS_RELEASE_BUCKET}/${KUBE_GCS_LATEST_FILE}"
|
||||
|
||||
local -r version_regex="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
|
||||
[[ ${new_version} =~ ${version_regex} ]] || {
|
||||
echo "!!! publish_latest_official passed bogus value: '${new_version}'" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
local -r version_major="${BASH_REMATCH[1]}"
|
||||
local -r version_minor="${BASH_REMATCH[2]}"
|
||||
local -r version_patch="${BASH_REMATCH[3]}"
|
||||
|
||||
local gcs_version
|
||||
gcs_version=$(gsutil cat "${latest_file_dst}")
|
||||
|
||||
[[ ${gcs_version} =~ ${version_regex} ]] || {
|
||||
echo "!!! ${latest_file_dst} contains invalid release version, can't compare: '${gcs_version}'" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
local -r gcs_version_major="${BASH_REMATCH[1]}"
|
||||
local -r gcs_version_minor="${BASH_REMATCH[2]}"
|
||||
local -r gcs_version_patch="${BASH_REMATCH[3]}"
|
||||
|
||||
local greater=true
|
||||
if [[ "${gcs_version_major}" -gt "${version_major}" ]]; then
|
||||
greater=false
|
||||
elif [[ "${gcs_version_major}" -lt "${version_major}" ]]; then
|
||||
: # fall out
|
||||
elif [[ "${gcs_version_minor}" -gt "${version_minor}" ]]; then
|
||||
greater=false
|
||||
elif [[ "${gcs_version_minor}" -lt "${version_minor}" ]]; then
|
||||
: # fall out
|
||||
elif [[ "${gcs_version_patch}" -ge "${version_patch}" ]]; then
|
||||
greater=false
|
||||
fi
|
||||
|
||||
if [[ "${greater}" != "true" ]]; then
|
||||
echo "+++ ${gcs_version} (latest on GCS) >= ${new_version} (just uploaded), not updating ${latest_file_dst}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "+++ ${new_version} (just uploaded) > ${gcs_version} (latest on GCS), updating ${latest_file_dst}"
|
||||
kube::release::gcs::publish_latest
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ set -o pipefail
|
|||
|
||||
KUBE_RELEASE_VERSION=${1-}
|
||||
|
||||
VERSION_REGEX="v[0-9]+.[0-9]+(.[0-9]+)?"
|
||||
VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
|
||||
[[ ${KUBE_RELEASE_VERSION} =~ $VERSION_REGEX ]] || {
|
||||
echo "!!! You must specify the version you are releasing in the form of '$VERSION_REGEX'" >&2
|
||||
exit 1
|
||||
|
@ -34,9 +34,11 @@ KUBE_GCS_UPLOAD_RELEASE=y
|
|||
KUBE_GCS_RELEASE_BUCKET=kubernetes-release
|
||||
KUBE_GCS_PROJECT=google-containers
|
||||
KUBE_GCS_RELEASE_PREFIX=release/${KUBE_RELEASE_VERSION}
|
||||
KUBE_GCS_LATEST_FILE="release/latest.txt"
|
||||
KUBE_GCS_LATEST_CONTENTS=${KUBE_RELEASE_VERSION}
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
source "$KUBE_ROOT/build/common.sh"
|
||||
|
||||
|
||||
kube::release::gcs::release
|
||||
kube::release::gcs::publish_latest_official
|
||||
|
|
Loading…
Reference in New Issue