linkerd2/bin/helm-build

56 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
set -e
setValues() {
sed -i "s/$1/$2/" charts/linkerd2/values.yaml
sed -i "s/$1/$2/" charts/linkerd2-cni/values.yaml
}
showErr() {
printf "Error on exit:\n Exit code: %d\n Failed command: \"%s\"\n" $? "$BASH_COMMAND"
setValues $fullVersion "{version}"
}
# trap the last failed command
trap 'showErr' ERR
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
rootdir=$( cd "$bindir"/.. && pwd )
"$bindir"/helm init --client-only
"$bindir"/helm lint "$rootdir"/charts/partials
"$bindir"/helm dep up "$rootdir"/charts/linkerd2-cni
"$bindir"/helm lint "$rootdir"/charts/linkerd2-cni
"$bindir"/helm dep up "$rootdir"/charts/linkerd2
"$bindir"/helm dep up "$rootdir"/charts/patch
"$bindir"/helm lint --set global.identityTrustAnchorsPEM="fake-trust" --set identity.issuer.tls.crtPEM="fake-cert" --set identity.issuer.tls.keyPEM="fake-key" --set identity.issuer.crtExpiry="fake-expiry-date" "$rootdir"/charts/linkerd2
"$bindir"/helm lint "$rootdir"/charts/linkerd2-cni
# `bin/helm-build package` assumes the presence of "$rootdir"/target/helm/index-pre.yaml which is downloaded in the chart_deploy CI job
if [ "$1" = package ]; then
. "$bindir"/_tag.sh
tag=$(named_tag)
clean_head || { echo 'There are uncommitted changes'; exit 1; }
regex='(edge|stable)-([0-9]+\.[0-9]+\.[0-9]+)'
if [[ ! "$tag" =~ $regex ]]; then
echo 'Version tag is malformed'
exit 1
fi
fullVersion=${BASH_REMATCH[0]}
repo=${BASH_REMATCH[1]}
version=${BASH_REMATCH[2]}
# set version in Values files
setValues "{version}" $fullVersion
"$bindir"/helm --version $version --app-version $tag -d "$rootdir"/target/helm package "$rootdir"/charts/linkerd2
"$bindir"/helm --version $version --app-version $tag -d "$rootdir"/target/helm package "$rootdir"/charts/linkerd2-cni
mv "$rootdir"/target/helm/index-pre.yaml "$rootdir"/target/helm/index-pre-$version.yaml
"$bindir"/helm repo index --url "https://helm.linkerd.io/$repo/" --merge "$rootdir"/target/helm/index-pre-$version.yaml "$rootdir"/target/helm
# restore version in Values files
setValues $fullVersion "{version}"
fi