helm-charts/publish.sh

73 lines
1.9 KiB
Bash
Raw Normal View History

#/bin/sh
2024-11-06 22:50:54 +01:00
HELM_REPO=${HELM_REPO:-codeberg.org/wrenix/helm-charts}
HELM_REPO_URL="oci://${HELM_REPO}"
COMMIT_SCOPE=${2:-fix}
COMMIT_MESSAGE=${1:-"update appVersion"}
2024-01-28 11:07:59 +01:00
ct lint # || exit 1
2024-01-13 01:32:22 +01:00
for p in * ; do
if \
2024-01-12 23:52:52 +01:00
[ ! -d $p ] || \
[ ! -f $p/Chart.yaml ] \
; then
continue
fi
echo "${p}:";
# last pkg
2024-03-13 21:39:05 +01:00
lastTag=$(git tag -l "${p}-v*" | sort --sort=version | tail -1)
lastVersion=${lastTag#${p}-v}
echo "last pkg: ${lastVersion}"
# Chart version
v=$(dasel -f "${p}/Chart.yaml" -s version)
echo "version: ${v}";
# should be increased?
tag="${p}-v${v}"
# check if a old version exists
2023-07-24 21:54:52 +02:00
if [ ! $lastTag == '' ]; then
# check if changes since new version happen
changes=$(git diff "${lastTag}" -- "${p}" | wc -l);
if [ "$changes" -gt "0" ]; then
# check / lint if version was increased correct
if [ "$tag" == "$lastTag" ]; then
echo "changed helmchart should create new pkg - diff line count has:"
echo $(git diff "${lastTag}" -- "${p}" | wc -l);
exit 1
fi
else
echo "nothing todo"
echo
continue;
fi
fi
2024-11-06 22:38:14 +01:00
2024-11-08 15:43:25 +01:00
echo "update docs"
2024-11-06 22:38:14 +01:00
helm-docs -t ./README.md.gotmpl -t _docs.gotmpl -o README.md -g "${p}"
helm-docs -t ./README.adoc.gotmpl -t _docs.gotmpl -o README.adoc -g "${p}"
2024-11-08 15:43:25 +01:00
echo "package and push helm-chart"
helm package "${p}"
2024-11-06 22:50:54 +01:00
helm push "${p}-${v}.tgz" "${HELM_REPO_URL}";
2024-11-08 15:43:25 +01:00
echo "update artifacthub.io"
2024-11-06 22:50:54 +01:00
oras push "${HELM_REPO}/${p}:artifacthub.io" \
--config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \
"${p}/artifacthub-repo.yml":application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml
2024-11-08 15:43:25 +01:00
echo "push to git"
2024-02-20 23:43:46 +01:00
git add "${p}/" "docs/modules/charts/nav.adoc" "docs/modules/charts/pages/${p}.adoc"
git commit -m "${COMMIT_SCOPE}(${p}): ${COMMIT_MESSAGE}"
git tag "${tag}" --no-sign;
git push --tags origin main;
echo
done