-
Notifications
You must be signed in to change notification settings - Fork 9
/
go
executable file
·158 lines (123 loc) · 3.53 KB
/
go
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly SCRIPT_DIR
goal_install() {
npm i
npm run build
./lein deps
}
goal_prettier() {
npm run prettier
}
goal_lint() {
find "$SCRIPT_DIR" -name "*.sh" -not -path "${SCRIPT_DIR}/node_modules/*" -exec shellcheck {} +
shellcheck "$SCRIPT_DIR"/go
npm run lint
}
goal_test_unit() {
# shellcheck disable=SC1010
"${SCRIPT_DIR}/lein" do clean, test
}
goal_test_integration() {
echo
echo "Testing integration with build-facts"
"${SCRIPT_DIR}/test/integration/test_build_facts.sh"
}
goal_test_example() {
echo
echo "Running simple example to make sure it doesn't break"
yes | "${SCRIPT_DIR}/examples/runSeedDataExample.sh"
}
goal_audit() {
npm audit --production
"${SCRIPT_DIR}/lein" nvd check
}
goal_test() {
goal_lint
goal_test_unit
goal_test_integration
goal_test_example
goal_audit
}
goal_make_release() {
local NEW_VERSION=$1
local OLD_VERSION
if [ -z "$NEW_VERSION" ]; then
echo "Provide a new version number"
exit 1
fi
(
cd "$SCRIPT_DIR"
OLD_VERSION=$(git tag --sort=-version:refname | head -1)
sed -i "" "s/$OLD_VERSION/$NEW_VERSION/g" README.md
sed -i "" "s/buildviz \"$OLD_VERSION\"/buildviz \"$NEW_VERSION\"/" project.clj
git add README.md project.clj
git commit -m "Bump version"
./lein clean
./lein ring uberjar
git show
git tag "$NEW_VERSION"
echo
echo "You now want to"
echo "$ git push origin master --tags"
echo "and upload the jar, and finally"
echo "$ ./go publish_docker ${NEW_VERSION}"
)
}
goal_bump_build_facts() {
local NEW_VERSION=$1
if [ -z "$NEW_VERSION" ]; then
echo "Provide a new version number"
exit 1
fi
(
cd "$SCRIPT_DIR"
sed -i "" "s/build_facts_version=\"\(.*\)\"/build_facts_version=\"$NEW_VERSION\"/g" test/integration/test_build_facts.sh
sed -i "" "s|/\([^/]*\)/build-facts-\1-standalone.jar|/$NEW_VERSION/build-facts-$NEW_VERSION-standalone.jar|" README.md
sed -i "" "s|build-facts-\(.*\)-standalone.jar|build-facts-$NEW_VERSION-standalone.jar|" README.md examples/README.md
git add test/integration/test_build_facts.sh README
git commit -m "Bump build-facts version"
./test/integration/test_build_facts.sh
git show
git status
)
}
fetch_buildviz_jar() {
local version="$1"
(
cd src/docker
rm -f buildviz-*-standalone.jar
curl -LO "https://github.com/cburgmer/buildviz/releases/download/${version}/buildviz-${version}-standalone.jar"
)
}
goal_publish_docker() {
local latest_version="$1"
local image_name="cburgmer/buildviz"
if [[ -z "$latest_version" ]]; then
echo "Please provide a version number"
exit 1
fi
echo "Logged into docker registry?"
read -rn 1
fetch_buildviz_jar "$latest_version"
docker build src/docker --tag "${image_name}:${latest_version}" --tag "${image_name}:latest"
docker push "${image_name}:${latest_version}"
docker push "${image_name}:latest"
}
goal_help() {
local GOALS
GOALS=$(set | grep -e "^goal_" | sed "s/^goal_\(.*\)().*/\1/" | xargs | sed "s/ / | /g")
echo "Usage: $0 [ ${GOALS} ]"
}
main() {
local GOAL
if [[ -z "$1" ]] || ! type -t "goal_$1" &>/dev/null; then
goal_help
exit 1
fi
GOAL="$1"
shift
"goal_${GOAL}" "$@"
}
main "$@"