fix(Chart): escape changelog messages for artifacthub
Some checks failed
Helm / helm-unittest (push) Successful in 17s
Helm / helm-lint (push) Successful in 24s
Release / publish-chart (push) Failing after 18s

This commit is contained in:
Markus Pesch 2025-06-06 22:01:04 +02:00
parent c9a45d8040
commit 863c3a30c1
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 16 additions and 12 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:
@ -22,8 +22,8 @@ jobs:
- name: Add Artifacthub.io annotations
run: |
NEW_TAG="$(git tag --sort=-version:refname | head -n 1)"
OLD_TAG="$(git tag --sort=-version:refname | head -n 2 | tail -n 1)"
NEW_TAG="$(git tag --sort=-version:refname | head --lines 1)"
OLD_TAG="$(git tag --sort=-version:refname | head --lines 2 | tail --lines 1)"
.gitea/scripts/add-annotations.sh "${OLD_TAG}" "${NEW_TAG}"
- name: Package chart