Browse Source

Upload script and some script refactoring

tags/v0.4.3
Julian K. Arni 7 years ago
parent
commit
0c52b23168
  1. 10
      .gitignore
  2. 21
      scripts/bump-versions.sh
  3. 31
      scripts/lib/common.sh
  4. 7
      scripts/start-sandbox.sh
  5. 9
      scripts/test-all.sh
  6. 7
      scripts/update-defaults-nix.sh
  7. 51
      scripts/upload.sh

10
.gitignore

@ -1,8 +1,8 @@
dist
bin
lib
share
packages
/dist
/bin
/lib
/share
/packages
*-packages.conf.d
cabal-dev
add-source-timestamps

21
scripts/bump-versions.sh

@ -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

@ -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
}

7
scripts/start-sandbox.sh

@ -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

9
scripts/test-all.sh

@ -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

7
scripts/update-defaults-nix.sh

@ -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

@ -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…
Cancel
Save