From bc83916fb0658685c55b100c0fb70326c821fa02 Mon Sep 17 00:00:00 2001 From: Alan Moran Date: Mon, 30 Sep 2024 18:33:00 +0200 Subject: [PATCH] Add VERSION file and update release scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Introduced a VERSION file to track the release version. • Simplified the release-autoscaler.sh script by removing hardcoded variables and adding a new create_mtar function for building mtar artifacts. • Added local_release_autoscaler.sh script to facilitate local testing and release process, including automatic SSH key generation and cleanup tasks. • Updated changelog generation to include mtar artifact details. --- VERSION | 1 + ci/autoscaler/scripts/release-autoscaler.sh | 37 ++++++++----- scripts/local_release_autoscaler.sh | 60 +++++++++++++++++++++ 3 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 VERSION create mode 100755 scripts/local_release_autoscaler.sh diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000..726bfd5981 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +14.1.5 diff --git a/ci/autoscaler/scripts/release-autoscaler.sh b/ci/autoscaler/scripts/release-autoscaler.sh index f1e9c1760e..9570f1a933 100755 --- a/ci/autoscaler/scripts/release-autoscaler.sh +++ b/ci/autoscaler/scripts/release-autoscaler.sh @@ -1,21 +1,8 @@ #! /usr/bin/env bash # NOTE: you can run this locally for testing !!! -# beware that it adds a commit you need to drop each time also you need to remove dev_releases from root. # -# DEPLOYMENT=foo \ -# GITHUB_TOKEN="ghp_..." \ -# PREV_VERSION=12.2.1 \ -# DEST="${PWD}/../../../build" \ -# VERSION="12.3.0" \ -# BUILD_OPTS="--force" \ -# AUTOSCALER_CI_BOT_NAME="foo" \ -# AUTOSCALER_CI_BOT_EMAIL="foo@bar.baz" \ -# AUTOSCALER_CI_BOT_SIGNING_KEY_PUBLIC="ssh-ed25519 AAAA... foo@bar.baz" \ -# AUTOSCALER_CI_BOT_SIGNING_KEY_PRIVATE="-----BEGIN OPENSSH PRIVATE KEY----- -# b3Bl... -# -----END OPENSSH PRIVATE KEY-----" \ -# ./ci/autoscaler/scripts/release-autoscaler.sh +# ./script/local_release_autoscaler.sh [ -n "${DEBUG}" ] && set -x @@ -47,6 +34,8 @@ function create_release() { yq eval -i ".properties.\"autoscaler.apiserver.info.build\".default = \"${version}\"" jobs/golangapiserver/spec git add jobs/golangapiserver/spec + echo "${version}" VERSION + git add VERSION [ "${CI}" = "true" ] && git commit -S -m "Updated release version to ${version} in golangapiserver" # shellcheck disable=SC2086 @@ -56,6 +45,17 @@ function create_release() { --tarball="${build_path}/artifacts/${release_file}" } +function create_mtar() { + set -e + mkdir -p "${build_path}/artifacts" + local version=$1 + local build_path=$2 + echo " - creating autorscaler mtar artifact" + pushd "${autoscaler_dir}" > /dev/null + make mta-release VERSION="${version}" DEST="${build_path}/artifacts/" + popd > /dev/null +} + function create_tests() { set -e mkdir -p "${build_path}/artifacts" @@ -136,19 +136,24 @@ pushd "${autoscaler_dir}" > /dev/null if [ "${PERFORM_BOSH_RELEASE}" == "true" ]; then RELEASE_TGZ="app-autoscaler-v${VERSION}.tgz" ACCEPTANCE_TEST_TGZ="app-autoscaler-acceptance-tests-v${VERSION}.tgz" + AUTOSCALER_MTAR="app-autoscaler-release-v${VERSION}.mtar" create_release "${VERSION}" "${build_path}" "${RELEASE_TGZ}" create_tests "${VERSION}" "${build_path}" + create_mtar "${VERSION}" "${build_path}" [ "${CI}" = "true" ] && commit_release sha256sum "${build_path}/artifacts/"* > "${build_path}/artifacts/files.sum.sha256" ACCEPTANCE_SHA256=$( grep "${ACCEPTANCE_TEST_TGZ}$" "${SUM_FILE}" | awk '{print $1}' ) RELEASE_SHA256=$( grep "${RELEASE_TGZ}$" "${SUM_FILE}" | awk '{print $1}') + MTAR_SHA256=$( grep "${AUTOSCALER_MTAR}$" "${SUM_FILE}" | awk '{print $1}') else ACCEPTANCE_SHA256="dummy-sha" RELEASE_SHA256="dummy-sha" + MTAR_SHA256="dummy-sha" fi export ACCEPTANCE_SHA256 export RELEASE_SHA256 + export MTAR_SHA256 cat >> "${build_path}/changelog.md" < /dev/null && pwd ) + +DEPLOYMENT=foo +export DEBUG=true +export PREV_VERSION=12.2.1 +export DEST="${script_dir}/../build" +export VERSION="12.3.0" +export BUILD_OPTS="--force" +export AUTOSCALER_CI_BOT_NAME="foo" +export AUTOSCALER_CI_BOT_EMAIL="foo@bar.baz" +export PREV_VERSION=$(cat ${script_dir}/../VERSION) +export VERSION=$(cat ${script_dir}/../VERSION)-pre + + +# check for GITHUB_TOKEN +if [ -z "${GITHUB_TOKEN}" ]; then + echo "GITHUB_TOKEN is not set" + exit 1 +fi + + +find_or_create_ssh_key() { + if [ -f ~/.ssh/id_ed25519 ]; then + echo "ssh key already exists" + return + fi + + ssh-keygen -t ed25519 -C "${AUTOSCALER_CI_BOT_EMAIL}" -f ~/.ssh/id_ed25519 -N "" +} + +prerelease() { + pushd "${script_dir}/.." > /dev/null + make clean generate-fakes generate-openapi-generated-clients-and-servers go-mod-tidy go-mod-vendor db scheduler + popd > /dev/null +} + +delete_dev_releases() { + rm -rf dev_releases +} + + +release_autoscaler() { + export AUTOSCALER_CI_BOT_SIGNING_KEY_PUBLIC=$(cat ~/.ssh/id_ed25519.pub) + export AUTOSCALER_CI_BOT_SIGNING_KEY_PRIVATE=$(cat ~/.ssh/id_ed25519) + source "${script_dir}/../ci/autoscaler/scripts/release-autoscaler.sh" + echo "beware that it adds a commit you need to drop each time also you need to remove dev_releases from root." +} + +main() { + find_or_create_ssh_key + delete_dev_releases + prerelease + release_autoscaler +} + +main +