forked from open-policy-agent/opa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-release.sh
executable file
·68 lines (59 loc) · 1.3 KB
/
build-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
#!/usr/bin/env bash
# Script to build OPA releases. Assumes execution environment is golang Docker container.
set -e
OPA_DIR=/go/src/github.com/open-policy-agent/opa
BUILD_DIR=$OPA_DIR/build
usage() {
echo "build-release.sh --output-dir=<path>"
echo " --source-url=<git-url>"
echo " [--version=<mj.mn.pt>]"
}
for i in "$@"; do
case $i in
--source-url=*)
SOURCE_URL="${i#*=}"
shift
;;
--output-dir=*)
OUTPUT_DIR="${i#*=}"
shift
;;
--version=*)
VERSION="${i#*=}"
shift
;;
*)
usage
exit 1
;;
esac
done
if [ -z "$OUTPUT_DIR" ]; then
usage
exit 1
elif [ -z "$SOURCE_URL" ]; then
usage
exit 1
fi
build_binaries() {
make deps
GOOS=darwin GOARCH=amd64 make build
GOOS=linux GOARCH=amd64 make build
GOOS=windows GOARCH=amd64 make build
mv opa_windows_amd64 opa_windows_amd64.exe
mv opa_*_* $OUTPUT_DIR
}
clone_repo() {
git clone $SOURCE_URL /go/src/github.com/open-policy-agent/opa
cd /go/src/github.com/open-policy-agent/opa
if [ -n "$VERSION" ]; then
git checkout v${VERSION}
fi
}
main() {
clone_repo
build_binaries
$BUILD_DIR/build-docs.sh --output-dir=$OUTPUT_DIR
make test
}
main