mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-09 05:56:58 +02:00
Merge pull request #529 from marineam/promote
core_promote: remove, replaced by plume release
This commit is contained in:
commit
a27c2eb70d
139
core_promote
139
core_promote
@ -1,139 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2014 The CoreOS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
|
||||
# We have to simple-mindedly set GCLIENT_ROOT in case we're running from
|
||||
# au-generator.zip because common.sh will fail while auto-detect it.
|
||||
export GCLIENT_ROOT=$(readlink -f "${SCRIPT_ROOT}/../../")
|
||||
. "${SCRIPT_ROOT}/common.sh" || exit 1
|
||||
|
||||
DEFINE_string board "amd64-usr" \
|
||||
"Board type of the image"
|
||||
DEFINE_string version "${COREOS_VERSION}" \
|
||||
"Version number to promote."
|
||||
DEFINE_string channel "alpha" \
|
||||
"Roller channel to promote this version to."
|
||||
DEFINE_string app_id "e96281a6-d1af-4bde-9a0a-97b76e56dc57" \
|
||||
"CoreOS AppId in roller."
|
||||
|
||||
DEFINE_string user "" \
|
||||
"User for roller."
|
||||
DEFINE_string api_key "" \
|
||||
"API key for roller."
|
||||
DEFINE_string endpoint "https://public.update.core-os.net" \
|
||||
"Roller endpoint to update."
|
||||
DEFINE_string build_storage "gs://builds.release.core-os.net" \
|
||||
"GS bucket with official build artifacts."
|
||||
DEFINE_string release_storage "" \
|
||||
"GS bucket for release downloads."
|
||||
DEFINE_string legacy_storage "gs://storage.core-os.net/coreos" \
|
||||
"Legacy 'storage' GS bucket."
|
||||
|
||||
# Allow toggling the assorted actions.
|
||||
DEFINE_boolean do_roller ${FLAGS_TRUE} "Update the channel in roller"
|
||||
DEFINE_boolean do_gce ${FLAGS_TRUE} "Add image to coreos-cloud GCE project"
|
||||
DEFINE_boolean do_storage ${FLAGS_TRUE} "Copy images to public storage"
|
||||
|
||||
FLAGS_HELPS="usage: $SCRIPTNAME [flags]
|
||||
|
||||
Setting everything up for use\n
|
||||
|
||||
1) Run 'gsutil config'
|
||||
2) Run 'gcutil config'
|
||||
3) Ensure rollerctl is installed in your path\n
|
||||
"
|
||||
|
||||
# Parse flags
|
||||
FLAGS "$@" || exit 1
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
switch_to_strict_mode
|
||||
|
||||
if [[ ${FLAGS_do_roller} -eq ${FLAGS_TRUE} ]]; then
|
||||
[[ -z "${FLAGS_api_key}" ]] && die "--api_key is required"
|
||||
[[ -z "${FLAGS_user}" ]] && die "--user is required"
|
||||
fi
|
||||
|
||||
# Ensure GS URL doesn't have a trailing /
|
||||
FLAGS_build_storage="${FLAGS_build_storage%%/}"
|
||||
FLAGS_release_storage="${FLAGS_release_storage%%/}"
|
||||
FLAGS_legacy_storage="${FLAGS_legacy_storage%%/}"
|
||||
|
||||
# The channel name in roller is capitalized, everywhere else is lower case.
|
||||
roller_channel="${FLAGS_channel^}"
|
||||
lower_channel="${FLAGS_channel,,}"
|
||||
|
||||
# Full GS URL of the original build
|
||||
gs_build="${FLAGS_build_storage}/${lower_channel}/boards/${FLAGS_board}/${FLAGS_version}"
|
||||
|
||||
if [[ -z "${FLAGS_release_storage}" ]]; then
|
||||
FLAGS_release_storage="gs://${lower_channel}.release.core-os.net"
|
||||
fi
|
||||
# Full GS URL of the public release locations
|
||||
gs_release="${FLAGS_release_storage}/${FLAGS_board}/${FLAGS_version}"
|
||||
gs_current="${FLAGS_release_storage}/${FLAGS_board}/current"
|
||||
|
||||
if [[ ${FLAGS_do_roller} -eq ${FLAGS_TRUE} ]]; then
|
||||
updateservicectl \
|
||||
--server="${FLAGS_endpoint}" \
|
||||
--user="${FLAGS_user}" \
|
||||
--key="${FLAGS_api_key}" \
|
||||
channel update \
|
||||
--app-id="${FLAGS_app_id}" \
|
||||
--channel="${roller_channel}" \
|
||||
--version="${FLAGS_version}" \
|
||||
--publish=true
|
||||
fi
|
||||
|
||||
if [[ ${FLAGS_do_gce} -eq ${FLAGS_TRUE} ]]; then
|
||||
gce_name="coreos-${lower_channel}-${FLAGS_version//./-}-v$(date -u +%Y%m%d)"
|
||||
# description must be of the format "Vendor, OS, Version, Description"
|
||||
gce_desc="CoreOS, CoreOS ${lower_channel}, ${FLAGS_version}, ${FLAGS_board} published on $(date -u +%Y-%m-%d)"
|
||||
gcutil \
|
||||
--project coreos-cloud \
|
||||
addimage \
|
||||
--description="${gce_desc}" \
|
||||
"${gce_name}" \
|
||||
"${gs_build}/coreos_production_gce.tar.gz"
|
||||
gce_path="projects/coreos-cloud/global/images/${gce_name}"
|
||||
gce_temp=$(mktemp --suffix=.txt)
|
||||
trap "rm -f '${gce_temp}'" EXIT
|
||||
echo "${gce_path}" > "${gce_temp}"
|
||||
gsutil cp "${gce_temp}" "${gs_build}/coreos_production_gce.txt"
|
||||
rm -f "${gce_temp}"
|
||||
trap - EXIT
|
||||
|
||||
# Set the DEPRECATED on all old images in this channel.
|
||||
for old_name in $(gcutil --project coreos-cloud \
|
||||
listimages --nostandard_images --format=names \
|
||||
--filter="name eq '^coreos-${lower_channel}-.*'")
|
||||
do
|
||||
if [[ "${old_name}" == "${gce_name}" ]]; then
|
||||
continue
|
||||
fi
|
||||
gcutil --project coreos-cloud \
|
||||
deprecateimage --state=DEPRECATED \
|
||||
--replacement="${gce_name}" "${old_name}"
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ${FLAGS_do_storage} -eq ${FLAGS_TRUE} ]]; then
|
||||
gsutil -m rsync -d "${gs_build}/" "${gs_release}/"
|
||||
gsutil -m rsync -d "${gs_build}/" "${gs_current}/"
|
||||
fi
|
||||
|
||||
if [[ ${FLAGS_do_storage} -eq ${FLAGS_TRUE} ]] && \
|
||||
[[ -n "${FLAGS_legacy_storage}" ]]
|
||||
then
|
||||
if [[ "${lower_channel}" == alpha ]]; then
|
||||
gsutil -m rsync -d "${gs_release}/" \
|
||||
"${FLAGS_legacy_storage}/${FLAGS_board}/${FLAGS_version}/"
|
||||
gsutil -m rsync -d "${gs_current}/" \
|
||||
"${FLAGS_legacy_storage}/${FLAGS_board}/alpha/"
|
||||
elif [[ "${lower_channel}" == beta ]]; then
|
||||
gsutil -m rsync -d "${gs_current}/" \
|
||||
"${FLAGS_legacy_storage}/${FLAGS_board}/beta/"
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue
Block a user