2015-06-05 14:14:26 +02:00
|
|
|
#!/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
|
|
|
|
|
2015-06-05 15:08:52 +02:00
|
|
|
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
|
|
|
. "$DIR"/lib/common.sh
|
2015-06-05 14:14:26 +02:00
|
|
|
|
|
|
|
usage () {
|
|
|
|
echo " upload.sh <USER> <PASSWORD>"
|
|
|
|
echo " Uploads all servant packages to Hackage"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
upload_package () {
|
2015-06-09 12:51:39 +02:00
|
|
|
local package="$1"
|
|
|
|
local user="$2"
|
|
|
|
local pass="$3"
|
|
|
|
local cabalFile="$package.cabal"
|
2015-06-05 14:14:26 +02:00
|
|
|
pushd "$package"
|
|
|
|
local version=$(grep -i '^version:' $cabalFile | awk '{ print $2 }')
|
2015-06-09 12:51:39 +02:00
|
|
|
local sdist="dist/${package}-${version}.tar.gz"
|
2015-06-05 14:14:26 +02:00
|
|
|
cabal sdist
|
2015-06-09 12:51:39 +02:00
|
|
|
echo "User is: $user"
|
|
|
|
cabal upload --user="$user" --password="$pass" "$sdist"
|
2015-06-05 14:14:26 +02:00
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if [ $# -ne 2 ] ; then
|
|
|
|
echo "expecting two arguments."
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
versions_equal
|
|
|
|
|
|
|
|
for s in ${SOURCES[@]} ; do
|
2015-06-09 12:51:39 +02:00
|
|
|
upload_package "$s" "$1" "$2"
|
2015-06-05 14:14:26 +02:00
|
|
|
done
|