Page MenuHomePhorge

No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/bin/increment-version b/bin/increment-version
index 4cfdc47..169ffae 100755
--- a/bin/increment-version
+++ b/bin/increment-version
@@ -1,89 +1,95 @@
#!/bin/bash
# Based on https://github.com/fmahnke/shell-semver
# The MIT License (MIT)
# Copyright (c) 2014 Fritz Mahnke
# Increment a version string using Semantic Versioning (SemVer) terminology.
# Parse command line options.
-while getopts ":Mmp" Option
+while getopts ":Mmpa:" Option
do
- case $Option in
- M ) major=true;;
- m ) minor=true;;
- p ) patch=true;;
- esac
+ case $Option in
+ M ) major=true;;
+ m ) minor=true;;
+ p ) patch=true;;
+ a ) alpha=${OPTARG};;
+ esac
done
shift $(($OPTIND - 1))
STAGED_COUNT=$(git diff --cached --numstat | wc -l)
UNSTAGED_COUNT=$(git diff --numstat | wc -l)
## TODO check we are on master
if [ $STAGED_COUNT -ne "0" ]; then
echo "you have staged changes. Aborting".
exit 1
fi
if [ $UNSTAGED_COUNT -ne "0" ]; then
echo "you have unstaged changes. Aborting".
exit 1
fi
version="$(mix run --no-compile --no-start -e ":io.format('~s', [PrometheusEx.Mixfile.project()[:version]])")"
echo "Old version: ${version}"
# Build array from version string.
oa=( ${version//./ } )
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] TAG_MESSAGE(optional)"
- exit 1
+ echo "usage: $(basename $0) [-Mmp] TAG_MESSAGE(optional)"
+ exit 1
fi
# Increment version numbers as requested.
if [ ! -z $major ]
then
- ((a[0]++))
- a[1]=0
- a[2]=0
+ ((a[0]++))
+ a[1]=0
+ a[2]=0
fi
if [ ! -z $minor ]
then
- ((a[1]++))
- a[2]=0
+ ((a[1]++))
+ a[2]=0
fi
if [ ! -z $patch ]
then
- ((a[2]++))
+ ((a[2]++))
fi
-new_version="${a[0]}.${a[1]}.${a[2]}"
+if [ -z ${alpha+x} ];
+then
+ new_version="${a[0]}.${a[1]}.${a[2]}";
+else
+ new_version="${a[0]}.${a[1]}.${a[2]}.alpha-$alpha";
+fi
echo "New version: ${new_version}"
sed -i s/\"${oa[0]}\.${oa[1]}\.${oa[2]}\"/\"${a[0]}\.${a[1]}\.${a[2]}\"/g mix.exs
sed -i s/\~\>\ ${oa[0]}\.${oa[1]}/\~\>\ ${a[0]}\.${a[1]}/g README.md
git add mix.exs
git add README.md
git add doc
git commit -m "Bump to v${new_version}"
TAG_MESSAGE=${1:-"New version: v${new_version}"}
git tag -a "v${new_version}" -m "${TAG_MESSAGE}"
git push origin master
git push origin "v${new_version}"
mix hex.publish

File Metadata

Mime Type
text/x-diff
Expires
Thu, Nov 28, 3:19 AM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40808
Default Alt Text
(2 KB)

Event Timeline