Skip to content

Commit 1164ca5

Browse files
authored
chore: use fpm for packaging (#476)
* chore: remove goreleaser configuration and scripts * chore: replace goreleaser with fpm goreleaser handled signing and uploading packages. So, that functionality had to be implemented here as well.
1 parent 48e8f5b commit 1164ca5

8 files changed

+378
-236
lines changed

.circleci/config.yml

+145-89
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,20 @@ executors:
2626
resource_class: windows.medium
2727
shell: bash.exe -eo pipefail
2828

29+
30+
release_filter: &release_filter
31+
filters:
32+
tags:
33+
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
34+
branches:
35+
ignore: /.*/
36+
2937
workflows:
3038
version: 2
3139
build-and-test:
3240
jobs:
3341
- lint
3442
- check-openapi
35-
- build-all
3643
- test-race:
3744
name: test-linux-amd64
3845
- test-build:
@@ -70,6 +77,24 @@ workflows:
7077
arch: amd64
7178
requires:
7279
- test-build-amd64-windows
80+
- build:
81+
name: build-<< matrix.os >>-<< matrix.arch >>
82+
matrix:
83+
parameters:
84+
os: [ linux, darwin, windows ]
85+
arch: [ amd64, arm64 ]
86+
exclude:
87+
- os: darwin
88+
arch: arm64
89+
- os: windows
90+
arch: arm64
91+
- build-packages:
92+
sign: false
93+
requires:
94+
- build-darwin-amd64
95+
- build-linux-amd64
96+
- build-linux-arm64
97+
- build-windows-amd64
7398
release-nightly:
7499
triggers:
75100
- schedule:
@@ -119,6 +144,24 @@ workflows:
119144
arch: amd64
120145
requires:
121146
- test-build-amd64-windows
147+
- build:
148+
name: build-<< matrix.os >>-<< matrix.arch >>
149+
matrix:
150+
parameters:
151+
os: [ linux, darwin, windows ]
152+
arch: [ amd64, arm64 ]
153+
exclude:
154+
- os: darwin
155+
arch: arm64
156+
- os: windows
157+
arch: arm64
158+
- build-packages:
159+
sign: true
160+
requires:
161+
- build-darwin-amd64
162+
- build-linux-amd64
163+
- build-linux-arm64
164+
- build-windows-amd64
122165
- release:
123166
is-nightly: true
124167
requires:
@@ -129,39 +172,20 @@ workflows:
129172
- test-linux-arm64
130173
- test-mac
131174
- test-windows
175+
- build-packages
132176
release-tag:
133177
jobs:
134178
- changelog:
135-
filters:
136-
branches:
137-
ignore: /.*/
138-
tags:
139-
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
179+
<<: *release_filter
140180
- lint:
141-
filters:
142-
branches:
143-
ignore: /.*/
144-
tags:
145-
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
181+
<<: *release_filter
146182
- check-openapi:
147-
filters:
148-
branches:
149-
ignore: /.*/
150-
tags:
151-
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
183+
<<: *release_filter
152184
- test-race:
153185
name: test-linux-amd64
154-
filters:
155-
branches:
156-
ignore: /.*/
157-
tags:
158-
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
186+
<<: *release_filter
159187
- test-build:
160-
filters:
161-
branches:
162-
ignore: /.*/
163-
tags:
164-
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
188+
<<: *release_filter
165189
matrix:
166190
parameters:
167191
os: [ linux, darwin, windows ]
@@ -176,47 +200,51 @@ workflows:
176200
- os: linux
177201
arch: amd64
178202
- test-prebuilt:
203+
<<: *release_filter
179204
name: test-linux-arm64
180-
filters:
181-
branches:
182-
ignore: /.*/
183-
tags:
184-
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
185205
executor: linux-arm64
186206
os: linux
187207
arch: arm64
188208
requires:
189209
- test-build-arm64-linux
190210
- test-prebuilt:
211+
<<: *release_filter
191212
name: test-mac
192-
filters:
193-
branches:
194-
ignore: /.*/
195-
tags:
196-
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
197213
executor: mac
198214
os: darwin
199215
arch: amd64
200216
requires:
201217
- test-build-amd64-darwin
202218
- test-prebuilt:
219+
<<: *release_filter
203220
name: test-windows
204-
filters:
205-
branches:
206-
ignore: /.*/
207-
tags:
208-
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
209221
executor: windows
210222
os: windows
211223
arch: amd64
212224
requires:
213225
- test-build-amd64-windows
226+
- build:
227+
<<: *release_filter
228+
name: build-<< matrix.os >>-<< matrix.arch >>
229+
matrix:
230+
parameters:
231+
os: [ linux, darwin, windows ]
232+
arch: [ amd64, arm64 ]
233+
exclude:
234+
- os: darwin
235+
arch: arm64
236+
- os: windows
237+
arch: arm64
238+
- build-packages:
239+
<<: *release_filter
240+
sign: true
241+
requires:
242+
- build-darwin-amd64
243+
- build-linux-amd64
244+
- build-linux-arm64
245+
- build-windows-amd64
214246
- release:
215-
filters:
216-
branches:
217-
ignore: /.*/
218-
tags:
219-
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
247+
<<: *release_filter
220248
is-nightly: false
221249
requires:
222250
- changelog
@@ -226,6 +254,7 @@ workflows:
226254
- test-linux-arm64
227255
- test-mac
228256
- test-windows
257+
- build-packages
229258

230259
commands:
231260
setup:
@@ -247,11 +276,6 @@ commands:
247276
echo 'export PATH=${GOPATH}/bin:${PATH}' >> $BASH_ENV
248277
mkdir -p ${HOME}/.cache
249278
echo 'export GOCACHE=${HOME}/.cache' >> $BASH_ENV
250-
install-goreleaser:
251-
steps:
252-
- run:
253-
name: Install goreleaser
254-
command: ./scripts/ci/download-goreleaser.sh v1.14.0
255279
256280
jobs:
257281
lint:
@@ -289,23 +313,6 @@ jobs:
289313
command: git submodule update --init --recursive
290314
- run: make checkopenapi
291315

292-
build-all:
293-
executor: linux-amd64
294-
steps:
295-
- checkout
296-
- setup
297-
- install-goreleaser
298-
- run:
299-
name: Make a pseudo-tag for the snapshot build
300-
command: |
301-
latest_tag=$(git describe --tags --abbrev=0)
302-
git tag ${latest_tag}+SNAPSHOT.$(git rev-parse --short HEAD)
303-
- run:
304-
name: Cross-build all targets
305-
command: IS_SNAPSHOT=1 goreleaser release --rm-dist --skip-publish --skip-sign --skip-validate
306-
- store_artifacts:
307-
path: dist
308-
309316
release:
310317
parameters:
311318
is-nightly:
@@ -315,38 +322,25 @@ jobs:
315322
- checkout
316323
- attach_workspace:
317324
at: .
318-
- setup
319325
- run:
320-
name: Import GPG key
321326
command: |
322-
echo -e "$GPG_PRIVATE_KEY" > private.key
323-
gpg --batch --import private.key
324-
- install-goreleaser
327+
export DEBIAN_FRONTEND=noninteractive
328+
sudo apt-get update -y
329+
sudo apt-get install -y awscli gnupg
330+
331+
gpg --import --batch \<<<"${GPG_PRIVATE_KEY//$'\\n'/$'\n'}"
325332
- when:
326333
condition: << parameters.is-nightly >>
327334
steps:
328335
- run:
329-
name: Make a pseudo-tag for the nightly build
330-
command: |
331-
latest_tag=$(git describe --tags --abbrev=0)
332-
git tag ${latest_tag}+nightly.$(date +%Y.%m.%d)
333-
- run:
334-
name: Publish nightly snapshot release
335-
command: IS_NIGHTLY=1 goreleaser release --rm-dist
336+
command: .circleci/scripts/upload-artifacts nightly
336337
- unless:
337338
condition: << parameters.is-nightly >>
338339
steps:
339340
- run:
340-
name: Publish tagged release
341-
command: goreleaser release --rm-dist
342-
- run:
343-
command: |
344-
export DEBIAN_FRONTEND=noninteractive
345-
sudo apt-get update
346-
sudo apt-get install awscli
347-
.circleci/scripts/upload-latest-artifacts
341+
command: .circleci/scripts/upload-artifacts release
348342
- store_artifacts:
349-
path: dist
343+
path: packages
350344

351345
test-build:
352346
executor: cross-builder
@@ -403,6 +397,68 @@ jobs:
403397
- store_test_results:
404398
path: ./test-results
405399

400+
build:
401+
executor: cross-builder
402+
parameters:
403+
os:
404+
type: string
405+
arch:
406+
type: string
407+
steps:
408+
- checkout
409+
- run:
410+
name: Build Binaries
411+
command: |
412+
GOOS=<<parameters.os>> GOARCH=<<parameters.arch>> make
413+
- store_artifacts:
414+
path: bin
415+
- persist_to_workspace:
416+
root: .
417+
paths: bin
418+
419+
build-packages:
420+
docker:
421+
- image: ubuntu:latest
422+
resource_class: small
423+
parameters:
424+
sign:
425+
type: boolean
426+
steps:
427+
- attach_workspace:
428+
at: /tmp/workspace
429+
- checkout
430+
- run:
431+
name: Build Packages
432+
command: |
433+
export DEBIAN_FRONTEND=noninteractive
434+
apt-get update
435+
apt-get install --yes \
436+
build-essential \
437+
git \
438+
gnupg \
439+
rpm \
440+
ruby-dev
441+
gem install fpm
442+
443+
if [[ "<< parameters.sign >>" == "true" ]]
444+
then
445+
gpg --import --batch \<<<"${GPG_PRIVATE_KEY//$'\\n'/$'\n'}"
446+
447+
export SIGN_PACKAGES=1
448+
fi
449+
450+
mkdir -p packages
451+
OS=darwin ARCH=amd64 scripts/ci/build-packages /tmp/workspace/bin/darwin/amd64/influx "${PWD}/packages"
452+
OS=linux ARCH=amd64 scripts/ci/build-packages /tmp/workspace/bin/linux/amd64/influx "${PWD}/packages"
453+
OS=linux ARCH=arm64 scripts/ci/build-packages /tmp/workspace/bin/linux/arm64/influx "${PWD}/packages"
454+
OS=windows ARCH=amd64 scripts/ci/build-packages /tmp/workspace/bin/windows/amd64/influx "${PWD}/packages"
455+
- store_artifacts:
456+
path: packages/
457+
- persist_to_workspace:
458+
root: .
459+
paths:
460+
- packages
461+
406462
changelog:
407463
docker:
408464
- image: quay.io/influxdb/changelogger:a20523cf8594eb93920e74d0189d6602a76a6146

0 commit comments

Comments
 (0)