git.iko.soy/typeable/servant
on 3bcbe80 help sign in
typeable/servant/scripts/bump-versions.sh
78 lines 2.1 kB history raw
1#!/bin/bash -
2#===============================================================================
3#
4# FILE: bump-versions.sh
5#
6# USAGE: ./bump-versions.sh
7#
8# DESCRIPTION: Bump the versions for all servant packages
9#
10# OPTIONS: See usage
11# REQUIREMENTS: bumper, bash >= 4
12# CREATED: 11.05.2015 21:36
13# REVISION: ---
14#===============================================================================
16set -o nounset
17set -o errexit
19DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
20DRY_RUN=false
21POSITION="none"
22SOURCES_TXT="$( dirname $DIR)/sources.txt"
24declare -a SOURCES
25readarray -t SOURCES < "$SOURCES_TXT"
27usage () {
28 echo " bump-versions <POSITION> [-d|--dry-run]"
29 echo " | [-h|--help]"
30 echo " Bumps the specified positional version of all servant packages."
31 echo " POSITION is a number between 0 and 3, inclusive."
32 exit 0
35join () { local IFS="$1"; shift; echo "$*"; }
37versions_equal () {
38 local NUM=$(find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l)
39 if [ 1 -eq $NUM ] ; then
40 return 0
41 else
42 echo "versions of packages are not all the same!" && exit 1
43 fi
46if [ $# -eq 0 ] ; then
47 echo "expecting one or more arguments. Got 0"
48 usage
49elif [ $# -gt 2 ] ; then
50 echo "expecting one or more arguments"
51 usage
52fi
54versions_equal
56while [ "${1:-unset}" != "unset" ] ; do
57 case "$1" in
58 -h | --help) usage ;;
59 -d | --dry-run) DRY_RUN=true
60 shift ;;
61 0) if POSITION="none" ; then POSITION=0 ; else usage ; fi
62 shift ;;
63 1) if POSITION="none" ; then POSITION=1 ; else usage ; fi
64 shift ;;
65 2) if POSITION="none" ; then POSITION=2 ; else usage ; fi
66 shift ;;
67 3) if POSITION="none" ; then POSITION=3 ; else usage ; fi
68 shift ;;
69 *) usage ;;
70 esac
71done
73if $DRY_RUN ; then
74 bumper --dry-run -"$POSITION" $(join , "${SOURCES[@]}")
75else
76 bumper -"$POSITION" $(join , "${SOURCES[@]}")
77fi