2023-02-18 15:13:52 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
_user() {
|
|
|
|
printf "\033[0;33m%s\033[0m" "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
_fail() {
|
|
|
|
printf "\033[0;31m==> %s\033[0m\n\n" "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
prep_release() {
|
|
|
|
if ! git diff-index --quiet HEAD --; then
|
|
|
|
_fail "Repo must not be dirty"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep -rlZE 'v\d+\.\d+\.\d+' --exclude=Dockerfile --exclude-dir=.git . | xargs sed -i '' 's/v[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}/'"$1"'/g'
|
|
|
|
|
2023-02-19 11:46:50 +00:00
|
|
|
_user "Prepare release draft on GitHub? "
|
2023-02-18 15:13:52 +00:00
|
|
|
read -r answer
|
|
|
|
if [ "$answer" = "y" ]; then
|
|
|
|
git add --update
|
2023-02-18 15:27:44 +00:00
|
|
|
git commit -S -m "Prepare for $1 release"
|
2023-02-18 15:13:52 +00:00
|
|
|
git push origin main
|
2023-02-18 15:27:44 +00:00
|
|
|
git tag -s "$1" -m "Release $1"
|
2023-02-18 15:13:52 +00:00
|
|
|
git push --tags
|
2023-02-19 11:46:50 +00:00
|
|
|
gh release create --draft --latest --title "$1" --verify-tag
|
|
|
|
gh release view "$1" --web
|
2023-02-18 15:13:52 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_help() {
|
|
|
|
echo "Usage: ./run.sh [command]"
|
|
|
|
echo ""
|
|
|
|
echo "Available commands:"
|
2023-02-19 11:46:50 +00:00
|
|
|
echo "prep-release <version> Prepare new release draft"
|
2023-02-18 15:13:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd="${1:-}"
|
|
|
|
case "$cmd" in
|
|
|
|
"prep-release")
|
|
|
|
shift
|
|
|
|
prep_release "$@"
|
|
|
|
;;
|
|
|
|
*) _help ;;
|
|
|
|
esac
|