-
Notifications
You must be signed in to change notification settings - Fork 9
/
install.sh
43 lines (32 loc) · 1000 Bytes
/
install.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
#!/usr/bin/env bash
# base directory in which we will extract the files
base="src/github.com/LUSHDigital/modelgen"
# get the latest tarball url from github's api
url=$(curl -s https://api.github.com/repos/LUSHDigital/modelgen/releases/latest \
| grep "tarball_url" \
| cut -d : -f 2,3 \
| tr -d \"\,\ )
# get the tagged version
version=$(curl -s https://api.github.com/repos/LUSHDigital/modelgen/releases/latest \
| grep "tag_name" \
| cut -d : -f 2,3 \
| tr -d \"\,\ )
# download the tarball
curl -s -L ${url} --output release.tar.gz
# set the gopath
export GOPATH=$(pwd)
export PATH="$GOPATH/bin:$PATH"
# create the base folder
mkdir -p ${base}
# extract everything into it
tar -xvzf release.tar.gz -C ${base} --strip-components=1
# move into it
cd ${base}
# build
go build -ldflags "-X main.version=$version" -o /usr/local/bin/modelgen
go build -ldflags "-X main.version=$version" -o /usr/local/bin/modelgen
# move back to the root
cd -
# cleanup the files
rm release.tar.gz
rm -rf src