Upload script and some script refactoring
This commit is contained in:
parent
664691e1ba
commit
aec39b546e
7 changed files with 92 additions and 44 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -1,8 +1,8 @@
|
|||
dist
|
||||
bin
|
||||
lib
|
||||
share
|
||||
packages
|
||||
/dist
|
||||
/bin
|
||||
/lib
|
||||
/share
|
||||
/packages
|
||||
*-packages.conf.d
|
||||
cabal-dev
|
||||
add-source-timestamps
|
||||
|
|
|
@ -16,33 +16,16 @@
|
|||
set -o nounset
|
||||
set -o errexit
|
||||
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
DRY_RUN=false
|
||||
POSITION="none"
|
||||
SOURCES_TXT="$( dirname $DIR)/sources.txt"
|
||||
|
||||
declare -a SOURCES
|
||||
readarray -t SOURCES < "$SOURCES_TXT"
|
||||
. lib/common.sh
|
||||
|
||||
usage () {
|
||||
echo " bump-versions <POSITION> [-d|--dry-run]"
|
||||
echo " bump-versions.sh <POSITION> [-d|--dry-run]"
|
||||
echo " | [-h|--help]"
|
||||
echo " Bumps the specified positional version of all servant packages."
|
||||
echo " POSITION is a number between 0 and 3, inclusive."
|
||||
exit 0
|
||||
}
|
||||
|
||||
join () { local IFS="$1"; shift; echo "$*"; }
|
||||
|
||||
versions_equal () {
|
||||
local NUM=$(find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l)
|
||||
if [ 1 -eq $NUM ] ; then
|
||||
return 0
|
||||
else
|
||||
echo "versions of packages are not all the same!" && exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ] ; then
|
||||
echo "expecting one or more arguments. Got 0"
|
||||
usage
|
||||
|
|
31
scripts/lib/common.sh
Normal file
31
scripts/lib/common.sh
Normal file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash -
|
||||
#===============================================================================
|
||||
#
|
||||
# FILE: lib/common.sh
|
||||
#
|
||||
# DESCRIPTION: Common functions for servant's shell scripts
|
||||
# Meant to be sourced rather than run.
|
||||
#
|
||||
# REQUIREMENTS: bash >= 4
|
||||
#===============================================================================
|
||||
|
||||
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
DRY_RUN=false
|
||||
POSITION="none"
|
||||
SOURCES_TXT="$( dirname $DIR)/sources.txt"
|
||||
CABAL=${CABAL:-cabal}
|
||||
|
||||
declare -a SOURCES
|
||||
readarray -t SOURCES < "$SOURCES_TXT"
|
||||
|
||||
join () { local IFS="$1"; shift; echo "$*"; }
|
||||
|
||||
versions_equal () {
|
||||
local NUM=$(find . -name 'servant*.cabal' | xargs grep "^version:" | awk '{ print $2 }' | uniq -c | wc -l)
|
||||
if [ 1 -eq $NUM ] ; then
|
||||
return 0
|
||||
else
|
||||
echo "versions of packages are not all the same!" && exit 1
|
||||
fi
|
||||
}
|
|
@ -13,12 +13,7 @@
|
|||
set -o nounset
|
||||
set -o errexit
|
||||
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
SOURCES_TXT="$( dirname $DIR)/sources.txt"
|
||||
CABAL=${CABAL:-cabal}
|
||||
|
||||
declare -a SOURCES
|
||||
readarray -t SOURCES < "$SOURCES_TXT"
|
||||
. lib/common.sh
|
||||
|
||||
prepare_sandbox () {
|
||||
$CABAL sandbox init
|
||||
|
|
|
@ -14,14 +14,7 @@
|
|||
set -o nounset
|
||||
set -o errexit
|
||||
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
GHC_FLAGS="-Werror"
|
||||
SOURCES_TXT="$( dirname $DIR)/sources.txt"
|
||||
CABAL=${CABAL:-cabal}
|
||||
|
||||
declare -a SOURCES
|
||||
readarray -t SOURCES < "$SOURCES_TXT"
|
||||
|
||||
. lib/common.sh
|
||||
|
||||
prepare_sandbox () {
|
||||
$CABAL sandbox init
|
||||
|
|
|
@ -11,12 +11,7 @@
|
|||
set -o nounset
|
||||
set -o errexit
|
||||
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
BASE_DIR="$( dirname $DIR)"
|
||||
SOURCES_TXT="$BASE_DIR/sources.txt"
|
||||
|
||||
declare -a SOURCES
|
||||
readarray -t SOURCES < "$SOURCES_TXT"
|
||||
. lib/common.sh
|
||||
|
||||
for s in ${SOURCES[@]} ; do
|
||||
echo $s
|
||||
|
|
51
scripts/upload.sh
Executable file
51
scripts/upload.sh
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash -
|
||||
#===============================================================================
|
||||
#
|
||||
# FILE: upload.sh
|
||||
#
|
||||
# USAGE: ./upload.sh <USER> <PASSWORD>
|
||||
#
|
||||
# DESCRIPTION: Uploads all servant packages to Hackage
|
||||
#
|
||||
# REQUIREMENTS: cabal, bash >= 4
|
||||
# AUTHOR: Julian K. Arni
|
||||
# CREATED: 05.06.2015 13:05
|
||||
#===============================================================================
|
||||
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
|
||||
. lib/common.sh
|
||||
|
||||
usage () {
|
||||
echo " upload.sh <USER> <PASSWORD>"
|
||||
echo " Uploads all servant packages to Hackage"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
upload_package () {
|
||||
local package="$0"
|
||||
local cabalFile="$0.cabal"
|
||||
pushd "$package"
|
||||
local version=$(grep -i '^version:' $cabalFile | awk '{ print $2 }')
|
||||
local sdist="${package}-${version}.tar.gz"
|
||||
cabal sdist
|
||||
cabal upload --user="$USER" --password="$PASS" "$sdist"
|
||||
popd
|
||||
}
|
||||
|
||||
|
||||
if [ $# -ne 2 ] ; then
|
||||
echo "expecting two arguments."
|
||||
usage
|
||||
else
|
||||
USER="$0"
|
||||
PASS="$1"
|
||||
fi
|
||||
|
||||
versions_equal
|
||||
|
||||
for s in ${SOURCES[@]} ; do
|
||||
upload_package "$s"
|
||||
done
|
Loading…
Reference in a new issue