-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bash
executable file
·78 lines (68 loc) · 1.33 KB
/
build.bash
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
#!/bin/bash -Eu
declare -a projects=(fragag-commons fragag-test-helpers reasm-core reasm-commons reasm-m68k reasm-z80 reasm-batch)
install() {
echo "Installing $1" &&
cd "./$1" && # './' bypasses CDPATH
git reset --hard &&
git clean -dfx &&
mvn clean install &&
cd .. &&
echo
}
build() {
if [[ $# -gt 0 ]]
then
install "$1" &&
shift &&
build "$@"
fi
}
package_dist() {
echo "Packaging reasm distribution" &&
rm -rf dist &&
mkdir dist &&
cp reasm-batch/target/reasm-batch-*.jar dist/reasm.jar &&
cp $(git ls-files src) dist/ &&
cd ./dist &&
tar --create --file=reasm.tar.xz --xz * &&
cd .. &&
echo
}
publish_sources() {
if [[ $# -gt 0 ]]
then
echo "Pushing $1" &&
cd "./$1" &&
git push origin master &&
cd .. &&
echo &&
shift &&
publish_sources "$@"
fi
}
publish_self() {
echo "Pushing reasm-dist" &&
git push &&
echo
}
upload_dist() {
echo "Uploading reasm distribution" &&
scp dist/reasm.tar.xz fragag.ca:files/public/reasm.tar.xz &&
echo
}
run() {
# Abort if repository is not clean
if git diff HEAD --quiet
then
build ${projects[@]} &&
package_dist &&
publish_sources ${projects[@]} &&
publish_self &&
upload_dist
else
echo "reasm-dist's working directory and index are not clean"
false
fi
}
set -o pipefail
run