ci(goreleaser): create a release version of goreleaser

Co-authored-by: Luke Morris <lukevmorris@gmail.com>
Co-authored-by: Mark Rushakoff <mark@influxdata.com>
pull/11508/head
Chris Goller 2019-01-23 14:19:05 -06:00
parent cfc5291e9e
commit a0121c8819
4 changed files with 136 additions and 24 deletions

View File

@ -37,14 +37,14 @@ jobs:
- restore_cache: - restore_cache:
name: Restoring GOCACHE name: Restoring GOCACHE
keys: keys:
- platform-gocache-{{ .Branch }}-{{ .Revision }} # Matches when retrying a single run. - influxdb-gocache-{{ .Branch }}-{{ .Revision }} # Matches when retrying a single run.
- platform-gocache-{{ .Branch }}- # Matches a new commit on an existing branch. - influxdb-gocache-{{ .Branch }}- # Matches a new commit on an existing branch.
- platform-gocache- # Matches a new branch. - influxdb-gocache- # Matches a new branch.
# Populate GOPATH/pkg. # Populate GOPATH/pkg.
- restore_cache: - restore_cache:
name: Restoring GOPATH/pkg/mod name: Restoring GOPATH/pkg/mod
keys: keys:
- platform-gomod-{{ checksum "go.sum" }} # Matches based on go.sum checksum. - influxdb-gomod-{{ checksum "go.sum" }} # Matches based on go.sum checksum.
- run: make test-go # This uses the test cache so it may succeed or fail quickly. - run: make test-go # This uses the test cache so it may succeed or fail quickly.
- run: make vet - run: make vet
- run: make checkfmt - run: make checkfmt
@ -64,13 +64,13 @@ jobs:
- save_cache: - save_cache:
name: Saving GOCACHE name: Saving GOCACHE
key: platform-gocache-{{ .Branch }}-{{ .Revision }} key: influxdb-gocache-{{ .Branch }}-{{ .Revision }}
paths: paths:
- /tmp/go-cache - /tmp/go-cache
when: always when: always
- save_cache: - save_cache:
name: Saving GOPATH/pkg/mod name: Saving GOPATH/pkg/mod
key: platform-gomod-{{ checksum "go.sum" }} key: influxdb-gomod-{{ checksum "go.sum" }}
paths: paths:
- /go/pkg/mod - /go/pkg/mod
when: always when: always
@ -89,18 +89,18 @@ jobs:
- restore_cache: - restore_cache:
name: Restoring GOCACHE name: Restoring GOCACHE
keys: keys:
- platform-gocache- # Just match the most recent Go cache. - influxdb-gocache- # Just match the most recent Go cache.
- restore_cache: - restore_cache:
name: Restoring GOPATH/pkg/mod name: Restoring GOPATH/pkg/mod
keys: keys:
- platform-gomod-{{ checksum "go.sum" }} # Just match the go.sum checksum cache. - influxdb-gomod-{{ checksum "go.sum" }} # Just match the go.sum checksum cache.
- restore_cache: - restore_cache:
name: Restore Yarn package cache name: Restore Yarn package cache
keys: keys:
- chronograf-npm-packages-{{ checksum "ui/package-lock.json" }} - chronograf-npm-packages-{{ checksum "ui/package-lock.json" }}
- run: make build - run: make build
deploy: deploy-nightly:
docker: docker:
- image: circleci/golang:1.11-node-browsers - image: circleci/golang:1.11-node-browsers
environment: environment:
@ -114,11 +114,11 @@ jobs:
- restore_cache: - restore_cache:
name: Restoring GOCACHE name: Restoring GOCACHE
keys: keys:
- platform-gocache- # Just match the most recent Go cache. - influxdb-gocache- # Just match the most recent Go cache.
- restore_cache: - restore_cache:
name: Restoring GOPATH/pkg/mod name: Restoring GOPATH/pkg/mod
keys: keys:
- platform-gomod-{{ checksum "go.sum" }} # Just match the go.sum checksum cache. - influxdb-gomod-{{ checksum "go.sum" }} # Just match the go.sum checksum cache.
- restore_cache: - restore_cache:
name: Restore Yarn package cache name: Restore Yarn package cache
keys: keys:
@ -127,12 +127,40 @@ jobs:
- run: - run:
name: "Docker Login" name: "Docker Login"
command: docker login -u "$QUAY_USER" -p $QUAY_PASS quay.io command: docker login -u "$QUAY_USER" -p $QUAY_PASS quay.io
- run:
name: "Tag commit for goreleaser semantic versioning"
command: git tag v0.0.0
- run: - run:
name: "Build nightly" name: "Build nightly"
command: make nightly command: make nightly
release:
docker:
- image: circleci/golang:1.11-node-browsers
environment:
GOCACHE: /tmp/go-cache
GOFLAGS: "-mod=readonly -p=4" # Go on Circle thinks 32 CPUs are available, but there aren't.
DOCKER_VERSION: 2.0.0-alpha
working_directory: /go/src/github.com/influxdata/influxdb
steps:
- checkout
# Speed up `make nightly` by restoring caches from previous runs.
- restore_cache:
name: Restoring GOCACHE
keys:
- influxdb-gocache- # Just match the most recent Go cache.
- restore_cache:
name: Restoring GOPATH/pkg/mod
keys:
- influxdb-gomod-{{ checksum "go.sum" }} # Just match the go.sum checksum cache.
- restore_cache:
name: Restore Yarn package cache
keys:
- chronograf-npm-packages-{{ checksum "ui/package-lock.json" }}
- setup_remote_docker
- run:
name: "Docker Login"
command: docker login -u "$QUAY_USER" -p $QUAY_PASS quay.io
- run:
name: "Build release"
command: make release
workflows: workflows:
version: 2 version: 2
@ -153,10 +181,23 @@ workflows:
jobs: jobs:
- gotest - gotest
- jstest - jstest
- deploy: - deploy-nightly:
requires: requires:
- gotest - gotest
- jstest - jstest
filters: filters:
branches: branches:
only: master only: master
release:
jobs:
- gotest
- jstest
- release:
requires:
- gotest
- jstest
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+$/

