From 2724b835e470746b5f4d753cd857f4f03f32921b Mon Sep 17 00:00:00 2001 From: Arne Diekmann Date: Tue, 26 May 2020 18:07:58 +0200 Subject: [PATCH] feat: add release script --- scripts/release.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 scripts/release.sh diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..3130c34 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +set -e + +check_commands() { + for command in $@; do + if ! command -v $command >/dev/null; then + echo -e "Install \033[1m$command\033[0m" + exit 1 + fi + done +} + +inc_version() { + version=$1 + version_array=(${version//./ }) + + if [ $2 = "major" ]; then + ((version_array[0]++)) + version_array[1]=0 + version_array[2]=0 + fi + + if [ $2 = "minor" ]; then + ((version_array[1]++)) + version_array[2]=0 + fi + + if [ $2 = "patch" ]; then + ((version_array[2]++)) + fi + + echo "${version_array[0]}.${version_array[1]}.${version_array[2]}" +} + +check_commands git jq yq cr + +if [[ "$#" != "1" ]] || [[ ! "$1" =~ ^(patch|minor|major)$ ]]; then + echo -e "Usage: $0 \033[1mpatch|minor|major\033[0m" + exit 1 +fi + +if [[ $(git status --porcelain) ]]; then + echo -e "The repository has changes. Commit first...\033[0;31mAborting!\033[0m" + exit 1 +fi + +SCRIPT_DIR=$( + cd "$(dirname "$0")" >/dev/null 2>&1 + pwd -P +) + +git pull --rebase +current_version=$(yq r $SCRIPT_DIR/../helm/Chart.yaml version) +version=$(inc_version $current_version $1) +cd $SCRIPT_DIR/.. +docker build -t neoskop/cert-manager-webhook-dnsimple:$version . +docker push neoskop/cert-manager-webhook-dnsimple:$version +cd - &>/dev/null +sed -i "s/appVersion: .*/appVersion: \"$version\"/" $SCRIPT_DIR/../deploy/dnsimple/Chart.yaml +sed -i "s/version: .*/version: $version/" $SCRIPT_DIR/../deploy/dnsimple/Chart.yaml +yq w -i $SCRIPT_DIR/../deploy/dnsimple/Chart.yaml version $version +yq w -i $SCRIPT_DIR/../deploy/dnsimple/Chart.yaml appVersion $version +yq w -i $SCRIPT_DIR/../deploy/dnsimple/values.yaml image.tag $version +git add . +git commit -m "chore: Bump version to ${version}." +git push + +helm package helm --destination .deploy +cr upload -o neoskop -r cert-manager-webhook-dnsimple -p .deploy +git checkout gh-pages +cr index -i ./index.yaml -p .deploy -o neoskop -r cert-manager-webhook-dnsimple -c https://neoskop.github.io/cert-manager-webhook-dnsimple/ +git add index.yaml +git commit -m "chore: Bump version to ${version}." +git push +git checkout master +rm -rf .deploy/