forked from phayes/go-scrutinize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-golang
41 lines (33 loc) · 1.27 KB
/
install-golang
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
#!/bin/bash
# This script installs go on Scrutinizer for github repositories
# To use:
# source <(curl -fsSL https://raw.githubusercontent.com/phayes/go-scrutinize/master/install-golang)
export PROJECT=$(echo $SCRUTINIZER_PROJECT | sed 's/^g/github.com/' | sed 's/^b/bitbucket.org/')
export DOMAIN=$(echo $PROJECT | cut -d'/' -f1)
export OWNER=$(echo $PROJECT | cut -d'/' -f2)
export PACKAGE=$(echo $PROJECT | cut -d'/' -f3)
# Install go
wget https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz
tar -xf go1.9.1.linux-amd64.tar.gz
sudo mv go /usr/local
# Install bzr
sudo apt-get -y update
sudo apt-get -y install bzr
# Set-up gopath and goroot
export GOROOT=/usr/local/go
mkdir ~/go
export GOPATH=$HOME/go
mkdir -p $GOPATH/src/$DOMAIN/$OWNER
ln -s ~/build $GOPATH/src/$DOMAIN/$OWNER/$PACKAGE
export PROJECTPATH=$GOPATH/src/$PROJECT
# Add bin directories to PATH
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
# Install coverage tools
go get github.com/phayes/go-scrutinize
# Set-up github for private go dependancies
# bitbucket should already work
if [[ $DOMAIN == "github.com" && $GITHUB_ACCESS_TOKEN != "" ]]
then
git config --global --unset url."ssh://git@github.com/".insteadOf
git config --global url.https://$GITHUB_ACCESS_TOKEN@github.com/.insteadOf "https://github.com/";
fi