-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease.sh
executable file
·98 lines (73 loc) · 1.66 KB
/
release.sh
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
#!/bin/bash
set -eu
ver="$1"
user="$2"
# TODO get from keyring
pass="$3"
ret=0
log () {
echo "# "$@
}
projectName=`ls *.cabal | sed s/.cabal//`
if [ -e "$projectName.cabal" ]; then
log "Project Name: $projectName"
else
log "*.cabal file not found, refusing release"
exit 1
fi
if [ -z "$ver" ]; then
log "Version not given, refusing release"
exit 1
fi
if [ -z "$user" ]; then
log "Username not given, refusing release"
exit 1
fi
if [ -z "$pass" ]; then
log "Password not given, refusing release"
exit 1
fi
# getExitCode () {
# "$@"
# echo "$?"
# }
git diff --exit-code >/dev/null || ret=$?
if [ "$ret" -ne 0 ]; then
git status --short
log "There are uncommitted changes, refusing release"
exit 2
else
log "No uncommitted changes. Wonderful. Continuing."
fi
git diff --cached --exit-code >/dev/null || ret=$?
if [ "$ret" -ne 0 ]; then
git status --short
log "There are uncommitted staged changes, refusing release"
exit 3
else
log "No uncommitted staged changes either. Wonderful. Continuing."
fi
rx="(version:\s+)([0-9\w.-]+)"
oldver=`cat "$projectName.cabal" | grep "^version:" | sed -re "s/$rx/\2/"`
log "\$oldver: $oldver"
cabal configure
cabal install --enable-test
cabal test
msg="Bumping version v$oldver -> v$ver"
if [ "$ver" != "$oldver" ]; then
sed -r -i -e "s/$rx/\1$ver/" "$projectName.cabal"
log "$msg"
fi
cabal sdist
cabal upload "dist/$projectName-$ver.tar.gz" --username "$user" --password "$pass"
neil docs --username "$user:$pass"
if [ "$ver" != "$oldver" ]; then
git add -u
git commit -m "$msg"
log "Committed: $msg"
fi
git push
if [ ! `git tag -l "v$ver"` ]; then
git tag "v$ver" HEAD
fi
git push --tags