-
Notifications
You must be signed in to change notification settings - Fork 5
/
release-dreck
executable file
·81 lines (61 loc) · 1.81 KB
/
release-dreck
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
#!/bin/bash
# This release script downloads the latest Go and dreck, sets things up and then calls
# into the Makefile to do the release.
PROG=$(basename $0)
# GetLatestGO download the latest version of Go (or used a cached download from /tmp).
function latestGo {
TEMP="$1"
LATEST=$(curl -s https://golang.org/VERSION?m=text)
GOLANG=https://dl.google.com/go/${LATEST}.linux-amd64.tar.gz
TAR=$(basename $GOLANG)
( cd $TEMP
if [[ ! -e /tmp/$TAR ]]; then
echo "$PROG: Downloading: $GOLANG"
wget -q $GOLANG
cp $TAR /tmp
else
echo "$PROG: Using cached version of: $GOLANG"
cp /tmp/$TAR .
fi
)
}
# setupGo extract Go and export GOROOT and GOPATH to get a compile confined to the tmp dir.
function setupGo {
TEMP="$1"
echo "$PROG: Setting up Go in $TEMP"
( cd $TEMP
tar xf $TAR
export GOROOT=$PWD/go
PATH=$GOROOT/bin:$PATH
export GOPATH=$PWD/g
)
}
# fromGithub download owner/repo from Github into g/src/github.com/owner/repo.
function fromGithub {
TEMP="$1"
GITHUB="$2" # OWNER/REPO
echo "$PROG: Getting $GITHUB"
( cd $TEMP
mkdir -p g/src/github.com/$GITHUB
cd g/src/github.com/$(dirname $GITHUB) && git clone --depth 1 https://github.com/$GITHUB
)
}
VERSION=$1
if [[ -z "$VERSION" ]]; then
echo "$PROG: No version set"
exit 1
fi
if [[ -z "$GITHUB_ACCESS_TOKEN" ]]; then
echo "$PROG: No GITHUB_ACCESS_TOKEN set"
exit 1
fi
GITHUB=miekg/dreck
TEMP=$(mktemp -d); function d1 { rm -rf $TEMP; }; trap d1 EXIT
latestGo $TEMP
setupGo $TEMP
fromGithub $TEMP $GITHUB
echo "$PROG: Building $GITHUB in $TEMP/g/src/github.com/$GITHUB"
( cd $TEMP/g/src/github.com/$GITHUB
make VERSION=$VERSION release
#make VERSION=$VERSION upload
)