scripts: Fix remote tag check, gcloud login and umask in release script

This commit is contained in:
Joe Betz 2018-05-09 10:37:24 -07:00
parent 4e24a0f34b
commit 4319a8a2ba
No known key found for this signature in database
GPG Key ID: 4930C680B6E0DDB8

View File

@ -48,6 +48,9 @@ main() {
exit 1 exit 1
fi fi
# Expected umask for etcd release artifacts
umask 022
# Set up release directory. # Set up release directory.
local reldir="/tmp/etcd-release-${VERSION}" local reldir="/tmp/etcd-release-${VERSION}"
if [ ! -d "${reldir}/etcd" ]; then if [ ! -d "${reldir}/etcd" ]; then
@ -58,8 +61,8 @@ main() {
cd "${reldir}/etcd" cd "${reldir}/etcd"
# If a release version tag already exists, use it. # If a release version tag already exists, use it.
local remote_tag_exists=$(git ls-remote origin "refs/tags/${RELEASE_VERSION}" | grep -q "${RELEASE_VERSION}") local remote_tag_exists=$(git ls-remote origin "refs/tags/${RELEASE_VERSION}" | grep -c "${RELEASE_VERSION}")
if ${remote_tag_exists}; then if [ ${remote_tag_exists} -gt 0 ]; then
echo "Release version tag exists on remote. Checking out refs/tags/${RELEASE_VERSION}" echo "Release version tag exists on remote. Checking out refs/tags/${RELEASE_VERSION}"
git checkout -q "tags/${RELEASE_VERSION}" git checkout -q "tags/${RELEASE_VERSION}"
fi fi
@ -73,7 +76,7 @@ main() {
fi fi
# If the release tag does not already exist remotely, create it. # If the release tag does not already exist remotely, create it.
if ! ${remote_tag_exists}; then if [ ${remote_tag_exists} -eq 0 ]; then
# Bump version/version.go to release version. # Bump version/version.go to release version.
local source_version=$(egrep "\s+Version\s*=" version/version.go | sed -e "s/.*\"\(.*\)\".*/\1/g") local source_version=$(egrep "\s+Version\s*=" version/version.go | sed -e "s/.*\"\(.*\)\".*/\1/g")
if [[ "${source_version}" != "${VERSION}" ]]; then if [[ "${source_version}" != "${VERSION}" ]]; then
@ -109,7 +112,7 @@ main() {
fi fi
# Tag release. # Tag release.
if $(git tag --list | grep -q "${RELEASE_VERSION}"); then if [ $(git tag --list | grep -c "${RELEASE_VERSION}") -gt 0 ]; then
echo "Skipping tag step. git tag ${RELEASE_VERSION} already exists." echo "Skipping tag step. git tag ${RELEASE_VERSION} already exists."
else else
echo "Tagging release..." echo "Tagging release..."
@ -159,15 +162,18 @@ main() {
else else
read -p "Publish etcd ${RELEASE_VERSION} docker images to quay.io [y/N]? " confirm read -p "Publish etcd ${RELEASE_VERSION} docker images to quay.io [y/N]? " confirm
[[ "${confirm,,}" == "y" ]] || exit 1 [[ "${confirm,,}" == "y" ]] || exit 1
until $(docker login quay.io); do for i in {1..5}; do
echo "Docker login failed, retrying." docker login quay.io && break
echo "login failed, retrying"
done done
gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd-development.json)" https://gcr.io gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd-development.json)" https://gcr.io
if [ "${MINOR_VERSION}" != "3.1" ]; then
for TARGET_ARCH in "-arm64" "-ppc64le" ""; do for TARGET_ARCH in "-arm64" "-ppc64le" ""; do
docker push quay.io/coreos/etcd:${RELEASE_VERSION}${TARGET_ARCH} docker push quay.io/coreos/etcd:${RELEASE_VERSION}${TARGET_ARCH}
gcloud docker -- push gcr.io/etcd-development/etcd:${RELEASE_VERSION}${TARGET_ARCH} gcloud docker -- push gcr.io/etcd-development/etcd:${RELEASE_VERSION}${TARGET_ARCH}
done done
fi
gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
docker tag quay.io/coreos/etcd:${RELEASE_VERSION} quay.io/coreos/etcd:v${MINOR_VERSION} docker tag quay.io/coreos/etcd:${RELEASE_VERSION} quay.io/coreos/etcd:v${MINOR_VERSION}