Skip to content

Instantly share code, notes, and snippets.

@jessb321
Created April 26, 2018 03:42
Show Gist options
  • Save jessb321/e2bbc76c5d21524069c78543ea0a2d89 to your computer and use it in GitHub Desktop.
Save jessb321/e2bbc76c5d21524069c78543ea0a2d89 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo -e "\nPlease call '$0 -m[inor] || -M[ajor] || -p[atch]' to run this command!\n"
exit 1
fi
if [ "$1" -eq "-p" ]; then
semver="patch"
fi
if [ "$1" -eq "-m" ]; then
semver="minor"
fi
if [ "$1" -eq "-M" ]; then
semver="major"
fi
version=$(niet ./coriolis/package.json version)
incversion=$(./increment_version.sh $1 ${version})
echo "$version => $incversion"
cd coriolis
git flow release start --showcommands $incversion
npm version "$semver"
git flow release finish --showcommands --nopush -n -m "${incversion}" ${incversion}
cd ../coriolis-data/
git flow release start --showcommands $incversion
npm version "$semver"
git flow release finish --showcommands --nopush -n -m "${incversion}" ${incversion}
#!/bin/bash
# Increment a version string using Semantic Versioning (SemVer) terminology.
# Parse command line options.
while getopts ":Mmp" Option
do
case $Option in
M ) major=true;;
m ) minor=true;;
p ) patch=true;;
esac
done
shift $(($OPTIND - 1))
version=$1
# Build array from version string.
a=( ${version//./ } )
# If version string is missing or has the wrong number of members, show usage message.
if [ ${#a[@]} -ne 3 ]
then
echo "usage: $(basename $0) [-Mmp] major.minor.patch"
exit 1
fi
# Increment version numbers as requested.
if [ ! -z $major ]
then
((a[0]++))
a[1]=0
a[2]=0
fi
if [ ! -z $minor ]
then
((a[1]++))
a[2]=0
fi
if [ ! -z $patch ]
then
((a[2]++))
fi
echo "${a[0]}.${a[1]}.${a[2]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment