From b71680dffd985a71e564065132364d017ede8f1d Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 5 Jan 2022 07:37:21 -1000 Subject: [PATCH] ;tools: release --- tools/release | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 tools/release diff --git a/tools/release b/tools/release new file mode 100755 index 000000000..b249e52f2 --- /dev/null +++ b/tools/release @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +# * release +# ** Usage + +set -e + +usage() { + cat <&2 + exit 1 + elif versionIsPreview "$V"; then + echo "$(majorVersionIncrement "$MAJOR")-branch" + else + echo "$MAJOR-branch" + fi +} + +# ** git + +# Does the named branch exist in this git repo ? +gitBranchExists() { + B="$1" + git branch -l "$B" | grep -q "$B" +} + +# Switch to the named git branch, creating it if it doesn't exist. +gitSwitchAutoCreate() { + B="$1" + if gitBranchExists "$B"; then + git switch "$B" + else + git switch -c "$B" + fi +} + +# ** main + +# Run a command with optional logging ($ECHO), dry-running ($DRY) and pausing ($PAUSE). +run() { + if [[ -n $PAUSE ]]; then read -rp "pausing, next is: $*" + elif [[ -n $ECHO || -n $DRY ]]; then echo "$@" + fi + if [[ -z $DRY ]]; then "$@"; fi +} + +# Create/switch to appropriate release branch and prepare for release. +prep() { + VERSION="$1" + [[ -z "$VERSION" ]] && usage + BRANCH=$(versionReleaseBranch "$VERSION") + COMMIT="-c" + run gitSwitchAutoCreate "$BRANCH" + run ./Shake setversion "$VERSION" $COMMIT + run ./Shake cmdhelp $COMMIT + run ./Shake mandates + run ./Shake manuals $COMMIT + run ./Shake changelogs $COMMIT +} + +# Push the current branch to the CI branches that generate platform binaries. +bin() { + run git push -f origin master:ci-windows + run git push -f origin master:ci-mac + run git push -f origin master:ci-linux-x64 +} + +if declare -f "$1" > /dev/null; then "$@"; else usage; fi