2022-04-01 08:12:38 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
|
|
|
|
2022-08-08 21:57:58 +00:00
|
|
|
# Designed to ensure the appversion in Chart.yaml is in sync with the primary Chart tag if found
|
2022-07-28 20:39:13 +00:00
|
|
|
# Also makes sure that home link is pointing to the correct url
|
2022-04-01 08:12:38 +00:00
|
|
|
sync_tag() {
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
|
|
|
echo "Attempting to sync primary tag with appversion for: ${chartname}"
|
|
|
|
local tag="$(cat ${chart}/values.yaml | grep '^ tag: ' | awk -F" " '{ print $2 }' | head -1)"
|
|
|
|
tag="${tag%%@*}"
|
|
|
|
tag="${tag:-auto}"
|
|
|
|
tag=$(echo $tag | sed "s/release-//g")
|
|
|
|
tag=$(echo $tag | sed "s/release_//g")
|
|
|
|
tag=$(echo $tag | sed "s/version-//g")
|
|
|
|
tag=$(echo $tag | sed "s/version_//g")
|
|
|
|
tag="${tag#*V.}"
|
|
|
|
tag="${tag#*v-}"
|
|
|
|
tag="${tag#*v}"
|
|
|
|
tag="${tag%-*}"
|
|
|
|
tag="${tag:0:10}"
|
|
|
|
tag="${tag%-}"
|
|
|
|
tag="${tag%_}"
|
|
|
|
tag="${tag%.}"
|
2022-07-29 14:13:18 +00:00
|
|
|
echo "Updating tag of ${chartname} to ${tag}..."
|
2022-04-01 08:12:38 +00:00
|
|
|
sed -i -e "s|appVersion: .*|appVersion: \"${tag}\"|" "${chart}/Chart.yaml"
|
2022-07-29 14:13:18 +00:00
|
|
|
echo "Updating icon of ${chartname}..."
|
2022-08-01 20:54:37 +00:00
|
|
|
sed -i -e "s|icon: .*|icon: https:\/\/truecharts.org\/img\/hotlink-ok\/chart-icons\/${chartname}.png|" "${chart}/Chart.yaml"
|
2022-07-29 14:13:18 +00:00
|
|
|
echo "Updating home of ${chartname}..."
|
2022-07-29 00:17:37 +00:00
|
|
|
sed -i -e "s|home: .*|home: https:\/\/truecharts.org\/docs\/charts\/${train}\/${chartname}|" "${chart}/Chart.yaml"
|
2022-07-31 10:54:01 +00:00
|
|
|
echo "Attempting to update sources of ${chartname}..."
|
2022-07-31 20:27:36 +00:00
|
|
|
echo "Using go-yq verion: <$(go-yq -V)>"
|
2022-07-31 19:15:36 +00:00
|
|
|
# Get all sources (except truecharts)
|
|
|
|
curr_sources=$(go-yq '.sources[] | select(. != "https://github.com/truecharts*")' "${chart}/Chart.yaml")
|
|
|
|
# Empty sources list in-place
|
|
|
|
go-yq -i 'del(.sources.[])' "${chart}/Chart.yaml"
|
|
|
|
# Add truechart source
|
|
|
|
tcsource="https://github.com/truecharts/charts/tree/master/charts/$train/$chartname" go-yq -i '.sources += env(tcsource)' "${chart}/Chart.yaml"
|
|
|
|
# Add the rest of the sources
|
|
|
|
while IFS= read -r line; do
|
|
|
|
src="$line" go-yq -i '.sources += env(src)' "${chart}/Chart.yaml"
|
|
|
|
done <<< "$curr_sources"
|
|
|
|
echo "Sources of ${chartname} updated!"
|
2022-04-01 08:12:38 +00:00
|
|
|
}
|
|
|
|
export -f sync_tag
|
|
|
|
|
2022-07-14 13:45:54 +00:00
|
|
|
sync_helmignore() {
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
|
|
|
echo "Attempting to sync HelmIgnore file for: ${chartname}"
|
2022-07-14 13:50:39 +00:00
|
|
|
rm -rf ${chart}/.helmignore
|
2022-07-19 10:51:38 +00:00
|
|
|
cp templates/chart/.helmignore ${chart}/
|
2022-07-14 13:45:54 +00:00
|
|
|
}
|
|
|
|
export -f sync_helmignore
|
|
|
|
|
2022-04-01 08:12:38 +00:00
|
|
|
create_changelog() {
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
|
|
|
local prevversion="$(git tag -l "${chartname}-*" --sort=-v:refname | head -n 1)"
|
2022-04-01 08:25:55 +00:00
|
|
|
echo "Generating changelogs for: ${chartname}"
|
|
|
|
# SCALE "Changelog" containing only last change
|
|
|
|
git-chglog --next-tag ${chartname}-${chartversion} --tag-filter-pattern ${chartname} --path ${chart} -o ${chart}/app-changelog.md ${chartname}-${chartversion}
|
|
|
|
# Append SCALE changelog to actual changelog
|
2022-04-01 08:12:38 +00:00
|
|
|
|
2022-04-01 08:25:55 +00:00
|
|
|
if [[ -f "${chart}/CHANGELOG.md" ]]; then
|
|
|
|
true
|
|
|
|
else
|
|
|
|
touch ${chart}/CHANGELOG.md
|
2022-04-01 08:12:38 +00:00
|
|
|
fi
|
2022-04-01 08:25:55 +00:00
|
|
|
sed -i '1d' ${chart}/CHANGELOG.md
|
|
|
|
cat ${chart}/app-changelog.md | cat - ${chart}/CHANGELOG.md > temp && mv temp ${chart}/CHANGELOG.md
|
2022-07-12 11:04:56 +00:00
|
|
|
sed -i '1s/^/# Changelog\n\n/' ${chart}/CHANGELOG.md
|
2022-04-01 08:25:55 +00:00
|
|
|
rm ${chart}/app-changelog.md || echo "changelog not found..."
|
2022-04-01 08:12:38 +00:00
|
|
|
}
|
|
|
|
export -f create_changelog
|
|
|
|
|
|
|
|
generate_docs() {
|
|
|
|
local chart="$1"
|
|
|
|
local chartname="$2"
|
|
|
|
local train="$3"
|
|
|
|
local chartversion="$4"
|
2022-04-01 08:25:55 +00:00
|
|
|
echo "Generating Docs"
|
|
|
|
helm-docs \
|
|
|
|
--ignore-file=".helmdocsignore" \
|
|
|
|
--output-file="README.md" \
|
2022-07-19 10:51:38 +00:00
|
|
|
--template-files="/__w/charts/charts/templates/docs/README.md.gotmpl" \
|
2022-04-01 08:25:55 +00:00
|
|
|
--chart-search-root="${chart}"
|
2022-08-22 16:46:38 +00:00
|
|
|
sed -i "s/TRAINPLACEHOLDER/${train}/" "${chart}/README.md"
|
2022-04-01 08:12:38 +00:00
|
|
|
}
|
|
|
|
export -f generate_docs
|
|
|
|
|
2022-04-03 08:43:00 +00:00
|
|
|
|
|
|
|
if [[ -d "charts/${1}" ]]; then
|
|
|
|
echo "Start processing charts/${1} ..."
|
|
|
|
chartversion=$(cat charts/${1}/Chart.yaml | grep "^version: " | awk -F" " '{ print $2 }')
|
|
|
|
chartname=$(basename charts/${1})
|
|
|
|
train=$(basename $(dirname "charts/${1}"))
|
|
|
|
SCALESUPPORT=$(cat charts/${1}/Chart.yaml | yq '.annotations."truecharts.org/SCALE-support"' -r)
|
2022-07-14 13:45:54 +00:00
|
|
|
sync_helmignore "charts/${1}" "${chartname}" "$train" "${chartversion}" || echo "Syncing HelmIgnore file failed..."
|
2022-09-27 17:00:46 +00:00
|
|
|
helm dependency update "charts/${1}" --skip-refresh || (sleep 10 && helm dependency update "charts/${1}" --skip-refresh) || (sleep 10 && helm dependency update "charts/${1}" --skip-refresh)
|
2022-04-03 08:43:00 +00:00
|
|
|
sync_tag "charts/${1}" "${chartname}" "$train" "${chartversion}" || echo "Tag sync failed..."
|
|
|
|
create_changelog "charts/${1}" "${chartname}" "$train" "${chartversion}" || echo "changelog generation failed..."
|
|
|
|
generate_docs "charts/${1}" "${chartname}" "$train" "${chartversion}" || echo "Docs generation failed..."
|
|
|
|
else
|
|
|
|
echo "Chart 'charts/${1}' no longer exists in repo. Skipping it..."
|
|
|
|
fi
|
|
|
|
echo "Done processing charts/${1} ..."
|