diff --git a/bin/console b/bin/console new file mode 100755 index 0000000..436af24 --- /dev/null +++ b/bin/console @@ -0,0 +1,2 @@ +#!/bin/sh +irb -I ./lib -r 'bundler' -r 'rubygems' -r 'db_lock' diff --git a/bin/release b/bin/release new file mode 100755 index 0000000..3c48dcf --- /dev/null +++ b/bin/release @@ -0,0 +1,31 @@ +#!/bin/bash -le + +name="db_lock" + +git fetch origin +current=`bin/version` +sha=`git rev-parse HEAD` + +read -p "Which version? (${current}) " version +version=${version:=$current} + +VERSION=$version gem build ${name}.gemspec + +echo "Creating GitHub release" +link=`gh release create v${version} --target $sha --generate-notes` +echo $link + +file="${name}-${version}.gem" +read -p "Push to rubygems? (y/n) " yn +case $yn in + y ) echo Pushing to rubygems ...;; + n ) echo Aborting.; + exit;; + * ) echo invalid response; + exit 1;; +esac + +gem push $file +rm $file + +open $link diff --git a/bin/version b/bin/version new file mode 100755 index 0000000..6855835 --- /dev/null +++ b/bin/version @@ -0,0 +1,16 @@ +#!/bin/bash -le + +branch=`git rev-parse --abbrev-ref HEAD` +version=`git describe --tags --match "v*" | sed -e "s/^v//"` +ref=`git rev-parse --short HEAD` + +# 0.0.0-i-sha or 0.0-i-sha +if [[ "$version" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-([a-z0-9]+) ]]; then + minor=$((${BASH_REMATCH[3]}+1)) + version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${minor}.${branch}.${BASH_REMATCH[4]}.$ref" +elif [[ "$version" =~ ^([0-9]+)\.([0-9]+)-([0-9]+)-([a-z0-9]+) ]]; then + minor=1 + version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${minor}.${branch}.${BASH_REMATCH[3]}.$ref" +fi + +echo $version