65
.goreleaser-nightly.yml Normal file
View File

@ -0,0 +1,65 @@
project_name: platform
builds:
- goos:
- linux
- darwin
goarch:
- amd64
- arm64
main: ./cmd/influx/
env:
- GO111MODULE=on
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
binary: influx
- goos:
- linux
- darwin
goarch:
- amd64
- arm64
main: ./cmd/influxd/
flags:
- -tags=assets
env:
- GO111MODULE=on
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
binary: influxd
hooks:
pre: make generate
archive:
format: tar.gz
wrap_in_directory: true
format_overrides:
- goos: windows
format: zip
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{
.Arm }}{{ end }}'
files:
- LICENSE
- README.md
snapshot:
name_template: 'nightly'
s3:
-
bucket: dl.influxdata.com
region: us-east-1
folder: "platform/nightlies/"
dockers:
- goos: linux
goarch: amd64
binaries:
- influxd
- influx
image_templates:
- 'quay.io/influxdb/influx:{{ .Version }}'
dockerfile: docker/influxd/Dockerfile
extra_files:
- docker/influxd/entrypoint.sh
# Do not make github release
release:
disable: true

View File

@ -1,4 +1,4 @@
project_name: platform project_name: influxdb
builds: builds:
- goos: - goos:
- linux - linux
@ -39,14 +39,11 @@ archive:
- LICENSE - LICENSE
- README.md - README.md
snapshot:
name_template: 'nightly'
s3: s3:
- -
bucket: dl.influxdata.com bucket: dl.influxdata.com
region: us-east-1 region: us-east-1
folder: "platform/nightlies/" folder: "influxdb/releases/"
dockers: dockers:
- goos: linux - goos: linux
@ -55,11 +52,14 @@ dockers:
- influxd - influxd
- influx - influx
image_templates: image_templates:
- 'quay.io/influxdb/influx:{{ .Version }}' - 'quay.io/influxdb/influxdb:{{ .Env.DOCKER_VERSION }}'
dockerfile: docker/influxd/Dockerfile dockerfile: docker/influxd/Dockerfile
extra_files: extra_files:
- docker/influxd/entrypoint.sh - docker/influxd/entrypoint.sh
# Do not make github release # Do not make github release
release: release:
disable: true name_template: "v{{.Version}}"
prerelease: auto # when we go to GA remove this line
draft: true # when we go to GA remove this line
disable: true # we keep the artifacts in S3 and link from the website

View File

@ -19,6 +19,7 @@ GO_ARGS=-tags '$(GO_TAGS)'
# Test vars can be used by all recursive Makefiles # Test vars can be used by all recursive Makefiles
export GOOS=$(shell go env GOOS) export GOOS=$(shell go env GOOS)
export GO_BUILD=env GO111MODULE=on go build $(GO_ARGS) export GO_BUILD=env GO111MODULE=on go build $(GO_ARGS)
export GO_INSTALL=env GO111MODULE=on go install $(GO_ARGS)
export GO_TEST=env GOTRACEBACK=all GO111MODULE=on go test $(GO_ARGS) export GO_TEST=env GOTRACEBACK=all GO111MODULE=on go test $(GO_ARGS)
# Do not add GO111MODULE=on to the call to go generate so it doesn't pollute the environment. # Do not add GO111MODULE=on to the call to go generate so it doesn't pollute the environment.
export GO_GENERATE=go generate $(GO_ARGS) export GO_GENERATE=go generate $(GO_ARGS)
@ -119,10 +120,15 @@ bench:
build: all build: all
dist: dist:
$(GO_RUN) github.com/goreleaser/goreleaser --snapshot --rm-dist $(GO_RUN) github.com/goreleaser/goreleaser --snapshot --rm-dist --config=.goreleaser-nightly.yml
nightly: nightly:
$(GO_RUN) github.com/goreleaser/goreleaser --snapshot --rm-dist --publish-snapshots $(GO_RUN) github.com/goreleaser/goreleaser --snapshot --rm-dist --publish-snapshots --config=.goreleaser-nightly.yml
release:
$(GO_INSTALL) github.com/goreleaser/goreleaser
git checkout -- go.sum # avoid dirty git repository caused by go install
goreleaser release --rm-dist
clean: clean:
@for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done @for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done