mirror of
https://github.com/plcnk/charts.git
synced 2026-04-13 05:00:38 +00:00
feat(charts): Now using bjw-s's common library chart (#7)
This commit is contained in:
committed by
GitHub
parent
8a84b5e13a
commit
31bbf1ca94
56
hack/update-changelog.sh
Executable file
56
hack/update-changelog.sh
Executable file
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
# require yq
|
||||
command -v yq >/dev/null 2>&1 || {
|
||||
echo >&2 'yq (https://github.com/mikefarah/yq) is not installed. Aborting.'
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo 'Usage: {append | replace} changelog [chart...]'
|
||||
exit
|
||||
fi
|
||||
|
||||
update_type="$1"
|
||||
shift
|
||||
|
||||
changelog="$(yq -P <<<"$1")"
|
||||
export changelog
|
||||
shift
|
||||
|
||||
CHARTS=()
|
||||
if [ "$#" -gt 0 ]; then
|
||||
# Get changed dirs from params
|
||||
for file in "$@"; do
|
||||
CHARTS+=( "$(dirname "$file")" )
|
||||
done
|
||||
else
|
||||
# Get changed dirs from uncommitted changes
|
||||
for file in $(git status --porcelain charts | grep '^M' | cut -c4-); do
|
||||
CHARTS+=( "$(dirname "$file")" )
|
||||
done
|
||||
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 --inplace "$expression" "$meta_file"
|
||||
echo "Updated $(basename "$chart") changelog"
|
||||
) done
|
||||
Reference in New Issue
Block a user