Skip to content

Commit 222db21

Browse files
Jon Carlyurishkuro
authored andcommitted
Publish binaries to GitHub Releases (#766)
Signed-off-by: Jon Carl <jon.carl.42@gmail.com>
1 parent 8375fe5 commit 222db21

File tree

3 files changed

+117
-12
lines changed

3 files changed

+117
-12
lines changed

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ matrix:
2020
- go: 1.9
2121
env:
2222
- DOCKER=true
23+
- DEPLOY=true
2324
- go: 1.9
2425
env:
2526
- ES_INTEGRATION_TEST=true
@@ -54,9 +55,26 @@ script:
5455
- if [ "$DOCKER" == true ]; then bash ./scripts/travis/build-docker-images.sh ; else echo 'skipping docker images'; fi
5556
- if [ "$ES_INTEGRATION_TEST" == true ]; then bash ./scripts/travis/es-integration-test.sh ; else echo 'skipping elastic search integration test'; fi
5657
- if [ "$HOTROD" == true ]; then bash ./scripts/travis/hotrod-integration-test.sh ; else echo 'skipping hotrod example'; fi
58+
- if [ "$DEPLOY" == true ]; then make build-binaries-linux build-binaries-windows build-binaries-darwin ; else echo 'skipping linux'; fi
5759

5860
after_success:
5961
- if [ "$COVERAGE" == true ]; then travis_retry goveralls -coverprofile=cover.out -service=travis-ci || true ; else echo 'skipping coverage'; fi
6062

6163
after_failure:
6264
- if [ "$CROSSDOCK" == true ]; then make crossdock-logs ; else echo 'skipping crossdock'; fi
65+
66+
before_deploy:
67+
- bash ./scripts/travis/package-deploy.sh
68+
69+
deploy:
70+
provider: releases
71+
api_key:
72+
secure: YOUR_API_KEY_ENCRYPTED
73+
file_glob: true
74+
file:
75+
- deploy/*.tar.gz
76+
skip_cleanup: true
77+
on:
78+
tags: true
79+
repo: jaegertracing/jaeger
80+
branch: master

Makefile

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,46 @@ build_ui:
143143
rm -rf jaeger-ui-build && mkdir jaeger-ui-build
144144
cp -r jaeger-ui/build jaeger-ui-build/
145145

146+
.PHONY: build-all-in-one
147+
build-all-in-one: build_ui
148+
CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/standalone/standalone-$(GOOS) $(BUILD_INFO) ./cmd/standalone/main.go
149+
146150
.PHONY: build-all-in-one-linux
147-
build-all-in-one-linux: build_ui
148-
CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./cmd/standalone/standalone-linux $(BUILD_INFO) ./cmd/standalone/main.go
151+
build-all-in-one-linux:
152+
GOOS=linux $(MAKE) build-all-in-one
149153

150-
.PHONY: build-agent-linux
151-
build-agent-linux:
152-
CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./cmd/agent/agent-linux $(BUILD_INFO) ./cmd/agent/main.go
154+
.PHONY: build-agent
155+
build-agent:
156+
CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/agent/agent-$(GOOS) $(BUILD_INFO) ./cmd/agent/main.go
153157

154-
.PHONY: build-query-linux
155-
build-query-linux:
156-
CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./cmd/query/query-linux $(BUILD_INFO) ./cmd/query/main.go
158+
.PHONY: build-query
159+
build-query:
160+
CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/query/query-$(GOOS) $(BUILD_INFO) ./cmd/query/main.go
157161

158-
.PHONY: build-collector-linux
159-
build-collector-linux:
160-
CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./cmd/collector/collector-linux $(BUILD_INFO) ./cmd/collector/main.go
162+
.PHONY: build-collector
163+
build-collector:
164+
CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/collector/collector-$(GOOS) $(BUILD_INFO) ./cmd/collector/main.go
161165

162166
.PHONY: docker-no-ui
163-
docker-no-ui: build-agent-linux build-collector-linux build-query-linux build-crossdock-linux
167+
docker-no-ui: build-binaries-linux build-crossdock-linux
164168
mkdir -p jaeger-ui-build/build/
165169
make docker-images-only
166170

167171
.PHONY: docker
168172
docker: build_ui docker-no-ui
169173

174+
.PHONY: build-binaries-linux
175+
build-binaries-linux:
176+
GOOS=linux $(MAKE) build-agent build-collector build-query build-all-in-one
177+
178+
.PHONY: build-binaries-windows
179+
build-binaries-windows:
180+
GOOS=windows $(MAKE) build-agent build-collector build-query build-all-in-one
181+
182+
.PHONY: build-binaries-darwin
183+
build-binaries-darwin:
184+
GOOS=darwin $(MAKE) build-agent build-collector build-query build-all-in-one
185+
170186
.PHONY: docker-images-only
171187
docker-images-only:
172188
cp -r jaeger-ui-build/build/ cmd/query/jaeger-ui-build
@@ -262,3 +278,7 @@ install-mockery:
262278
.PHONY: generate-mocks
263279
generate-mocks: install-mockery
264280
$(MOCKERY) -all -dir ./pkg/es/ -output ./pkg/es/mocks && rm pkg/es/mocks/ClientBuilder.go
281+
282+
.PHONY: echo-version
283+
echo-version:
284+
@echo $(GIT_CLOSEST_TAG)

scripts/travis/package-deploy.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
# stage-file copies the file $1 with the specified path $2
4+
# if no file exists it will silently continue
5+
function stage-file {
6+
if [ -f $1 ]; then
7+
echo "Copying $1 to $2"
8+
cp $1 $2
9+
else
10+
echo "$1 does not exist. Continuing on."
11+
fi
12+
}
13+
14+
# stage-platform-files stages the different the platform ($1) into the package
15+
# staging dir ($2). If you pass in a file extension ($3) it will be used when
16+
# copying on the source
17+
function stage-platform-files {
18+
local PLATFORM=$1
19+
local PACKAGE_STAGING_DIR=$2
20+
local FILE_EXTENSION=$3
21+
22+
stage-file ./cmd/standalone/standalone-$PLATFORM $PACKAGE_STAGING_DIR/jaeger-standalone$FILE_EXTENSION
23+
stage-file ./cmd/agent/agent-$PLATFORM $PACKAGE_STAGING_DIR/jaeger-agent$FILE_EXTENSION
24+
stage-file ./cmd/query/query-$PLATFORM $PACKAGE_STAGING_DIR/jaeger-query$FILE_EXTENSION
25+
stage-file ./cmd/collector/collector-$PLATFORM $PACKAGE_STAGING_DIR/jaeger-collector$FILE_EXTENSION
26+
}
27+
28+
# package pulls built files for the platform ($1). If you pass in a file
29+
# extension ($2) it will be used on the binaries
30+
function package {
31+
local PLATFORM=$1
32+
local FILE_EXTENSION=$2
33+
34+
local PACKAGE_STAGING_DIR=$DEPLOY_STAGING_DIR/$PLATFORM
35+
mkdir $PACKAGE_STAGING_DIR
36+
37+
stage-platform-files $PLATFORM $PACKAGE_STAGING_DIR $FILE_EXTENSION
38+
39+
local PACKAGE_FILES=$(ls -A $PACKAGE_STAGING_DIR/*) 2>/dev/null
40+
41+
if [ "$PACKAGE_FILES" ]; then
42+
local ARCHIVE_NAME="jaeger-$VERSION-$PLATFORM-amd64.tar.gz"
43+
echo "Packaging the following files into $ARCHIVE_NAME:"
44+
echo $PACKAGE_FILES
45+
tar -czvf ./deploy/$ARCHIVE_NAME $PACKAGE_FILES
46+
else
47+
echo "Will not package or deploy $PLATFORM files as there are no files to package!"
48+
fi
49+
}
50+
51+
# script start
52+
53+
DEPLOY_STAGING_DIR=./deploy-staging
54+
VERSION="$(make echo-version | awk 'match($0, /([0-9]*\.[0-9]*\.[0-9]*)$/) { print substr($0, RSTART, RLENGTH) }')"
55+
echo "Working on version: $VERSION"
56+
57+
# make needed directories
58+
mkdir deploy
59+
mkdir $DEPLOY_STAGING_DIR
60+
61+
if [ "$DEPLOY" = true ]; then
62+
package linux
63+
package darwin
64+
package windows .exe
65+
else
66+
echo "Skipping the packaging of binaries as \$DEPLOY was not true."
67+
fi

0 commit comments

Comments
 (0)