publish-new-tag

#!/usr/bin/env bash
##
# Checkout a new local build branch, build the phar, add it to the bin dir & commit, and create a remote versioned tag (*version name comes from `get-new-version`*). Then switches back to the previous branch & deletes the local build branch
#

# read -p "Be sure all changes are stashed or committed before building [enter] tocontinue, [ctrl+c] to exit."

cur_branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch --tags
full_version="$(bin/get-new-version)"

echo $full_version
exit

new_branch="build-$full_version"
git branch --delete --force $new_branch
git checkout -B $new_branch

rm -rf .cache/
mkdir .cache

if [[ -d "vendor" ]];then

    read -p "Remove & Re-install vendor/ w/ --no-dev? (y/n)" answer
    if [[ "$answer" == "y" || "$answer" == "Y" ]];then
        rm -rf vendor/
        composer install --no-dev
    fi
fi



bin/build-phar

mv build/scrawl.phar bin/scrawl.phar
if [[ ! -f bin/scrawl.phar ]];then
    echo "Failed to create bin/scrawl.phar"
    exit 2;
fi

git add bin/scrawl.phar
git commit -m "build scrawl.phar & git tag it"
git tag -a "$full_version"
git push origin "$full_version"

git checkout "$cur_branch"
git branch --delete --force "$new_branch"

# An increase in each section of the version means the following:
# (Idk if this is true, just an idea, probably not the best place to leave this note. but here it is)
# BackwardCompatibilityBreaks.FeatureAdded.BugFixed.OtherChange
# BackwCompat.Feature.Bug.Other
# Except 0.X.X is 0.BackwardCompatibilityBreaks.AnyCommit