-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathrelease
executable file
·104 lines (76 loc) · 2.52 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
#
if [ "$(git branch | grep '* ')" != "* master" ]; then
echo "You are not on the master branch!"
exit 1
fi
echo "Have you updated the version number? Type 'yes' if you have!"
read version_response
if [ "$version_response" != "yes" ]; then
echo "Go and update the version number"
exit 1
fi
# Not 'example' as well because we don't really want to upload a simple example package to Hackage.
declare -a subdirectories=(core hunit quickcheck quickcheck2)
declare -a filenames
index=0
while [ "$index" -lt "${#subdirectories[@]}" ]; do
# Find out the working subdirectory and enter it
subdirectory=${subdirectories[index]}
cd $subdirectory
# For those directories that use CPP, we need to configure before sdist will work without a warning
runghc Setup.lhs configure --user
# OK, build the tarball
sdist_output=`runghc Setup.lhs sdist`
if [ "$?" != "0" ]; then
echo "Cabal sdist failed, aborting"
exit 1
fi
# Want to find a line like:
# Source tarball created: dist/ansi-terminal-0.1.tar.gz
# Test this with:
# runghc Setup.lhs sdist | grep ...
filename=`echo $sdist_output | sed 's/.*Source tarball created: \([^ ]*\).*/\1/'`
filenames[$index]="$subdirectory/$filename"
echo "Filename: $filename"
if [ "$filename" = "$sdist_output" ]; then
echo "Could not find filename, aborting"
exit 1
fi
if [ "$subdirectory" = "core" ]; then
# Test this with:
# echo dist/ansi-terminal-0.1.tar.gz | sed ...
version=`echo $filename | sed 's/^[^0-9]*\([0-9\.]*\).tar.gz$/\1/'`
echo "Version: $version"
if [ "$version" = "$filename" ]; then
echo "Could not find version, aborting"
exit 1
fi
fi
# Move to the next directory
cd ..
let "index = $index + 1"
done
echo "This is your last chance to abort! I'm going to upload v$version in 10 seconds"
sleep 10
if [ -n "$version" ]; then
git tag "v$version"
if [ "$?" != "0" ]; then
echo "Git tag failed, aborting"
exit 1
fi
fi
index=0
while [ "$index" -lt "${#filenames[@]}" ]; do
# You need to have stored your Hackage username and password as directed by cabal-upload
# I use -v5 because otherwise the error messages can be cryptic :-)
filename=${filenames[index]}
cabal upload -v3 $filename
if [ "$?" != "0" ]; then
echo "Hackage upload of $filename failed, aborting"
exit 1
fi
let "index = $index + 1"
done
# Success!
exit 0