fix(Chart): escape changelog messages for artifacthub
All checks were successful
Helm / helm-lint (push) Successful in 12s
Helm / helm-unittest (push) Successful in 17s

This commit is contained in:
Markus Pesch 2025-06-06 22:05:52 +02:00
parent 975eaa0d5d
commit 39c064c8b4
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 13 additions and 9 deletions

View File

@ -54,7 +54,8 @@ else
fi
fi
YAML_FILE=$(mktemp)
CHANGE_LOG_YAML=$(mktemp)
echo "[]" > "${CHANGE_LOG_YAML}"
function map_type_to_kind() {
case "${1}" in
@ -86,25 +87,28 @@ echo "INFO: Generate change log entries from ${OLD_TAG} until ${NEW_TAG}"
while IFS= read -r line; do
if [[ "${line}" =~ ^([a-zA-Z]+)(\([^\)]+\))?\:\ (.+)$ ]]; then
TYPE="${BASH_REMATCH[1]}"
KIND=$(map_type_to_kind "${TYPE}")
if [ "${TYPE}" == "skip" ]; then
if [ "${KIND}" == "skip" ]; then
continue
fi
DESC="${BASH_REMATCH[3]}"
KIND=$(map_type_to_kind "${TYPE}")
echo "- ${KIND}: ${DESC}"
yq --inplace ". += [ {\"kind\": \"${KIND}\", \"description\": \"${DESC}\"}]" "${YAML_FILE}"
jq --arg kind changed --arg description "$DESC" '. += [ $ARGS.named ]' < ${CHANGE_LOG_YAML} > ${CHANGE_LOG_YAML}.new
mv ${CHANGE_LOG_YAML}.new ${CHANGE_LOG_YAML}
fi
done <<< "${COMMIT_TITLES}"
if [ -s "${YAML_FILE}" ]; then
yq --no-colors --inplace ".annotations.\"artifacthub.io/changes\" |= loadstr(\"${YAML_FILE}\") | sort_keys(.)" "${CHART_FILE}"
if [ -s "${CHANGE_LOG_YAML}" ]; then
yq --inplace --input-format json --output-format yml "${CHANGE_LOG_YAML}"
yq --no-colors --inplace ".annotations.\"artifacthub.io/changes\" |= loadstr(\"${CHANGE_LOG_YAML}\") | sort_keys(.)" "${CHART_FILE}"
else
echo "ERROR: Changelog file is empty: ${YAML_FILE}" 1>&2
echo "ERROR: Changelog file is empty: ${CHANGE_LOG_YAML}" 1>&2
exit 1
fi
rm "${YAML_FILE}"
rm "${CHANGE_LOG_YAML}"

View File

@ -14,7 +14,7 @@ jobs:
- name: Install tooling
run: |
apk update
apk add git npm yq
apk add git npm jq yq
- uses: actions/checkout@v4
with: