2021-01-25 13:05:53 +05:30
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
|
|
#############
|
|
|
|
|
# FUNCTIONS #
|
|
|
|
|
#############
|
|
|
|
|
|
2021-12-02 15:40:17 -07:00
|
|
|
MAKE='make --debug=v --output-sync'
|
2021-09-01 12:59:32 -06:00
|
|
|
|
2021-01-25 13:05:53 +05:30
|
|
|
function build() {
|
2021-09-01 12:59:32 -06:00
|
|
|
$MAKE build.all
|
2021-01-25 13:05:53 +05:30
|
|
|
# quick check that go modules are tidied
|
2021-09-01 12:59:32 -06:00
|
|
|
$MAKE mod.check
|
2021-01-25 13:05:53 +05:30
|
|
|
}
|
|
|
|
|
|
2025-04-16 17:20:47 -06:00
|
|
|
function publish_images_and_docs() {
|
2021-07-16 13:20:31 +05:30
|
|
|
build
|
2021-09-01 12:59:32 -06:00
|
|
|
$MAKE -C build/release build BRANCH_NAME=${BRANCH_NAME} TAG_WITH_SUFFIX=${TAG_WITH_SUFFIX} GIT_API_TOKEN=${GIT_API_TOKEN}
|
2021-07-16 13:20:31 +05:30
|
|
|
git status &
|
|
|
|
|
git diff &
|
2025-04-16 17:20:47 -06:00
|
|
|
$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}
|
2021-07-16 13:20:31 +05:30
|
|
|
}
|
2021-07-23 22:01:52 +05:30
|
|
|
|
2025-04-16 17:20:47 -06:00
|
|
|
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}
|
2021-07-26 15:35:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#############
|
|
|
|
|
# MAIN #
|
|
|
|
|
#############
|
|
|
|
|
|
2023-02-16 12:06:58 +01:00
|
|
|
# Load dot env file if available
|
|
|
|
|
if [ -f .env ]; then
|
|
|
|
|
# shellcheck disable=SC2046
|
|
|
|
|
export $(grep -v '^#' .env | xargs -d '\n')
|
|
|
|
|
fi
|
|
|
|
|
|
2026-02-18 17:26:45 +05:30
|
|
|
# Use Git access token for accessing the docs repo if set
|
2023-02-16 12:06:58 +01:00
|
|
|
# shellcheck disable=SC2034
|
2026-02-18 17:26:45 +05:30
|
|
|
export DOCS_GIT_REPO="${DOCS_GIT_REPO:-git@github.com:rook/rook.github.io.git}"
|
2023-02-16 12:06:58 +01:00
|
|
|
if [ -n "${GIT_API_TOKEN}" ]; then
|
|
|
|
|
DOCS_GIT_REPO="${DOCS_GIT_REPO//git@/}"
|
|
|
|
|
DOCS_GIT_REPO="${DOCS_GIT_REPO//:/\/}"
|
2023-04-04 18:50:02 +02:00
|
|
|
export DOCS_GIT_REPO="https://${GIT_API_TOKEN}@${DOCS_GIT_REPO}"
|
2023-02-16 12:06:58 +01:00
|
|
|
fi
|
|
|
|
|
|
2025-04-16 17:20:47 -06:00
|
|
|
TAGGED_RELEASE=false
|
2021-07-26 15:35:08 -06:00
|
|
|
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}"
|
2025-04-16 17:20:47 -06:00
|
|
|
TAGGED_RELEASE=true
|
2021-07-26 15:35:08 -06:00
|
|
|
else
|
|
|
|
|
echo "Publishing from release branch ${BRANCH_NAME}"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
2025-04-16 17:20:47 -06:00
|
|
|
publish_images_and_docs
|
2021-07-26 15:35:08 -06:00
|
|
|
|
2025-04-16 17:20:47 -06:00
|
|
|
if [[ "$TAGGED_RELEASE" = true ]]; then
|
|
|
|
|
publish_charts
|
2021-07-23 22:01:52 +05:30
|
|
|
fi
|