Skip to content

Instantly share code, notes, and snippets.

@JonathanWillitts
Last active February 1, 2024 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonathanWillitts/3e7e2f107d32836222d38a80a025a1a7 to your computer and use it in GitHub Desktop.
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
#!/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
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