forked from typeable/schematic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release
executable file
·43 lines (33 loc) · 1.47 KB
/
release
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
set -o xtrace
dist=`stack path --dist-dir --stack-yaml ./stack.yaml 2> /dev/null`
rootdir=`pwd`
cabalfile=`ls *.cabal`
packagename="${cabalfile%%.*}"
version=`grep '^version:' schematic.cabal | rev | cut -d" " -f1 | rev`
echo -e "\033[1;36mTesting library...\033[0m"
stack test 2> /dev/null
echo -e "\033[1;36mRunning sdist...\033[0m"
cabal sdist
echo -e "\033[1;36mGenerating documentation...\033[0m"
stack haddock 2> /dev/null
if [ "$?" -eq "0" ]; then
echo -e "\033[1;32mUploading package to Hackage...\033[0m"
read -p "Hackage username: " username
read -p "Hackage password: " -s password
echo ""
cabal upload -u $username -p $password dist/$packagename-$version.tar.gz
docdir=`find .stack-work -name "$packagename-$version-docs"`
echo -e "Compressing documentation from \033[1;34m$docdir\033[0m for \033[1;35m$packagename\033[0m-\033[1;33m$version\033[1;30m"
tar -c -v -z --format=ustar -f $docdir.tar.gz $docdir
echo -e "\033[1;32mUploading documentation to Hackage...\033[0m"
cd $docdir
cd ..
curl -X PUT -H 'Content-Type: application/x-tar' -H 'Content-Encoding: gzip' --data-binary "$packagename-$version-docs.tar.gz" "https://$username:[email protected]/package/$packagename-$version/candidate/docs"
open "https://hackage.haskell.org/package/$packagename-$version/candidate/"
cd $rootdir
echo "To publish the candidate, use 'cabal upload --publish'."
exit $?
else
echo -e "\033[1;31mNot in a stack-powered project\033[0m"
fi