Skip to content

Commit

Permalink
Add VERSION file and update release scripts
Browse files Browse the repository at this point in the history
 • 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.
  • Loading branch information
bonzofenix committed Sep 30, 2024
1 parent 5cb80fe commit bc83916
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 14 deletions.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.1.5
37 changes: 23 additions & 14 deletions ci/autoscaler/scripts/release-autoscaler.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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" <<EOF
Expand All @@ -164,6 +169,10 @@ releases:
version: ${VERSION}
url: https://storage.googleapis.com/app-autoscaler-releases/releases/app-autoscaler-acceptance-tests-v${VERSION}.tgz
sha1: sha256:${ACCEPTANCE_SHA256}
- name: app-autoscaler-mtar
version: ${VERSION}
url: https://storage.googleapis.com/app-autoscaler-releases/releases/app-autoscaler-release-v${VERSION}.tgz
sha1: sha256:${MTAR_SHA256}
\`\`\`
EOF
echo "---------- Changelog file ----------"
Expand Down
60 changes: 60 additions & 0 deletions scripts/local_release_autoscaler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#! /usr/bin/env bash
#
set -euo pipefail
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /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

0 comments on commit bc83916

Please sign in to comment.