Skip to content

Commit bfd0bd8

Browse files
committed
feat: add building via circleci
1 parent 10e14dc commit bfd0bd8

File tree

6 files changed

+165
-2
lines changed

6 files changed

+165
-2
lines changed

.circleci/config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: 2
2+
jobs:
3+
build:
4+
machine:
5+
docker_layer_caching: true
6+
steps:
7+
- checkout
8+
- run:
9+
command: |
10+
make version
11+
if [[ "$CIRCLE_BRANCH" == "release" ]]; then
12+
make .env.docker
13+
fi
14+
- run: make circleci
15+
- run: make build-docker-image
16+
- run:
17+
command: |
18+
make build-in-docker
19+
[[ -d build ]] && sudo chown -R circleci:circleci build
20+
- store_artifacts:
21+
path: build
22+
destination: build
23+
- run:
24+
command: |
25+
if [[ "$CIRCLE_BRANCH" == "release" ]]; then
26+
make release-in-docker
27+
fi

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Dockerfile*
2+
LICENSE
3+
README.md

.gitignore

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1-
.env
2-
dds-client
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, build with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Build output
15+
build/*
16+
17+
# Release output
18+
release/*
19+
20+
# Validation output
21+
validation/*
22+
23+
# .env files
24+
.env*
25+
26+
*dds-client

Dockerfile.build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM golang:1.12.0-stretch
2+
3+
RUN apt-get update \
4+
&& apt install apt-transport-https build-essential curl gnupg2 lintian rpm rsync rubygems-integration ruby-dev ruby -qy \
5+
&& apt-get clean \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
RUN gem install --no-ri --no-rdoc --quiet rake fpm package_cloud
9+
10+
WORKDIR /src

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2019 Plotly, Inc
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Makefile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
NAME = dds-client
2+
MAINTAINER = plotly
3+
REPOSITORY = dds-client
4+
HARDWARE = $(shell uname -m)
5+
SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]')
6+
BASE_VERSION ?= 0.7.0
7+
IMAGE_NAME ?= $(MAINTAINER)/$(REPOSITORY)
8+
9+
ifeq ($(CIRCLE_BRANCH),release)
10+
VERSION ?= $(BASE_VERSION)
11+
DOCKER_IMAGE_VERSION = $(VERSION)
12+
else
13+
VERSION = $(shell echo "${BASE_VERSION}")build+$(shell git rev-parse --short HEAD)
14+
DOCKER_IMAGE_VERSION = $(shell echo "${BASE_VERSION}")build-$(shell git rev-parse --short HEAD)
15+
endif
16+
17+
version:
18+
@echo "$(CIRCLE_BRANCH)"
19+
@echo "$(VERSION)"
20+
21+
LIST = build release
22+
targets = $(addsuffix -in-docker, $(LIST))
23+
24+
.env.docker:
25+
@rm -f .env.docker
26+
@touch .env.docker
27+
@echo "CIRCLE_BRANCH=$(CIRCLE_BRANCH)" >> .env.docker
28+
@echo "GITHUB_ACCESS_TOKEN=$(GITHUB_ACCESS_TOKEN)" >> .env.docker
29+
@echo "IMAGE_NAME=$(IMAGE_NAME)" >> .env.docker
30+
@echo "VERSION=$(VERSION)" >> .env.docker
31+
32+
build:
33+
@$(MAKE) build/darwin/$(NAME)
34+
@$(MAKE) build/linux/$(NAME)
35+
36+
build-docker-image:
37+
docker build --rm -q -f Dockerfile.build -t $(IMAGE_NAME):build .
38+
39+
$(targets): %-in-docker: .env.docker
40+
docker run \
41+
--env-file .env.docker \
42+
--rm \
43+
--volume /var/lib/docker:/var/lib/docker \
44+
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
45+
--volume ${PWD}:/src/github.com/$(MAINTAINER)/$(REPOSITORY) \
46+
--workdir /src/github.com/$(MAINTAINER)/$(REPOSITORY) \
47+
$(IMAGE_NAME):build make -e $(@:-in-docker=)
48+
49+
build/darwin/$(NAME):
50+
mkdir -p build/darwin
51+
CGO_ENABLED=0 GOOS=darwin go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
52+
-ldflags "-s -w -X main.Version=$(VERSION)" \
53+
-o build/darwin/$(NAME)
54+
55+
build/linux/$(NAME):
56+
mkdir -p build/linux
57+
CGO_ENABLED=0 GOOS=linux go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
58+
-ldflags "-s -w -X main.Version=$(VERSION)" \
59+
-o build/linux/$(NAME)
60+
61+
clean:
62+
rm -rf build release
63+
64+
circleci:
65+
docker version
66+
rm -f ~/.gitconfig
67+
68+
bin/gh-release:
69+
mkdir -p bin
70+
curl -o bin/gh-release.tgz -sL https://github.com/progrium/gh-release/releases/download/v2.2.1/gh-release_2.2.1_$(SYSTEM_NAME)_$(HARDWARE).tgz
71+
tar xf bin/gh-release.tgz -C bin
72+
chmod +x bin/gh-release
73+
74+
release: build bin/gh-release
75+
rm -rf release && mkdir release
76+
tar -zcf release/$(NAME)_$(VERSION)_linux_$(HARDWARE).tgz -C build/linux $(NAME)
77+
tar -zcf release/$(NAME)_$(VERSION)_darwin_$(HARDWARE).tgz -C build/darwin $(NAME)
78+
bin/gh-release create $(MAINTAINER)/$(REPOSITORY) $(VERSION) $(shell git rev-parse --abbrev-ref HEAD)

0 commit comments

Comments
 (0)