chore(ci): Include charts-only CI in this repo
This commit is contained in:
49
.github/scripts/check-releasenotes.sh
vendored
Normal file
49
.github/scripts/check-releasenotes.sh
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# Check if release notes have been changed
|
||||
# Usage ./check-releasenotes.sh path
|
||||
|
||||
# require yq
|
||||
command -v yq >/dev/null 2>&1 || {
|
||||
printf >&2 "%s\n" "yq (https://github.com/mikefarah/yq) is not installed. Aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Absolute path of repository
|
||||
repository=$(git rev-parse --show-toplevel)
|
||||
|
||||
# Allow for a specific chart to be passed in as a argument
|
||||
if [ $# -ge 1 ] && [ -n "$1" ]; then
|
||||
root="$1"
|
||||
chart_file="${1}/Chart.yaml"
|
||||
if [ ! -f "$chart_file" ]; then
|
||||
printf >&2 "File %s\n does not exist.\n" "${chart_file}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd $root
|
||||
|
||||
if [ -z "$DEFAULT_BRANCH" ]; then
|
||||
DEFAULT_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
|
||||
fi
|
||||
|
||||
CURRENT=$(cat Chart.yaml | yq e '.annotations."artifacthub.io/changes"' -P -)
|
||||
|
||||
if [ "$CURRENT" == "" ] || [ "$CURRENT" == "null" ]; then
|
||||
printf >&2 "Changelog annotation has not been set in %s!\n" "$chart_file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEFAULT_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
|
||||
ORIGINAL=$(git show origin/$DEFAULT_BRANCH:./Chart.yaml | yq e '.annotations."artifacthub.io/changes"' -P -)
|
||||
|
||||
if [ "$CURRENT" == "$ORIGINAL" ]; then
|
||||
printf >&2 "Changelog annotation has not been updated in %s!\n" "$chart_file"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
printf >&2 "%s\n" "No chart folder has been specified."
|
||||
exit 1
|
||||
fi
|
||||
47
.github/scripts/gen-helm-docs.sh
vendored
Normal file
47
.github/scripts/gen-helm-docs.sh
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
|
||||
# Generate helm-docs for Helm charts
|
||||
# Usage ./gen-helm-docs.sh [stable/incubator] [chart]
|
||||
|
||||
# require helm-docs
|
||||
command -v helm-docs >/dev/null 2>&1 || {
|
||||
echo >&2 "helm-docs (https://github.com/k8s-at-home/helm-docs) is not installed. Aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Absolute path of repository
|
||||
repository=$(git rev-parse --show-toplevel)
|
||||
|
||||
# Templates to copy into each chart directory
|
||||
readme_template="${repository}/hack/templates/README.md.gotmpl"
|
||||
readme_config_template="${repository}/hack/templates/README_CONFIG.md.gotmpl"
|
||||
|
||||
# Gather all charts using the common library, excluding common-test
|
||||
charts=$(find "${repository}" -name "Chart.yaml")
|
||||
|
||||
# Allow for a specific chart to be passed in as a argument
|
||||
if [ $# -ge 1 ] && [ -n "$1" ] && [ -n "$2" ]; then
|
||||
charts="${repository}/charts/$1/$2/Chart.yaml"
|
||||
root="$(dirname "${charts}")"
|
||||
if [ ! -f "$charts" ]; then
|
||||
echo "File ${charts} does not exist."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
root="${repository}/charts/stable"
|
||||
fi
|
||||
|
||||
for chart in ${charts}; do
|
||||
chart_directory="$(dirname "${chart}")"
|
||||
echo "-] Copying templates to ${chart_directory}"
|
||||
# Copy CONFIG template to each Chart directory, do not overwrite if exists
|
||||
cp -n "${readme_config_template}" "${chart_directory}" || true
|
||||
done
|
||||
|
||||
# Run helm-docs for charts using the common library and the common library itself
|
||||
helm-docs \
|
||||
--ignore-file="${repository}/.helmdocsignore" \
|
||||
--template-files="${readme_template}" \
|
||||
--template-files="$(basename "${readme_config_template}")" \
|
||||
--chart-search-root="${root}"
|
||||
52
.github/scripts/renovate-releasenotes.sh
vendored
Normal file
52
.github/scripts/renovate-releasenotes.sh
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# Check if release notes have been changed
|
||||
# Usage ./check-releasenotes.sh path
|
||||
|
||||
# require yq
|
||||
command -v yq >/dev/null 2>&1 || {
|
||||
printf >&2 "%s\n" "yq (https://github.com/mikefarah/yq) is not installed. Aborting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Allow for a specific chart to be passed in as a argument
|
||||
if [ $# -ge 1 ] && [ -n "$1" ]; then
|
||||
root="$1"
|
||||
chart_file="${1}/Chart.yaml"
|
||||
if [ ! -f "$chart_file" ]; then
|
||||
printf >&2 "File %s does not exist.\n" "${chart_file}"
|
||||
exit 1
|
||||
fi
|
||||
cd "${root}"
|
||||
|
||||
if [ -z "$DEFAULT_BRANCH" ]; then
|
||||
DEFAULT_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
|
||||
fi
|
||||
|
||||
printf "Updating changelog annotation for chart %s\n" "$root"
|
||||
|
||||
# Loop over all dependencies in current chart version
|
||||
NEW_DEPENDENCIES=()
|
||||
while IFS='' read -r line; do NEW_DEPENDENCIES+=("$line"); done < <(yq e '.dependencies[].name' -P Chart.yaml | LC_ALL=C sort)
|
||||
OLD_DEPENDENCIES=$(git show "origin/$DEFAULT_BRANCH:./Chart.yaml" | yq e '.dependencies[].name' -P - | LC_ALL=C sort)
|
||||
|
||||
tmpfile=$(mktemp)
|
||||
trap 'rm -f "$tmpfile"' EXIT
|
||||
|
||||
for DEP_NAME in "${NEW_DEPENDENCIES[@]}"
|
||||
do
|
||||
NEW_VERSION=$(yq e ".dependencies[] | select(.name == \"$DEP_NAME\") | .version" -P Chart.yaml)
|
||||
OLD_VERSION=$(git show "origin/$DEFAULT_BRANCH:./Chart.yaml" | yq e ".dependencies[] | select(.name == \"$DEP_NAME\") | .version" -P -)
|
||||
if [ "${NEW_VERSION}" != "${OLD_VERSION}" ]; then
|
||||
printf "%s\n" "- kind: changed" >> "${tmpfile}"
|
||||
printf " description: Upgraded \`%s\` chart dependency to version \`%s\`.\n" "${DEP_NAME}" "${NEW_VERSION}" >> "${tmpfile}"
|
||||
fi
|
||||
done
|
||||
|
||||
yq eval-all --inplace 'select(fileIndex == 0).annotations."artifacthub.io/changes" = (select(fileIndex == 1) | to_yaml) | select(fileIndex==0)' Chart.yaml "${tmpfile}"
|
||||
else
|
||||
printf >&2 "%s\n" "No chart folder has been specified."
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user