2020-05-01 15:33:41 +00:00
|
|
|
#!/bin/bash
|
2021-07-29 11:50:16 +00:00
|
|
|
set -eux
|
2020-05-01 15:33:41 +00:00
|
|
|
|
2020-08-22 17:27:18 +00:00
|
|
|
CHARTS=${1:-'.*'}
|
2021-02-12 11:04:16 +00:00
|
|
|
FORCE=${2:-''}
|
2020-05-01 15:33:41 +00:00
|
|
|
# all credits go to the argoproj Helm guys https://github.com/argoproj/argo-helm
|
|
|
|
|
|
|
|
SRCROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
2020-08-20 14:55:49 +00:00
|
|
|
GIT_PUSH=${GIT_PUSH:-true}
|
2020-05-01 15:33:41 +00:00
|
|
|
|
2021-01-21 10:53:53 +00:00
|
|
|
TMPDIR=$(mktemp -d kubezero-repo.XXX)
|
2021-03-26 09:56:17 +00:00
|
|
|
mkdir -p $TMPDIR/stage && trap 'rm -rf $TMPDIR' ERR EXIT
|
2021-01-21 10:53:53 +00:00
|
|
|
|
|
|
|
git clone -b gh-pages ssh://git@git.zero-downtime.net:22000/ZeroDownTime/KubeZero.git $TMPDIR/repo
|
2020-05-06 17:23:52 +00:00
|
|
|
# Reset all
|
2021-01-21 10:53:53 +00:00
|
|
|
# rm -rf $TMPDIR/repo/*tgz $TMPDIR/repo/index.yaml
|
2020-05-01 15:33:41 +00:00
|
|
|
|
|
|
|
helm repo add argoproj https://argoproj.github.io/argo-helm
|
2020-05-14 17:24:51 +00:00
|
|
|
helm repo add jetstack https://charts.jetstack.io
|
|
|
|
helm repo add uswitch https://uswitch.github.io/kiam-helm-charts/charts/
|
2020-07-07 12:17:20 +00:00
|
|
|
helm repo update
|
2020-05-01 15:33:41 +00:00
|
|
|
|
2020-08-22 17:27:18 +00:00
|
|
|
for dir in $(find -L $SRCROOT/charts -mindepth 1 -maxdepth 1 -type d);
|
2020-05-01 15:33:41 +00:00
|
|
|
do
|
|
|
|
name=$(basename $dir)
|
2020-08-22 17:27:18 +00:00
|
|
|
[[ $name =~ $CHARTS ]] || continue
|
2020-05-01 15:33:41 +00:00
|
|
|
if [ $(helm dep list $dir 2>/dev/null| wc -l) -gt 1 ]
|
|
|
|
then
|
|
|
|
echo "Processing chart dependencies"
|
2020-07-07 12:17:20 +00:00
|
|
|
rm -rf $dir/tmpcharts
|
|
|
|
helm dependency update --skip-refresh $dir
|
2020-05-01 15:33:41 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Processing $dir"
|
2021-01-04 18:13:36 +00:00
|
|
|
helm lint $dir || true
|
2021-01-21 10:53:53 +00:00
|
|
|
helm --debug package -d $TMPDIR/stage $dir
|
2020-05-01 15:33:41 +00:00
|
|
|
done
|
|
|
|
|
2021-01-21 10:53:53 +00:00
|
|
|
# Do NOT overwrite existing charts
|
2021-02-12 11:04:16 +00:00
|
|
|
if [ -n "$FORCE" ]; then
|
|
|
|
cp $TMPDIR/stage/*.tgz $TMPDIR/repo
|
|
|
|
else
|
|
|
|
cp -n $TMPDIR/stage/*.tgz $TMPDIR/repo
|
|
|
|
fi
|
2020-05-01 15:33:41 +00:00
|
|
|
|
2021-01-21 10:53:53 +00:00
|
|
|
cd $TMPDIR/repo
|
|
|
|
|
2021-08-25 14:02:21 +00:00
|
|
|
# read
|
|
|
|
|
2021-01-21 10:53:53 +00:00
|
|
|
helm repo index .
|
|
|
|
git status
|
2020-05-01 15:33:41 +00:00
|
|
|
|
|
|
|
if [ "$GIT_PUSH" == "true" ]
|
|
|
|
then
|
2021-03-30 12:50:37 +00:00
|
|
|
git add . && git commit -m "ci: Publish charts" && git push ssh://git@git.zero-downtime.net:22000/ZeroDownTime/KubeZero.git gh-pages
|
2020-05-01 15:33:41 +00:00
|
|
|
fi
|
2021-01-21 10:53:53 +00:00
|
|
|
|
|
|
|
cd -
|
|
|
|
rm -rf $TMPDIR
|