Last active
November 15, 2024 16:36
-
-
Save JonathanWillitts/3e7e2f107d32836222d38a80a025a1a7 to your computer and use it in GitHub Desktop.
Pre-release helper script, to ensure git flow is initialised, and dir initialised for build
This file contains 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 | |
echo "" | |
echo "Running pre-release script for: " | |
echo "$PWD" | |
set -e | |
echo "Checking repo statuses ..." | |
git checkout main && git pull && \ | |
git checkout develop && git pull | |
echo "" | |
while true; do | |
read -p "Continue? [y/n]" yn | |
case $yn in | |
[Yy]* ) | |
break | |
;; | |
[Nn]* ) exit 1;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
until echo -e "\nChecking git flow installed ..." && brew list git-flow; do | |
read -p "Git flow not installed. Install git-flow (with 'brew install git-flow')? [y/n]" yn | |
case $yn in | |
[Yy]* ) brew install git-flow;; | |
[Nn]* ) exit 1;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
echo "" | |
echo "Checking git flow initialized ..." | |
until grep -q -E -i '^\[gitflow "branch"\]$' .git/config && \ | |
grep -q -E -i 'master = (main|master)$' .git/config && \ | |
grep -q -E -i 'develop = develop$' .git/config && \ | |
grep -q -E -i '^\[gitflow "prefix"\]$' .git/config && \ | |
grep -q -E -i 'feature = feature/$' .git/config && \ | |
grep -q -E -i 'release = release/$' .git/config && \ | |
grep -q -E -i 'hotfix = hotfix/$' .git/config && \ | |
grep -q -E -i 'support = support/$' .git/config && \ | |
grep -q -E -i 'versiontag = $' .git/config | |
do | |
read -p "Git flow not initialized. Initialize? [y/n]" yn | |
case $yn in | |
[Yy]* ) git flow init;; | |
[Nn]* ) exit 1;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
echo "Git flow initialized" | |
# source: https://stackoverflow.com/a/28619760 | |
echo "" | |
while true; do | |
read -p "Remove old build files and other cruft in '$PWD'? [y/n]" yn | |
case $yn in | |
[Yy]* ) | |
rm -rf \ | |
"$(basename "$PWD" | tr - _).egg-info" \ | |
.coverage \ | |
.tox \ | |
_version.py \ | |
build \ | |
dist \ | |
db.sqlite3 \ | |
htmlcov | |
break | |
;; | |
[Nn]* ) exit 1;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment