build: set up nightly & tagged release jobs (#188)

This commit is contained in:
Daniel Moran 2021-07-16 17:17:43 -04:00 committed by GitHub
parent a69f06b41b
commit ef4bdcb9b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 224 additions and 45 deletions

View File

@ -37,6 +37,71 @@ workflows:
- linux-arm64
- mac
- windows
release-nightly:
triggers:
- schedule:
cron: "0 5 * * *"
filters:
branches:
only:
- main
jobs:
- lint
- check-openapi
- test:
requires:
- lint
- check-openapi
matrix:
parameters:
executor:
- linux-amd64
- linux-arm64
- mac
- windows
- release:
is-nightly: true
requires:
- test
release-tag:
jobs:
- lint:
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
- check-openapi:
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
- test:
requires:
- lint
- check-openapi
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
matrix:
parameters:
executor:
- linux-amd64
- linux-arm64
- mac
- windows
- release:
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
is-nightly: false
requires:
- test
commands:
setup:
@ -58,6 +123,11 @@ commands:
echo 'export PATH=${GOPATH}/bin:${PATH}' >> $BASH_ENV
mkdir -p ${HOME}/.cache
echo 'export GOCACHE=${HOME}/.cache' >> $BASH_ENV
install-goreleaser:
steps:
- run:
name: Install goreleaser
command: ./scripts/ci/download-goreleaser.sh -b ${GOPATH}/bin v0.165.0
jobs:
lint:
@ -85,7 +155,42 @@ jobs:
steps:
- checkout
- setup
- run: make crossbuild
- install-goreleaser
- run:
name: Cross-build all targets
command: goreleaser build --rm-dist --snapshot
- store_artifacts:
path: dist
release:
parameters:
is-nightly:
type: boolean
executor: linux-amd64
steps:
- checkout
- setup
- run:
name: Import GPG key
command: |
echo -e "$GPG_PRIVATE_KEY" > private.key
gpg --batch --import private.key
- install-goreleaser
- when:
condition: << parameters.is-nightly >>
steps:
- run:
name: Make a pseudo-tag for the nightly build
command: git tag nightly-$(date +%Y-%m-%d)
- run:
name: Publish nightly snapshot release
command: IS_NIGHTLY=1 goreleaser release --rm-dist --skip-validate
- unless:
condition: << parameters.is-nightly >>
steps:
- run:
name: Publish tagged release
command: goreleaser release --rm-dist
- store_artifacts:
path: dist

View File

@ -1,4 +1,9 @@
project_name: influx-cli
# Do not make github release
release:
disable: true
builds:
- id: influx
goos:
@ -17,9 +22,65 @@ builds:
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{if .IsSnapshot}}dev{{else}}{{.Version}}{{end}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
- -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
binary: influx
# Do not make github release
release:
disable: true
nfpms:
- id: influx-cli
formats:
- deb
- rpm
bindir: /usr/bin
conflicts:
- influxdb
overrides:
deb:
replaces:
# Tells the deb system that it's ok for this package to overwrite files from versions of the `influxdb2`
# package prior to 2.0.8. Needed to support installing `influx-cli` next to `influxdb` without upgrading
# the server.
- influxdb2 (<< 2.0.8)
file_name_template: influxdb2-client-{{if index .Env "IS_NIGHTLY"}}nightly{{else}}{{.Version}}{{end}}-{{ .Arch }}
rpm:
conflicts:
# Tells the rpm system that this package can't be installed alongside versions of the `influxdb2` package
# prior to 2.0.8. This is as good as we can do for rpm; there's no equivalent to deb's "replaces" metadata.
- influxdb2 < 2.0.8
replacements:
amd64: x86_64
arm64: aarch64
armhf: armv7hl
file_name_template: influxdb2-client-{{if index .Env "IS_NIGHTLY"}}nightly{{else}}{{.Version}}{{end}}.{{ .Arch }}
vendor: InfluxData
homepage: https://influxdata.com
maintainer: support@influxdata.com
description: CLI for managing resources in InfluxDB v2
license: MIT
archives:
- id: influx-cli
format: tar.gz
format_overrides:
- goos: windows
format: zip
wrap_in_directory: true
name_template: influxdb2-client-{{if index .Env "IS_NIGHTLY"}}nightly{{else}}{{.Version}}{{end}}-{{ .Os }}-{{ .Arch }}
files:
- LICENSE
- README.md
checksum:
name_template: influxdb2-client-{{if index .Env "IS_NIGHTLY"}}nightly{{else}}{{.Version}}{{end}}.sha256
algorithm: sha256
signs:
- signature: "${artifact}.asc"
cmd: gpg
args: [ --passphrase, "{{.Env.PASSPHRASE}}", --pinentry-mode=loopback, --batch, --armor, --detach-sign, "${artifact}"]
artifacts: all
blobs:
- provider: s3
bucket: dl.influxdata.com
region: us-east-1
folder: '{{if index .Env "IS_NIGHTLY"}}platform/nightlies/{{else}}influxdb/releases/{{end}}'

44
CHANGELOG.md Normal file
View File

@ -0,0 +1,44 @@
## v2.1.0 [unreleased]
### New Repository
This is the initial release of the `influx` CLI from the [`influxdata/influx-cli`](https://github.com/influxdata/influx-cli/)
GitHub repository.
### Breaking Changes
#### `influx write` skip-header parsing
The `write` command no longer supports `--skipHeader` as short-hand for `--skipHeader 1`. This change was made to
simplify our CLI parser.
#### Stricter input validation for template-related commands
The `apply`, `export`, and `stacks` commands now raise errors when CLI options fail to parse instead of silently
discarding bad inputs. This change was made to help users debug when their commands fail to execute as expected.
#### Server-side template summarization & validation
The `template` and `template validate` commands now use an API request to the server to perform their logic,
instead of performing the work on the client-side. Offline summarization & validation is no longer supported.
This change was made to avoid significant code duplication between `influxdb` and `influx-cli`, and to allow server-
side template logic to evolve without requiring coordinated CLI changes.
### Features
1. [33](https://github.com/influxdata/influx-cli/pull/33): Add global `--http-debug` flag to help inspect communication with InfluxDB servers.
1. [52](https://github.com/influxdata/influx-cli/pull/52): Add `bucket-schema` commands to manage explicit measurement schemas in InfluxDB Cloud.
1. [52](https://github.com/influxdata/influx-cli/pull/52): Update `bucket create` to allow setting a schema type.
1. [52](https://github.com/influxdata/influx-cli/pull/52): Update `bucket list` to display schema types.
1. [116](https://github.com/influxdata/influx-cli/pull/116): Reimplement `backup` to support downloading embedded SQL store from InfluxDB v2.1.x.
1. [116](https://github.com/influxdata/influx-cli/pull/116): Add `--compression` flag to `backup` to support enabling/disabling GZIP compression of downloaded files.
1. [121](https://github.com/influxdata/influx-cli/pull/121): Reimplement `restore` to support uploading embedded SQL store from InfluxDB v2.1.x.
1. [191](https://github.com/influxdata/influx-cli/pull/191): Add `--password` flag to `user password` command to allow bypassing interactive prompt.
### Bug Fixes
1. [35](https://github.com/influxdata/influx-cli/pull/35): Fix interactive password collection & color rendering in PowerShell.
1. [97](https://github.com/influxdata/influx-cli/pull/97): `org members list` no longer hangs on organizations with more than 10 members.
1. [109](https://github.com/influxdata/influx-cli/pull/109): Detect & warn when inputs to `write` contain standalone CR characters.
1. [122](https://github.com/influxdata/influx-cli/pull/122): `dashboards` command now accepts `--org` flag, or falls back to default org in config.
1. [140](https://github.com/influxdata/influx-cli/pull/140): Return a consistent error when responses fail to decode, with hints for OSS- our Cloud-only commands.

View File

@ -4,17 +4,14 @@ export GOOS=$(shell go env GOOS)
export GOARCH=$(shell go env GOARCH)
export GOVERSION=$(shell go list -m -f '{{.GoVersion}}')
ifeq ($(OS), Windows_NT)
VERSION := $(shell git describe --exact-match --tags 2>nil)
else
VERSION := $(shell git describe --exact-match --tags 2>/dev/null)
endif
COMMIT := $(shell git rev-parse --short HEAD)
LDFLAGS := $(LDFLAGS) -X main.date=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := $(LDFLAGS) -X main.commit=$(COMMIT) -X main.date=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
ifdef VERSION
LDFLAGS += -X main.version=$(VERSION)
endif
ifdef COMMIT
LDFLAGS += -X main.commit=$(COMMIT)
endif
export GO_BUILD=go build -ldflags "$(LDFLAGS)"
SOURCES := $(shell find . -name '*.go' -not -name '*_test.go') go.mod go.sum
@ -46,26 +43,6 @@ influx: bin/$(GOOS)/influx
vendor: go.mod go.sum
go mod vendor
GORELEASER_VERSION := v0.165.0
bin/goreleaser-$(GORELEASER_VERSION):
./etc/download-goreleaser.sh $(GORELEASER_VERSION)
goreleaser: bin/goreleaser-$(GORELEASER_VERSION)
build: bin/goreleaser-$(GORELEASER_VERSION)
ifdef VERSION
GORELEASER_CURRENT_TAG=$(VERSION) bin/goreleaser-$(GORELEASER_VERSION) build --rm-dist --single-target
else
bin/goreleaser-$(GORELEASER_VERSION) build --rm-dist --single-target --snapshot
endif
crossbuild: bin/goreleaser-$(GORELEASER_VERSION)
ifdef VERSION
GORELEASER_CURRENT_TAG=$(VERSION) bin/goreleaser-$(GORELEASER_VERSION) build --rm-dist
else
bin/goreleaser-$(GORELEASER_VERSION) build --snapshot --rm-dist
endif
clean:
$(RM) -r bin
$(RM) -r vendor
@ -98,4 +75,4 @@ test-race:
$(GO_TEST) -v -race -count=1 $(GO_TEST_PATHS)
### List of all targets that don't produce a file
.PHONY: influx openapi fmt build crossbuild goreleaser checkfmt checktidy staticcheck vet mock test test-race
.PHONY: influx openapi fmt checkfmt checktidy staticcheck vet mock test test-race

View File

@ -2,25 +2,17 @@
CLI for managing resources in InfluxDB v2
## Status
## Motivation
This is a work-in-progress effort to decouple the `influx` CLI from the OSS `influxdb` codebase.
Our goals are to:
This repository decouples the `influx` CLI from the OSS `influxdb` codebase. Our goals are to:
1. Make it easier to keep the CLI up-to-date with InfluxDB Cloud API changes
2. Enable faster turn-around on fixes/features that only affect the CLI
3. Allow the CLI to be built & released for a wider range of platforms than the server can support
## Building
### Development build
Run `make` or `make influx` to build the CLI. The output binary will be written to `bin/$(GOOS)/influx`.
### Release build
We use [`goreleaser`](https://goreleaser.com/) to manage cross-building the CLI for release. Run `make build`
to build the CLI with release settings for your current `GOOS` and `GOARCH`. Run `make crossbuild` to build
the CLI for all `GOOS`/`GOARCH` pairs supported by the CLI. The output binary/binaries will be written under
`dist/influx_${GOOS}_${GOARCH}/`.
### Regenerating OpenAPI client
We use [`OpenAPITools/openapi-generator`](https://github.com/OpenAPITools/openapi-generator) to generate

View File

@ -63,8 +63,8 @@ execute() {
if [ "$OS" = "windows" ]; then
binexe="${binexe}.exe"
fi
install "${srcdir}/${binexe}" "${BINDIR}/${binexe}-${TAG}"
log_info "installed ${BINDIR}/${binexe}-${TAG}"
install "${srcdir}/${binexe}" "${BINDIR}/${binexe}"
log_info "installed ${BINDIR}/${binexe}"
done
rm -rf "${tmpdir}"
}