mirror of https://git.rancher.io/charts
50 lines
1.7 KiB
Bash
Executable File
50 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
cd $(dirname $0)
|
|
|
|
cd ..
|
|
|
|
# Name of the directory where we pull in the current released branch; can be arbitrarily set
|
|
RELEASE_BRANCH_DIR=released-branch-dir
|
|
|
|
if [ -z ${RELEASE_REPO_URL} ] || [ -z ${RELEASE_BRANCH} ]; then
|
|
echo "Usage: RELEASE_REPO_URL=<github-repo-url> RELEASE_BRANCH=<branch> make stage-release"
|
|
exit 1
|
|
fi
|
|
|
|
# Print a warning if a developer tries to invoke this script locally
|
|
if [[ -z ${FROM_WORKFLOW} ]]; then
|
|
echo ""
|
|
echo "Unexpected Behavior: Detected that this script was invoked outside of a Github Workflow since FROM_WORKFLOW is unset."
|
|
echo "- This script is only intended to be run as part of a Github Workflow on your source branch, once changes have already been pushed to your remote."
|
|
echo "- This script will only generate the released/ directory based on what would be run on a 'make sync' on ${RELEASE_REPO_URL}@${RELEASE_BRANCH}"
|
|
echo "- If a change is made locally in this branch but not committed to the remote Github repository, it will not be staged by this script."
|
|
echo ""
|
|
echo "Proceed with caution!"
|
|
echo ""
|
|
fi
|
|
|
|
echo "Regenerating released/ based on ${RELEASE_REPO_URL}@${RELEASE_BRANCH}..."
|
|
|
|
rm -rf released
|
|
mkdir -p released
|
|
|
|
echo "Pulling in ${RELEASE_REPO_URL}@${RELEASE_BRANCH} into ${RELEASE_BRANCH_DIR}"
|
|
rm -rf ${RELEASE_BRANCH_DIR}
|
|
|
|
git clone --depth 1 --branch ${RELEASE_BRANCH} ${RELEASE_REPO_URL} ${RELEASE_BRANCH_DIR} 2>/dev/null
|
|
|
|
cd ${RELEASE_BRANCH_DIR}
|
|
|
|
make sync
|
|
cp -R assets/ ../released/assets
|
|
cp -R charts/ ../released/charts
|
|
cp -R index.yaml ../released/index.yaml
|
|
|
|
cd ..
|
|
rm -rf ${RELEASE_BRANCH_DIR}
|
|
|
|
# Modify the index.yaml to point to the released/ directory only
|
|
helm repo index --url released/assets released/assets
|
|
mv released/assets/index.yaml index.yaml |