Skip to content

Instantly share code, notes, and snippets.

@infinityplusone
Created December 4, 2019 17:04
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 infinityplusone/91df8c92ebd84244971297f7ceed1683 to your computer and use it in GitHub Desktop.
Save infinityplusone/91df8c92ebd84244971297f7ceed1683 to your computer and use it in GitHub Desktop.
My build script, more or less.
#!/bin/sh
# Formatting variables
blackBG='\033[1;40m'
cyan='\033[1;36m'$blackBG
gray='\033[1;37m'$blackBG
green='\033[1;32m'$blackBG
purple='\033[1;35m'$blackBG
red='\033[0;31m'$blackBG
yellow='\033[1;33m'$blackBG
nc='\033[0m'$blackBG
project=$(pwd | sed -e "s/.*\///g")
branch=$(git rev-parse --abbrev-ref HEAD)
# get everything ready
echo "Getting version number.\n"
grunt build
# figure out the version
version=$(cat VERSION)
# checkout a branch for this version
echo "Checking out ${cyan}latest${nc} branch for ${cyan}v${version}${nc}.\n"
git branch -D latest
git checkout -b latest
# add the distribution file & push it
echo "Adding build file to latest branch and pushing to remote.\n"
git rm -rf {scripts,tasks,cmn}
git rm {.gitignore,.npmignore,Gruntfile.js,package.json,README.md}
git add assets
git rm assets/bundle.js # this often varies
git commit -am "v${version}"
git push origin latest --force
# remove "latest" tag on the remote & create a new local one
echo "Creating new tag for ${cyan}v${version}${nc} and pushing to remote.\n"
git tag -f v${version}
# push up new tags
echo "Pushing tags up to remote.\n"
git push origin --tags
# cleanup
echo "Cleaning up and checking out ${cyan}${branch}${nc}.\n"
rm -rf VERSION
# go back to where you started
git checkout $branch
# run collect
grunt collect
echo "${green}Done!${nc}\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment