Files
my-rook-config/tests/scripts/build-release.sh
T
Travis Nielsen 7d908d0a5e build: stop publishing charts in master branch
The helm charts will now only be published when it is
an officially tagged release build.

The images will only be published to all repos for
dockerhub, quay, and ghcr when it is a tagged release.

The images will be published only to dockerhub for all
master and interim release branch builds.

Remove obsolete makefile option for images.
Ceph is the only image Rook ever expects to build.
Simplify the makefile by removing the legacy option
to select which image to build.

Also included are other small improvements to clean up
the release scripts.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
2025-04-18 10:40:29 -06:00

76 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -ex
#############
# FUNCTIONS #
#############
MAKE='make --debug=v --output-sync'
function build() {
$MAKE build.all
# quick check that go modules are tidied
$MAKE mod.check
}
function publish_images_and_docs() {
build
$MAKE -C build/release build BRANCH_NAME=${BRANCH_NAME} TAG_WITH_SUFFIX=${TAG_WITH_SUFFIX} GIT_API_TOKEN=${GIT_API_TOKEN}
git status &
git diff &
$MAKE -C build/release publish BRANCH_NAME=${BRANCH_NAME} TAG_WITH_SUFFIX=${TAG_WITH_SUFFIX} AWS_ACCESS_KEY_ID=${AWS_USR} AWS_SECRET_ACCESS_KEY=${AWS_PSW} GIT_API_TOKEN=${GIT_API_TOKEN} TAGGED_RELEASE=${TAGGED_RELEASE}
}
function publish_charts() {
echo "Publishing helm charts for release build"
$MAKE -C build/release promote BRANCH_NAME=${BRANCH_NAME} TAG_WITH_SUFFIX=${TAG_WITH_SUFFIX} AWS_ACCESS_KEY_ID=${AWS_USR} AWS_SECRET_ACCESS_KEY=${AWS_PSW}
}
#############
# MAIN #
#############
# Load dot env file if available
if [ -f .env ]; then
# shellcheck disable=SC2046
export $(grep -v '^#' .env | xargs -d '\n')
fi
# Use Git access token for accessing the docs repo if set
# shellcheck disable=SC2034
export DOCS_GIT_REPO="${DOCS_GIT_REPO:-git@github.com:rook/rook.github.io.git}"
if [ -n "${GIT_API_TOKEN}" ]; then
DOCS_GIT_REPO="${DOCS_GIT_REPO//git@/}"
DOCS_GIT_REPO="${DOCS_GIT_REPO//:/\/}"
export DOCS_GIT_REPO="https://${GIT_API_TOKEN}@${DOCS_GIT_REPO}"
fi
TAGGED_RELEASE=false
if [[ ${GITHUB_REF} =~ master ]]; then
echo "Publishing from master"
else
echo "Tagging with suffix for release and tagged builds"
TAG_WITH_SUFFIX=true
# If a tag, find the source release branch
if [[ $BRANCH_NAME = v* ]]; then
TAG_NAME=${BRANCH_NAME}
BRANCH_NAME=$(git branch -r --contain refs/tags/${BRANCH_NAME} | grep "origin/release-." | sed 's/origin\///' | xargs)
if [[ $BRANCH_NAME = "" ]]; then
echo "Branch name not found in tag $TAG_NAME"
exit 1
fi
echo "Publishing tag ${TAG_NAME} in branch ${BRANCH_NAME}"
TAGGED_RELEASE=true
else
echo "Publishing from release branch ${BRANCH_NAME}"
fi
fi
publish_images_and_docs
if [[ "$TAGGED_RELEASE" = true ]]; then
publish_charts
fi