diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh new file mode 100644 index 0000000..ef0a455 --- /dev/null +++ b/scripts/bump-version.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# +# Usage: ./scripts/bump-version.sh +# + +PCRE_MATCH_VERSION="[0-9]+\.[0-9]+\.[0-9]+" +PCRE_MATCH_VERSION_BOUNDS="(^|[- v/'\"])${PCRE_MATCH_VERSION}([- /'\"]|$)" +VERSION="$1" + +if ! echo "$VERSION" | grep -Pq "${PCRE_MATCH_VERSION}"; then + echo "Usage: ./scripts/bump-version.sh " + echo " must be a valid 3 digit version number" + echo " Make sure to double check 'git diff' before commiting anything you'll regret on master" + exit 1 +fi + +# Edit text files matching the PCRE, do *not* patch .git folder +grep -PIrl "${PCRE_MATCH_VERSION_BOUNDS}" $(ls) | xargs sed -ir "s/${PCRE_MATCH_VERSION_BOUNDS}/"'\1'"${VERSION}"'\2/g' +