forked from honeycombio/refinery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
177 lines (169 loc) · 5.08 KB
/
config.yml
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
version: 2.1
orbs:
aws-cli: circleci/[email protected]
docker: circleci/[email protected]
executors:
linuxgo:
parameters:
docker:
- image: cimg/go:1.15
- image: redis:6
commands:
go-build:
parameters:
os:
description: Target operating system
type: enum
enum: ["linux", "darwin"]
default: "linux"
arch:
description: Target architecture
type: enum
enum: ["amd64", "arm64"]
default: "amd64"
steps:
- run: |
GOOS=<< parameters.os >> \
GOARCH=<< parameters.arch >> \
go build -ldflags "-X main.BuildID=${CIRCLE_TAG:-${CIRCLE_SHA1:0:7}}" \
-o $GOPATH/bin/refinery-<< parameters.os >>-<< parameters.arch >> \
./cmd/refinery
jobs:
test:
executor: linuxgo
steps:
- checkout
- run:
name: install dockerize
command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
environment:
DOCKERIZE_VERSION: v0.3.0
- run:
name: Wait for redis
command: dockerize -wait tcp://localhost:6379 -timeout 1m
- run:
name: go_test with race
command: go test -tags race --race --timeout 60s -v ./...
- run:
name: go_test
command: go test -tags all --timeout 60s -v ./...
build:
executor: linuxgo
steps:
- checkout
- go-build:
os: linux
arch: amd64
- go-build:
os: linux
arch: arm64
- go-build:
os: darwin
arch: amd64
- run:
name: apt_get_update
command: sudo apt-get -qq update
- run:
name: apt_get_install
command: sudo apt-get install -y build-essential rpm ruby ruby-dev
- run:
name: gem_install
command: sudo gem install fpm
- run: mkdir -p ~/artifacts
- run:
name: build_deb_amd64
command: ./build-pkg.sh -m amd64 -v "${CIRCLE_TAG:-${CIRCLE_SHA1:0:7}}" -t deb && mv *.deb ~/artifacts
- run:
name: build_deb_arm64
command: ./build-pkg.sh -m arm64 -v "${CIRCLE_TAG:-${CIRCLE_SHA1:0:7}}" -t deb && mv *.deb ~/artifacts
- run:
name: build_rpm_amd64
command: ./build-pkg.sh -m amd64 -v "${CIRCLE_TAG:-${CIRCLE_SHA1:0:7}}" -t rpm && mv *.rpm ~/artifacts
- run:
name: copy_binaries
command: cp $GOPATH/bin/refinery-* ~/artifacts
- run: echo "finished builds" && find ~/artifacts -ls
- persist_to_workspace:
root: ~/
paths:
- artifacts
- store_artifacts:
path: ~/artifacts
publish_github:
docker:
- image: cibuilds/github:0.13.0
steps:
- attach_workspace:
at: ~/
- run:
name: "Publish Release on GitHub"
command: |
echo "about to publish to tag ${CIRCLE_TAG}"
ls -l ~/artifacts/*
ghr -draft -n ${CIRCLE_TAG} -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${CIRCLE_TAG} ~/artifacts
publish_s3:
executor: aws-cli/default
steps:
- attach_workspace:
at: ~/
- aws-cli/setup:
aws-access-key-id: AWS_ACCESS_KEY_ID
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
aws-region: AWS_REGION
- run:
name: sync_s3_artifacts
command: |
version=${CIRCLE_TAG:1}
if [[ -z "$version" ]] ; then version=${CIRCLE_SHA1:0:7}; fi
aws s3 sync ~/artifacts s3://honeycomb-builds/honeycombio/refinery/$version/
workflows:
build:
jobs:
- test:
filters:
tags:
only: /.*/
- build:
requires:
- test
filters:
tags:
only: /.*/
- publish_github:
context: Honeycomb Secrets for Public Repos
requires:
- build
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- publish_s3:
context: Honeycomb Secrets for Public Repos
requires:
- build
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- docker/publish:
tag: latest
extra_build_args: --build-arg BUILD_ID=${CIRCLE_SHA1:0:7}
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
requires:
- build
filters:
branches:
only: main
- docker/publish:
tag: latest,${CIRCLE_TAG:1}
extra_build_args: --build-arg BUILD_ID=${CIRCLE_TAG:1}
image: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
requires:
- build
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/