Last active
November 9, 2020 03:02
-
-
Save scottrigby/29f8ae263e36d38054dc68703fc8d57f to your computer and use it in GitHub Desktop.
scripts for https://github.com/helm/charts/issues/24030
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
settings() { | |
set -eu | |
if [ "${DEBUG:-}" = 1 ]; then | |
export PS4='+ ($LINENO) ' | |
set -x | |
fi | |
} | |
requirements() { | |
for c in git gh; do | |
if ! command -v $c > /dev/null 2>&1; then | |
echo "$c could not be found" | |
exit 1 | |
fi | |
done | |
} | |
validate_input() { | |
if [ -z "$1" ] || [ ! -f "$1"/Chart.yaml ]; then | |
echo "You must supply a chart path" | |
ecit 1 | |
fi | |
} | |
get_branch() { | |
branch=$(echo 24030-"$1" | tr '/' '-') | |
export branch=$branch | |
} | |
checkout_branch() { | |
git checkout -b $branch | |
} | |
add_commit() { | |
git add -p "$1" | |
git commit -s -m "[$1] add repo archive notice" | |
} | |
pr() { | |
# See https://github.com/cli/cli/issues/480 | |
# Allows gh pr create to skip remote prompt, saving time. | |
# Damn, doesn't work. To-do: figure this out later. | |
# git push -u scottrigby $branch | |
gh pr create -b 'See #24030' | |
} | |
stash() { | |
git stash | |
} | |
master() { | |
git checkout master | |
} | |
pop() { | |
git stash pop | |
} | |
settings | |
requirements | |
validate_input "$@" | |
get_branch "$@" | |
checkout_branch | |
add_commit "$@" | |
pr | |
stash | |
master | |
pop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
settings() { | |
set -eu | |
if [ "${DEBUG:-}" = 1 ]; then | |
export PS4='+ ($LINENO) ' | |
set -x | |
fi | |
} | |
validate_input() { | |
# shellcheck disable=SC2235 | |
if [ -z "${1:-}" ] || ([ "$1" != 'stable' ] && [ "$1" != 'incubator' ]); then | |
echo "You must specify the repo: stable or incubator" | |
exit 1 | |
fi | |
} | |
requirements() { | |
for c in grep find; do | |
if ! command -v $c > /dev/null 2>&1; then | |
echo "$c could not be found" | |
exit 1 | |
fi | |
done | |
} | |
find_non_deprecated() { | |
local deprecated=$(grep -e 'deprecated: true' "$1"/*/Chart.yaml | cut -d'/' -f1-2 | uniq | sort) | |
local all=$(find "$1" -type d -maxdepth 1 -mindepth 1 | sort) | |
# Remove deprecated charts | |
non_deprecated=$(comm -13 <(echo "$deprecated") <(echo "$all")) | |
export non_deprecated="$non_deprecated" | |
} | |
add_note() { | |
local file=$1/README.md | |
local note='# ⚠️ Repo Archive Notice | |
As of Nov 13, 2020, charts in this repo will no longer be updated. | |
For more information, see the Helm Charts [Deprecation and Archive Notice](https://github.com/helm/charts#%EF%B8%8F-deprecation-and-archive-notice), and [Update](https://helm.sh/blog/charts-repo-deprecation/).' | |
echo -e "$note\n\n$(cat $file)" > $file | |
} | |
add_notes_all() { | |
for c in $non_deprecated; do | |
add_note $c | |
done | |
} | |
bump_versions() { | |
for c in $non_deprecated; do | |
old=$(sed -n -e 's/^version: //p' "$c"/Chart.yaml | sed s/\"//g) | |
# Bump PATCH. See https://github.com/tomologic/bump-semver/blob/master/bump.sh | |
new=$(echo $old | awk -F. -v a="0" -v b="0" -v c="1" '{printf("%d.%d.%d", $1+a, $2+b , $3+c)}') | |
# Don't replace all instances of this version, in case appVersion matches, etc. | |
# Handle both quoted and unquoted | |
sed -i '' "s,version: \"$old\",version: \"$new\",g" "$c"/Chart.yaml | |
sed -i '' "s,version: $old,version: $new,g" "$c"/Chart.yaml | |
done | |
} | |
find_non_deprecated "$@" | |
add_notes_all | |
bump_versions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
First make local changes for either
incubator
orstable
:$ ./helm-charts-24030.sh incubator
Then one chart at a time, create the local branch, interactive add, commit, and create PR:
$ ./helm-charts-24030-pr.sh incubator/aws-alb-ingress-controller