-
Notifications
You must be signed in to change notification settings - Fork 0
/
projctl
executable file
·74 lines (64 loc) · 1.15 KB
/
projctl
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
#!/usr/bin/env bash
set -xeuo pipefail
INPUT=${1:-empty}
function prep(){ ## clears output directory if it exists
if [ -d output ]; then
rm -r output
fi
}
function version(){ ## Add the Jenkins $BUILD_NUMBER to the version
sed -i "/Version/ s/\$/.${BUILD_NUMBER}/" DESCRIPTION
}
function data(){ ## Create the data
cd data-raw && make
}
function build(){ ## Build the package
R -e 'devtools::build(path = "/tmp/")'
}
function archive(){ ## Move the package to the output directory
[ -d output ] || mkdir output
mv /tmp/memorids_*.tar.gz ./output/
}
function usage(){ ## prints the usage
echo "Usage: $(basename "$0") <prep|version|data|build|archive|all|help>"
echo
awk 'BEGIN {FS = "\\(\\){ ## "} /^[f].*?## / {printf " \033[36m%-17s\033[0m %s\n", $1, $2}' projctl | sed 's/function//g'
echo
exit 1
}
case $INPUT in
prep)
prep
exit 0
;;
version)
version
exit 0
;;
data)
data
exit 0
;;
build)
build
exit 0
;;
archive)
archive
exit 0
;;
all)
prep
version
data
build
archive
exit 0
;;
help)
usage
;;
empty)
usage
;;
esac