-
Notifications
You must be signed in to change notification settings - Fork 45
/
release.sh
executable file
·128 lines (95 loc) · 3.63 KB
/
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
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
#!/usr/bin/env bash
# STEPS TO PERFORM RELEASE
#
# 1) ensure a new tag exists on github:
# git tag -a v0.15.1 -m 'my release note'
#
# 2) run release.sh
#
# https://github.com/aktau/github-release
#
# expects GITHUB_TOKEN in env
#
# show info on current release
# github-release info -u dataux -r dataux
export GITHUB_USER="dataux"
export GITHUB_REPO="dataux"
cd $GOPATH/src/github.com/dataux/dataux
# ensure before we build it is correct package vendoring
dep ensure -v
dockerbuild() {
# build the go binaries for docker
./.build
# set gcloud config to point to this project
# where we are hosting our docker images
gcloud config set project dataux-io
# cleanup local docker
docker rm -f gcr.io/dataux-io/dataux:latest
docker rmi -f gcr.io/dataux-io/dataux:latest
docker rm -f gcr.io/dataux-io/dataux:$TAG
docker rmi -f gcr.io/dataux-io/dataux:$TAG
# if you get auth issues
#
# rm ~/.docker/config.json
# gcloud auth configure-docker
docker build -t gcr.io/dataux-io/dataux:$TAG .
#gcloud docker -- push gcr.io/dataux-io/dataux:$TAG
docker push gcr.io/dataux-io/dataux:$TAG
docker tag gcr.io/dataux-io/dataux:$TAG gcr.io/dataux-io/dataux:latest
#docker build -t gcr.io/dataux-io/dataux:latest .
docker push gcr.io/dataux-io/dataux:latest
# now lets allow anyone to read these gcr images
# https://cloud.google.com/container-registry/docs/access-control
gsutil defacl ch -u AllUsers:R gs://artifacts.dataux-io.appspot.com
gsutil acl ch -r -u AllUsers:R gs://artifacts.dataux-io.appspot.com
}
dorelease() {
# http://stackoverflow.com/questions/11354518/golang-application-auto-build-versioning
version=$(git describe --tags | tr -d '\n')
pubver=$(git rev-parse --short HEAD)
echo "Making binaries version: $version versionpublic: $pubver tag= $TAG"
# if we are re-running, lets delete it first
github-release delete --tag "$TAG"
# create a release for tag
github-release release \
--tag "$TAG" \
--name "Dataux $TAG release" \
--description "
Scripts to download and save the binary and rename to dataux
\`\`\`
# linux/amd64
curl -Lo dataux https://github.com/dataux/dataux/releases/download/$TAG/dataux_linux.$TAG && chmod +x dataux && sudo mv dataux /usr/local/bin/
# OS X/amd64
curl -Lo dataux https://github.com/dataux/dataux/releases/download/$TAG/dataux_mac.$TAG && chmod +x dataux && sudo mv dataux /usr/local/bin/
\`\`\`
"
# https://github.com/dataux/dataux/releases/download/2016.12.03/dataux_linux.2016.12.03
# create a build for the mac osx amd64 binary
echo "Building mac dataux"
env GOOS=darwin GOARCH=amd64 go build -ldflags "-X github.com/dataux/dataux/version.Version=${version} -X github.com/dataux/dataux/version.VersionPublic=${pubver}"
# need to move to the staic build for docker
# GOOS=linux go build -a --ldflags '-extldflags "-static"' -tags netgo -installsuffix netgo .
echo "Now uploading $TAG mac version"
github-release upload \
--tag "$TAG" \
--label "Dataux mac $TAG" \
--name "dataux_mac.$TAG" \
--file dataux
# do the linux release
echo "Building linux dataux"
go build -ldflags "-X github.com/dataux/dataux/version.Version=${version} -X github.com/dataux/dataux/version.VersionPublic=${pubver}"
echo "Now uploading $TAG linux version"
github-release upload \
--tag "$TAG" \
--label "Dataux linux $TAG" \
--name "dataux_linux.$TAG" \
--file dataux
}
# lets get the name of this release which is our tag
# aka v0.15.0 type tag
export TAG=$(git describe $(git rev-list --tags --max-count=1))
dorelease
dockerbuild
# we are going to always release a latest
export TAG="latest"
dorelease