diff --git a/.github/workflows/renovate.yaml b/.github/workflows/renovate.yaml index a4a7dd754..28c536655 100644 --- a/.github/workflows/renovate.yaml +++ b/.github/workflows/renovate.yaml @@ -49,7 +49,7 @@ jobs: set -eux export DESCRIPTION="$(sed 's/^:.*: //' <<<"$TITLE")" CHANGELOG="$(yq -o json '[{"kind": "changed", "description": strenv(DESCRIPTION)}]')" - ./hack/update-changelog.sh "$CHANGELOG" ${{ steps.changes.outputs.charts_files }} + ./hack/update-changelog.sh replace "$CHANGELOG" ${{ steps.changes.outputs.charts_files }} - name: Set type to patch if: contains(steps.pr.outputs.labels, 'patch') || contains(steps.pr.outputs.labels, 'digest') diff --git a/hack/update-changelog.sh b/hack/update-changelog.sh index 07ed1798c..7bf3cde4b 100755 --- a/hack/update-changelog.sh +++ b/hack/update-changelog.sh @@ -8,11 +8,14 @@ command -v yq >/dev/null 2>&1 || { exit 1 } -if [ "$#" -eq 0 ]; then - echo 'Usage: changelog [chart...]' +if [ "$#" -lt 2 ]; then + echo 'Usage: {append | replace} changelog [chart...]' exit fi +update_type="$1" +shift + changelog="$(yq -P <<<"$1")" export changelog shift @@ -31,10 +34,23 @@ else fi CHARTS=( $(sort -u <<<"${CHARTS[*]}") ) +case "$update_type" in + append) + expression='.annotations."artifacthub.io/changes" |= (@yamld + (strenv(changelog) | @yamld) | @yaml | trim)' + ;; + replace) + expression='.annotations."artifacthub.io/changes" = (env(changelog) | @yaml | trim)' + ;; + *) + echo "Invalid update type: $update_type" >&2 + exit 1 + ;; +esac + for chart in "${CHARTS[@]}"; do ( meta_file="$chart/Chart.yaml" if [ ! -f "$meta_file" ]; then echo >&2 "Invalid file: $meta_file"; exit; fi - yq -i '.annotations."artifacthub.io/changes" = (strenv(changelog) | @yamld style="literal" | @yaml)' "$meta_file" + yq --inplace "$expression" "$meta_file" echo "Updated $(basename "$chart") changelog" ) done