From a0121c8819c1f818a95636c6457b03202539d072 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 23 Jan 2019 14:19:05 -0600 Subject: [PATCH] ci(goreleaser): create a release version of goreleaser Co-authored-by: Luke Morris Co-authored-by: Mark Rushakoff --- .circleci/config.yml | 71 ++++++++++++++++++++++++++++++++--------- .goreleaser-nightly.yml | 65 +++++++++++++++++++++++++++++++++++++ .goreleaser.yml | 14 ++++---- Makefile | 10 ++++-- 4 files changed, 136 insertions(+), 24 deletions(-) create mode 100644 .goreleaser-nightly.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index e739de3524..08f9a2f52b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,14 +37,14 @@ jobs: - restore_cache: name: Restoring GOCACHE keys: - - platform-gocache-{{ .Branch }}-{{ .Revision }} # Matches when retrying a single run. - - platform-gocache-{{ .Branch }}- # Matches a new commit on an existing branch. - - platform-gocache- # Matches a new branch. + - influxdb-gocache-{{ .Branch }}-{{ .Revision }} # Matches when retrying a single run. + - influxdb-gocache-{{ .Branch }}- # Matches a new commit on an existing branch. + - influxdb-gocache- # Matches a new branch. # Populate GOPATH/pkg. - restore_cache: name: Restoring GOPATH/pkg/mod 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 vet - run: make checkfmt @@ -64,13 +64,13 @@ jobs: - save_cache: name: Saving GOCACHE - key: platform-gocache-{{ .Branch }}-{{ .Revision }} + key: influxdb-gocache-{{ .Branch }}-{{ .Revision }} paths: - /tmp/go-cache when: always - save_cache: name: Saving GOPATH/pkg/mod - key: platform-gomod-{{ checksum "go.sum" }} + key: influxdb-gomod-{{ checksum "go.sum" }} paths: - /go/pkg/mod when: always @@ -89,18 +89,18 @@ jobs: - restore_cache: name: Restoring GOCACHE keys: - - platform-gocache- # Just match the most recent Go cache. + - influxdb-gocache- # Just match the most recent Go cache. - restore_cache: name: Restoring GOPATH/pkg/mod 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: name: Restore Yarn package cache keys: - chronograf-npm-packages-{{ checksum "ui/package-lock.json" }} - run: make build - deploy: + deploy-nightly: docker: - image: circleci/golang:1.11-node-browsers environment: @@ -114,11 +114,11 @@ jobs: - restore_cache: name: Restoring GOCACHE keys: - - platform-gocache- # Just match the most recent Go cache. + - influxdb-gocache- # Just match the most recent Go cache. - restore_cache: name: Restoring GOPATH/pkg/mod 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: name: Restore Yarn package cache keys: @@ -127,12 +127,40 @@ jobs: - run: name: "Docker Login" 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: name: "Build 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: version: 2 @@ -153,10 +181,23 @@ workflows: jobs: - gotest - jstest - - deploy: + - deploy-nightly: requires: - gotest - jstest filters: branches: 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]+$/ diff --git a/.goreleaser-nightly.yml b/.goreleaser-nightly.yml new file mode 100644 index 0000000000..d19be31ce5 --- /dev/null +++ b/.goreleaser-nightly.yml @@ -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 diff --git a/.goreleaser.yml b/.goreleaser.yml index d19be31ce5..93718c9227 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,4 @@ -project_name: platform +project_name: influxdb builds: - goos: - linux @@ -39,14 +39,11 @@ archive: - LICENSE - README.md -snapshot: - name_template: 'nightly' - s3: - bucket: dl.influxdata.com region: us-east-1 - folder: "platform/nightlies/" + folder: "influxdb/releases/" dockers: - goos: linux @@ -55,11 +52,14 @@ dockers: - influxd - influx image_templates: - - 'quay.io/influxdb/influx:{{ .Version }}' + - 'quay.io/influxdb/influxdb:{{ .Env.DOCKER_VERSION }}' dockerfile: docker/influxd/Dockerfile extra_files: - docker/influxd/entrypoint.sh # Do not make github 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 diff --git a/Makefile b/Makefile index 6098dfd9b3..b4dc09908e 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ GO_ARGS=-tags '$(GO_TAGS)' # Test vars can be used by all recursive Makefiles export GOOS=$(shell go env GOOS) 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) # 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) @@ -119,10 +120,15 @@ bench: build: all dist: - $(GO_RUN) github.com/goreleaser/goreleaser --snapshot --rm-dist + $(GO_RUN) github.com/goreleaser/goreleaser --snapshot --rm-dist --config=.goreleaser-nightly.yml 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: @for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done