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.
This commit is contained in:
@ -26,13 +26,20 @@ executors:
|
|||||||
resource_class: windows.medium
|
resource_class: windows.medium
|
||||||
shell: bash.exe -eo pipefail
|
shell: bash.exe -eo pipefail
|
||||||
|
|
||||||
|
|
||||||
|
release_filter: &release_filter
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
|
||||||
|
branches:
|
||||||
|
ignore: /.*/
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
build-and-test:
|
build-and-test:
|
||||||
jobs:
|
jobs:
|
||||||
- lint
|
- lint
|
||||||
- check-openapi
|
- check-openapi
|
||||||
- build-all
|
|
||||||
- test-race:
|
- test-race:
|
||||||
name: test-linux-amd64
|
name: test-linux-amd64
|
||||||
- test-build:
|
- test-build:
|
||||||
@ -70,6 +77,24 @@ workflows:
|
|||||||
arch: amd64
|
arch: amd64
|
||||||
requires:
|
requires:
|
||||||
- test-build-amd64-windows
|
- test-build-amd64-windows
|
||||||
|
- build:
|
||||||
|
name: build-<< matrix.os >>-<< matrix.arch >>
|
||||||
|
matrix:
|
||||||
|
parameters:
|
||||||
|
os: [ linux, darwin, windows ]
|
||||||
|
arch: [ amd64, arm64 ]
|
||||||
|
exclude:
|
||||||
|
- os: darwin
|
||||||
|
arch: arm64
|
||||||
|
- os: windows
|
||||||
|
arch: arm64
|
||||||
|
- build-packages:
|
||||||
|
sign: false
|
||||||
|
requires:
|
||||||
|
- build-darwin-amd64
|
||||||
|
- build-linux-amd64
|
||||||
|
- build-linux-arm64
|
||||||
|
- build-windows-amd64
|
||||||
release-nightly:
|
release-nightly:
|
||||||
triggers:
|
triggers:
|
||||||
- schedule:
|
- schedule:
|
||||||
@ -119,6 +144,24 @@ workflows:
|
|||||||
arch: amd64
|
arch: amd64
|
||||||
requires:
|
requires:
|
||||||
- test-build-amd64-windows
|
- test-build-amd64-windows
|
||||||
|
- build:
|
||||||
|
name: build-<< matrix.os >>-<< matrix.arch >>
|
||||||
|
matrix:
|
||||||
|
parameters:
|
||||||
|
os: [ linux, darwin, windows ]
|
||||||
|
arch: [ amd64, arm64 ]
|
||||||
|
exclude:
|
||||||
|
- os: darwin
|
||||||
|
arch: arm64
|
||||||
|
- os: windows
|
||||||
|
arch: arm64
|
||||||
|
- build-packages:
|
||||||
|
sign: true
|
||||||
|
requires:
|
||||||
|
- build-darwin-amd64
|
||||||
|
- build-linux-amd64
|
||||||
|
- build-linux-arm64
|
||||||
|
- build-windows-amd64
|
||||||
- release:
|
- release:
|
||||||
is-nightly: true
|
is-nightly: true
|
||||||
requires:
|
requires:
|
||||||
@ -129,39 +172,20 @@ workflows:
|
|||||||
- test-linux-arm64
|
- test-linux-arm64
|
||||||
- test-mac
|
- test-mac
|
||||||
- test-windows
|
- test-windows
|
||||||
|
- build-packages
|
||||||
release-tag:
|
release-tag:
|
||||||
jobs:
|
jobs:
|
||||||
- changelog:
|
- changelog:
|
||||||
filters:
|
<<: *release_filter
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
|
|
||||||
- lint:
|
- lint:
|
||||||
filters:
|
<<: *release_filter
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
|
|
||||||
- check-openapi:
|
- check-openapi:
|
||||||
filters:
|
<<: *release_filter
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
|
|
||||||
- test-race:
|
- test-race:
|
||||||
name: test-linux-amd64
|
name: test-linux-amd64
|
||||||
filters:
|
<<: *release_filter
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
|
|
||||||
- test-build:
|
- test-build:
|
||||||
filters:
|
<<: *release_filter
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
|
|
||||||
matrix:
|
matrix:
|
||||||
parameters:
|
parameters:
|
||||||
os: [ linux, darwin, windows ]
|
os: [ linux, darwin, windows ]
|
||||||
@ -176,47 +200,51 @@ workflows:
|
|||||||
- os: linux
|
- os: linux
|
||||||
arch: amd64
|
arch: amd64
|
||||||
- test-prebuilt:
|
- test-prebuilt:
|
||||||
|
<<: *release_filter
|
||||||
name: test-linux-arm64
|
name: test-linux-arm64
|
||||||
filters:
|
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
|
|
||||||
executor: linux-arm64
|
executor: linux-arm64
|
||||||
os: linux
|
os: linux
|
||||||
arch: arm64
|
arch: arm64
|
||||||
requires:
|
requires:
|
||||||
- test-build-arm64-linux
|
- test-build-arm64-linux
|
||||||
- test-prebuilt:
|
- test-prebuilt:
|
||||||
|
<<: *release_filter
|
||||||
name: test-mac
|
name: test-mac
|
||||||
filters:
|
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
|
|
||||||
executor: mac
|
executor: mac
|
||||||
os: darwin
|
os: darwin
|
||||||
arch: amd64
|
arch: amd64
|
||||||
requires:
|
requires:
|
||||||
- test-build-amd64-darwin
|
- test-build-amd64-darwin
|
||||||
- test-prebuilt:
|
- test-prebuilt:
|
||||||
|
<<: *release_filter
|
||||||
name: test-windows
|
name: test-windows
|
||||||
filters:
|
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
|
|
||||||
executor: windows
|
executor: windows
|
||||||
os: windows
|
os: windows
|
||||||
arch: amd64
|
arch: amd64
|
||||||
requires:
|
requires:
|
||||||
- test-build-amd64-windows
|
- test-build-amd64-windows
|
||||||
|
- build:
|
||||||
|
<<: *release_filter
|
||||||
|
name: build-<< matrix.os >>-<< matrix.arch >>
|
||||||
|
matrix:
|
||||||
|
parameters:
|
||||||
|
os: [ linux, darwin, windows ]
|
||||||
|
arch: [ amd64, arm64 ]
|
||||||
|
exclude:
|
||||||
|
- os: darwin
|
||||||
|
arch: arm64
|
||||||
|
- os: windows
|
||||||
|
arch: arm64
|
||||||
|
- build-packages:
|
||||||
|
<<: *release_filter
|
||||||
|
sign: true
|
||||||
|
requires:
|
||||||
|
- build-darwin-amd64
|
||||||
|
- build-linux-amd64
|
||||||
|
- build-linux-arm64
|
||||||
|
- build-windows-amd64
|
||||||
- release:
|
- release:
|
||||||
filters:
|
<<: *release_filter
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
||||||
tags:
|
|
||||||
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta)[0-9]+)?$/
|
|
||||||
is-nightly: false
|
is-nightly: false
|
||||||
requires:
|
requires:
|
||||||
- changelog
|
- changelog
|
||||||
@ -226,6 +254,7 @@ workflows:
|
|||||||
- test-linux-arm64
|
- test-linux-arm64
|
||||||
- test-mac
|
- test-mac
|
||||||
- test-windows
|
- test-windows
|
||||||
|
- build-packages
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
setup:
|
setup:
|
||||||
@ -247,11 +276,6 @@ commands:
|
|||||||
echo 'export PATH=${GOPATH}/bin:${PATH}' >> $BASH_ENV
|
echo 'export PATH=${GOPATH}/bin:${PATH}' >> $BASH_ENV
|
||||||
mkdir -p ${HOME}/.cache
|
mkdir -p ${HOME}/.cache
|
||||||
echo 'export GOCACHE=${HOME}/.cache' >> $BASH_ENV
|
echo 'export GOCACHE=${HOME}/.cache' >> $BASH_ENV
|
||||||
install-goreleaser:
|
|
||||||
steps:
|
|
||||||
- run:
|
|
||||||
name: Install goreleaser
|
|
||||||
command: ./scripts/ci/download-goreleaser.sh v1.14.0
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
@ -289,23 +313,6 @@ jobs:
|
|||||||
command: git submodule update --init --recursive
|
command: git submodule update --init --recursive
|
||||||
- run: make checkopenapi
|
- run: make checkopenapi
|
||||||
|
|
||||||
build-all:
|
|
||||||
executor: linux-amd64
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- setup
|
|
||||||
- install-goreleaser
|
|
||||||
- run:
|
|
||||||
name: Make a pseudo-tag for the snapshot build
|
|
||||||
command: |
|
|
||||||
latest_tag=$(git describe --tags --abbrev=0)
|
|
||||||
git tag ${latest_tag}+SNAPSHOT.$(git rev-parse --short HEAD)
|
|
||||||
- run:
|
|
||||||
name: Cross-build all targets
|
|
||||||
command: IS_SNAPSHOT=1 goreleaser release --rm-dist --skip-publish --skip-sign --skip-validate
|
|
||||||
- store_artifacts:
|
|
||||||
path: dist
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
parameters:
|
parameters:
|
||||||
is-nightly:
|
is-nightly:
|
||||||
@ -315,38 +322,25 @@ jobs:
|
|||||||
- checkout
|
- checkout
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: .
|
at: .
|
||||||
- setup
|
|
||||||
- run:
|
- run:
|
||||||
name: Import GPG key
|
|
||||||
command: |
|
command: |
|
||||||
echo -e "$GPG_PRIVATE_KEY" > private.key
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
gpg --batch --import private.key
|
sudo apt-get update -y
|
||||||
- install-goreleaser
|
sudo apt-get install -y awscli gnupg
|
||||||
|
|
||||||
|
gpg --import --batch \<<<"${GPG_PRIVATE_KEY//$'\\n'/$'\n'}"
|
||||||
- when:
|
- when:
|
||||||
condition: << parameters.is-nightly >>
|
condition: << parameters.is-nightly >>
|
||||||
steps:
|
steps:
|
||||||
- run:
|
- run:
|
||||||
name: Make a pseudo-tag for the nightly build
|
command: .circleci/scripts/upload-artifacts nightly
|
||||||
command: |
|
|
||||||
latest_tag=$(git describe --tags --abbrev=0)
|
|
||||||
git tag ${latest_tag}+nightly.$(date +%Y.%m.%d)
|
|
||||||
- run:
|
|
||||||
name: Publish nightly snapshot release
|
|
||||||
command: IS_NIGHTLY=1 goreleaser release --rm-dist
|
|
||||||
- unless:
|
- unless:
|
||||||
condition: << parameters.is-nightly >>
|
condition: << parameters.is-nightly >>
|
||||||
steps:
|
steps:
|
||||||
- run:
|
- run:
|
||||||
name: Publish tagged release
|
command: .circleci/scripts/upload-artifacts release
|
||||||
command: goreleaser release --rm-dist
|
|
||||||
- run:
|
|
||||||
command: |
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install awscli
|
|
||||||
.circleci/scripts/upload-latest-artifacts
|
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: dist
|
path: packages
|
||||||
|
|
||||||
test-build:
|
test-build:
|
||||||
executor: cross-builder
|
executor: cross-builder
|
||||||
@ -403,6 +397,68 @@ jobs:
|
|||||||
- store_test_results:
|
- store_test_results:
|
||||||
path: ./test-results
|
path: ./test-results
|
||||||
|
|
||||||
|
build:
|
||||||
|
executor: cross-builder
|
||||||
|
parameters:
|
||||||
|
os:
|
||||||
|
type: string
|
||||||
|
arch:
|
||||||
|
type: string
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Build Binaries
|
||||||
|
command: |
|
||||||
|
GOOS=<<parameters.os>> GOARCH=<<parameters.arch>> make
|
||||||
|
- store_artifacts:
|
||||||
|
path: bin
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: .
|
||||||
|
paths: bin
|
||||||
|
|
||||||
|
build-packages:
|
||||||
|
docker:
|
||||||
|
- image: ubuntu:latest
|
||||||
|
resource_class: small
|
||||||
|
parameters:
|
||||||
|
sign:
|
||||||
|
type: boolean
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: /tmp/workspace
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Build Packages
|
||||||
|
command: |
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update
|
||||||
|
apt-get install --yes \
|
||||||
|
build-essential \
|
||||||
|
git \
|
||||||
|
gnupg \
|
||||||
|
rpm \
|
||||||
|
ruby-dev
|
||||||
|
gem install fpm
|
||||||
|
|
||||||
|
if [[ "<< parameters.sign >>" == "true" ]]
|
||||||
|
then
|
||||||
|
gpg --import --batch \<<<"${GPG_PRIVATE_KEY//$'\\n'/$'\n'}"
|
||||||
|
|
||||||
|
export SIGN_PACKAGES=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p packages
|
||||||
|
OS=darwin ARCH=amd64 scripts/ci/build-packages /tmp/workspace/bin/darwin/amd64/influx "${PWD}/packages"
|
||||||
|
OS=linux ARCH=amd64 scripts/ci/build-packages /tmp/workspace/bin/linux/amd64/influx "${PWD}/packages"
|
||||||
|
OS=linux ARCH=arm64 scripts/ci/build-packages /tmp/workspace/bin/linux/arm64/influx "${PWD}/packages"
|
||||||
|
OS=windows ARCH=amd64 scripts/ci/build-packages /tmp/workspace/bin/windows/amd64/influx "${PWD}/packages"
|
||||||
|
- store_artifacts:
|
||||||
|
path: packages/
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: .
|
||||||
|
paths:
|
||||||
|
- packages
|
||||||
|
|
||||||
changelog:
|
changelog:
|
||||||
docker:
|
docker:
|
||||||
- image: quay.io/influxdb/changelogger:a20523cf8594eb93920e74d0189d6602a76a6146
|
- image: quay.io/influxdb/changelogger:a20523cf8594eb93920e74d0189d6602a76a6146
|
||||||
|
52
.circleci/scripts/upload-artifacts
Executable file
52
.circleci/scripts/upload-artifacts
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -o errexit \
|
||||||
|
-o nounset \
|
||||||
|
-o pipefail
|
||||||
|
|
||||||
|
# Determine if "${CIRCLE_TAG}" matches the semantic version regex. Otherwise,
|
||||||
|
# assume that "${CIRCLE_TAG}" is not intended to tag a release. The regex is
|
||||||
|
# permissive of what occurs after the semantic version. This allows for
|
||||||
|
# alphas, betas, and release candidates.
|
||||||
|
if [[ "${CIRCLE_TAG:-}" =~ ^v[0-9]+.[0-9]+.[0-9]+ ]]
|
||||||
|
then
|
||||||
|
VERSION_REGEX="${CIRCLE_TAG/#v/}"
|
||||||
|
else
|
||||||
|
# When "${CIRCLE_TAG}" cannot be used to construct the package version,
|
||||||
|
# use "${CIRCLE_SHA1}". Since "${CIRCLE_SHA1}" can start with an alpha
|
||||||
|
# (non-numeric) character, prefix it with "2.x-".
|
||||||
|
VERSION_REGEX="2.x[-_]${CIRCLE_SHA1:0:8}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
REGEX='^packages/influxdb2-client[-_]'"${VERSION_REGEX}"'(.*)'
|
||||||
|
|
||||||
|
for target in packages/*
|
||||||
|
do
|
||||||
|
if [[ "${target}" =~ ${REGEX} ]]
|
||||||
|
then
|
||||||
|
# After renaming the artifact to the "latest/nightly" version, append
|
||||||
|
# the artifact to the `invalidations` file. Since `dl.influxdata.com`
|
||||||
|
# contains many 100GBs, this should only invalidate artifacts
|
||||||
|
# that have changed.
|
||||||
|
case ${1} in
|
||||||
|
nightly)
|
||||||
|
mv -v "${target}" "packages/influxdb2-client-nightly${BASH_REMATCH[1]}"
|
||||||
|
printf '/platform/nightlies/influxdb2-client-nightly%s\n' "${BASH_REMATCH[1]}" >>invalidations
|
||||||
|
;;
|
||||||
|
release)
|
||||||
|
cp -v "${target}" "packages/influxdb2-client-latest${BASH_REMATCH[1]}"
|
||||||
|
printf '/influxdb/releases/influxdb2-client-latest%s\n' "${BASH_REMATCH[1]}" >>invalidations
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
case ${1} in
|
||||||
|
nightly)
|
||||||
|
aws s3 sync packages s3://dl.influxdata.com/platform/nightlies
|
||||||
|
;;
|
||||||
|
release)
|
||||||
|
aws s3 sync packages s3://dl.influxdata.com/influxdb/releases
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
aws cloudfront create-invalidation --distribution-id "${AWS_DISTRIBUTION_ID}" --paths $(<invalidations)
|
@ -1,26 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -o errexit \
|
|
||||||
-o nounset \
|
|
||||||
-o pipefail
|
|
||||||
|
|
||||||
REGEX='^dist/influxdb2-client-([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)(.*)'
|
|
||||||
|
|
||||||
for target in dist/*
|
|
||||||
do
|
|
||||||
# `dist` contains more than just the packages. This will match
|
|
||||||
# only the artifacts with a "package" filename.
|
|
||||||
if [[ "${target}" =~ ${REGEX} ]]
|
|
||||||
then
|
|
||||||
mv -v "${target}" "dist/influxdb2-client-latest${BASH_REMATCH[2]}"
|
|
||||||
|
|
||||||
# After renaming the artifact to the "lastest" version, append the
|
|
||||||
# artifact to the `invalidations` file. Since `dl.influxdata.com`
|
|
||||||
# contains many 100GBs, this should only invalidate artifacts
|
|
||||||
# that have changed.
|
|
||||||
printf '/influxdb/releases/influxdb2-client-latest%s\n' "${BASH_REMATCH[2]}" >>invalidations
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
aws s3 sync dist 's3://dl.influxdata.com/influxdb/releases/'
|
|
||||||
|
|
||||||
aws cloudfront create-invalidation --distribution-id "${AWS_DISTRIBUTION_ID}" --paths $(<invalidations)
|
|
@ -1,93 +0,0 @@
|
|||||||
project_name: influx-cli
|
|
||||||
|
|
||||||
# Do not make github release or generate a changelog
|
|
||||||
release:
|
|
||||||
disable: true
|
|
||||||
changelog:
|
|
||||||
skip: true
|
|
||||||
|
|
||||||
builds:
|
|
||||||
- id: influx
|
|
||||||
goos:
|
|
||||||
- linux
|
|
||||||
- darwin
|
|
||||||
- windows
|
|
||||||
goarch:
|
|
||||||
- amd64
|
|
||||||
- arm64
|
|
||||||
ignore:
|
|
||||||
- goos: darwin
|
|
||||||
goarch: arm64
|
|
||||||
- goos: windows
|
|
||||||
goarch: arm64
|
|
||||||
main: ./cmd/influx
|
|
||||||
env:
|
|
||||||
- CGO_ENABLED=0
|
|
||||||
flags:
|
|
||||||
- -tags={{if eq .Os "windows"}}timetzdata{{end}}
|
|
||||||
ldflags:
|
|
||||||
- -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}
|
|
||||||
binary: influx
|
|
||||||
|
|
||||||
nfpms:
|
|
||||||
- id: influx-cli
|
|
||||||
package_name: influxdb2-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.1.0. Needed to support installing `influxdb2-cli` next to `influxdb2` without upgrading
|
|
||||||
# the server.
|
|
||||||
- influxdb2 (<< 2.1.0)
|
|
||||||
file_name_template: influxdb2-client-{{if index .Env "IS_SNAPSHOT"}}SNAPSHOT{{else 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.1.0. This is as good as we can do for rpm; there's no equivalent to deb's "replaces" metadata.
|
|
||||||
- influxdb2 < 2.1.0
|
|
||||||
replacements:
|
|
||||||
amd64: x86_64
|
|
||||||
arm64: aarch64
|
|
||||||
armhf: armv7hl
|
|
||||||
file_name_template: influxdb2-client-{{if index .Env "IS_SNAPSHOT"}}SNAPSHOT{{else 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_SNAPSHOT"}}SNAPSHOT{{else if index .Env "IS_NIGHTLY"}}nightly{{else}}{{.Version}}{{end}}-{{ .Os }}-{{ .Arch }}
|
|
||||||
files:
|
|
||||||
- LICENSE
|
|
||||||
- README.md
|
|
||||||
|
|
||||||
checksum:
|
|
||||||
name_template: influxdb2-client-{{if index .Env "IS_SNAPSHOT"}}SNAPSHOT{{else 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}}'
|
|
||||||
extra_files:
|
|
||||||
- glob: ./changelog_artifacts/CHANGELOG*.md
|
|
16
Makefile
16
Makefile
@ -1,9 +1,19 @@
|
|||||||
|
# TOP is the directory where Makefile lives (i.e. top-level project).
|
||||||
|
# This must be before any includes.
|
||||||
|
TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
|
include $(TOP)/support.mk
|
||||||
|
|
||||||
### Environment setup
|
### Environment setup
|
||||||
export GOPATH=$(shell go env GOPATH)
|
export GOPATH=$(shell go env GOPATH)
|
||||||
export GOOS=$(shell go env GOOS)
|
export GOOS=$(shell go env GOOS)
|
||||||
export GOARCH=$(shell go env GOARCH)
|
export GOARCH=$(shell go env GOARCH)
|
||||||
export GOVERSION=$(shell go list -m -f '{{.GoVersion}}')
|
export GOVERSION=$(shell go list -m -f '{{.GoVersion}}')
|
||||||
|
|
||||||
|
ifeq ($(GOOS),windows)
|
||||||
|
GOTAGS += timetzdata,
|
||||||
|
endif
|
||||||
|
|
||||||
LDFLAGS := $(LDFLAGS) -X main.date=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
|
LDFLAGS := $(LDFLAGS) -X main.date=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||||
|
|
||||||
ifdef VERSION
|
ifdef VERSION
|
||||||
@ -20,7 +30,7 @@ ifneq ($(GCFLAGS),)
|
|||||||
GCFLAGS := -gcflags "$(GCFLAGS)"
|
GCFLAGS := -gcflags "$(GCFLAGS)"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
export GO_BUILD=go build $(GCFLAGS) -ldflags "$(LDFLAGS)"
|
export GO_BUILD=go build $(call with-param,-tags ,$(GOTAGS)) $(GCFLAGS) -ldflags "$(LDFLAGS)"
|
||||||
|
|
||||||
# SOURCES are the files that affect building the main binary.
|
# SOURCES are the files that affect building the main binary.
|
||||||
SOURCES := $(shell find . -name '*.go' -not -name '*_test.go') go.mod go.sum
|
SOURCES := $(shell find . -name '*.go' -not -name '*_test.go') go.mod go.sum
|
||||||
@ -45,11 +55,11 @@ fmt: $(FMT_FILES)
|
|||||||
# Format imports.
|
# Format imports.
|
||||||
go run github.com/daixiang0/gci -w $^
|
go run github.com/daixiang0/gci -w $^
|
||||||
|
|
||||||
bin/$(GOOS)/influx: $(SOURCES)
|
bin/$(GOOS)/$(GOARCH)/influx: $(SOURCES)
|
||||||
CGO_ENABLED=0 $(GO_BUILD) -o $@ ./cmd/$(shell basename "$@")
|
CGO_ENABLED=0 $(GO_BUILD) -o $@ ./cmd/$(shell basename "$@")
|
||||||
|
|
||||||
.DEFAULT_GOAL := influx
|
.DEFAULT_GOAL := influx
|
||||||
influx: bin/$(GOOS)/influx
|
influx: bin/$(GOOS)/$(GOARCH)/influx
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -r bin
|
$(RM) -r bin
|
||||||
|
151
scripts/ci/build-packages
Executable file
151
scripts/ci/build-packages
Executable file
@ -0,0 +1,151 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -o errexit \
|
||||||
|
-o nounset \
|
||||||
|
-o pipefail
|
||||||
|
|
||||||
|
PKG_BIN_PATH="${1}"
|
||||||
|
PKG_OUT_PATH="${2}"
|
||||||
|
|
||||||
|
# Determine if "${CIRCLE_TAG}" matches the semantic version regex. Otherwise,
|
||||||
|
# assume that "${CIRCLE_TAG}" is not intended to tag a release. The regex is
|
||||||
|
# permissive of what occurs after the semantic version. This allows for
|
||||||
|
# alphas, betas, and release candidates.
|
||||||
|
if [[ "${CIRCLE_TAG:-}" =~ ^v[0-9]+.[0-9]+.[0-9]+ ]]
|
||||||
|
then
|
||||||
|
VERSION="${CIRCLE_TAG/#v/}"
|
||||||
|
RELEASE=1
|
||||||
|
else
|
||||||
|
# When "${CIRCLE_TAG}" cannot be used to construct the package version,
|
||||||
|
# use "${CIRCLE_SHA1}". Since "${CIRCLE_SHA1}" can start with an alpha
|
||||||
|
# (non-numeric) character, prefix it with "2.x-".
|
||||||
|
VERSION="2.x-${CIRCLE_SHA1:0:8}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_archive()
|
||||||
|
{
|
||||||
|
local workspace="$(mktemp -d)"
|
||||||
|
|
||||||
|
cp LICENSE README.md "${PKG_BIN_PATH}" "${workspace}"
|
||||||
|
|
||||||
|
pushd "${workspace}"
|
||||||
|
|
||||||
|
local target="${PKG_OUT_PATH}/influxdb2-client-${VERSION}_${OS}_${ARCH}.tar.gz"
|
||||||
|
|
||||||
|
tar -czf "${target}" .
|
||||||
|
|
||||||
|
# generate signature and checksums
|
||||||
|
generate_signature "${target}"
|
||||||
|
generate_checksums "${target}"
|
||||||
|
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
build_package_linux()
|
||||||
|
{
|
||||||
|
local workspace="$(mktemp -d)"
|
||||||
|
|
||||||
|
pushd "${workspace}"
|
||||||
|
|
||||||
|
mkdir -p fs/usr/bin
|
||||||
|
|
||||||
|
# copies binaries into package file system
|
||||||
|
cp "${PKG_BIN_PATH}" fs/usr/bin
|
||||||
|
|
||||||
|
fpm_wrapper deb
|
||||||
|
fpm_wrapper rpm
|
||||||
|
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
fpm_wrapper()
|
||||||
|
{
|
||||||
|
# "${ARCH}" matches Debian architecture names. Therefore, when building an
|
||||||
|
# RPM, it needs to be converted into a Redhat architecture name. Currently,
|
||||||
|
# influxdb-cli only supports "x86_64" and "aarch64".
|
||||||
|
if [[ "${1}" == rpm ]]
|
||||||
|
then
|
||||||
|
case ${ARCH} in
|
||||||
|
amd64)
|
||||||
|
ARCH=x86_64
|
||||||
|
;;
|
||||||
|
arm64)
|
||||||
|
ARCH=aarch64
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
case ${1} in
|
||||||
|
rpm)
|
||||||
|
REPLACES='influxdb < 2.1.0'
|
||||||
|
;;
|
||||||
|
deb)
|
||||||
|
REPLACES='influxdb (<< 2.1.0)'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
fpm \
|
||||||
|
--log error \
|
||||||
|
`# package description` \
|
||||||
|
--name influxdb2-client \
|
||||||
|
--vendor InfluxData \
|
||||||
|
--description 'CLI for managing resources in InfluxDB v2' \
|
||||||
|
--url https://influxdata.com \
|
||||||
|
--maintainer support@influxdb.com \
|
||||||
|
--license MIT \
|
||||||
|
--replaces "${REPLACES}" \
|
||||||
|
`# package configuration` \
|
||||||
|
--input-type dir \
|
||||||
|
--output-type "${1}" \
|
||||||
|
--architecture "${ARCH}" \
|
||||||
|
--version "${VERSION}" \
|
||||||
|
--iteration 1 \
|
||||||
|
`# package options` \
|
||||||
|
--chdir fs/ \
|
||||||
|
--package "${PKG_OUT_PATH}/"
|
||||||
|
|
||||||
|
# `goreleaser` removed the "package revision" from the package filename.
|
||||||
|
# Since the automation is based on the packages created by `goreleaser`,
|
||||||
|
# this will also remove the "package revision" to
|
||||||
|
# maintain compatibility.
|
||||||
|
case ${1} in
|
||||||
|
deb)
|
||||||
|
mv "${PKG_OUT_PATH}/influxdb2-client_${VERSION}-1_${ARCH}.deb" \
|
||||||
|
"${PKG_OUT_PATH}/influxdb2-client-${VERSION}-${ARCH}.deb"
|
||||||
|
|
||||||
|
# generate signature and checksums
|
||||||
|
generate_signature "${PKG_OUT_PATH}/influxdb2-client-${VERSION}-${ARCH}.deb"
|
||||||
|
generate_checksums "${PKG_OUT_PATH}/influxdb2-client-${VERSION}-${ARCH}.deb"
|
||||||
|
;;
|
||||||
|
rpm)
|
||||||
|
mv "${PKG_OUT_PATH}/influxdb2-client-${VERSION//-/_}-1.${ARCH}.rpm" \
|
||||||
|
"${PKG_OUT_PATH}/influxdb2-client-${VERSION//-/_}.${ARCH}.rpm"
|
||||||
|
|
||||||
|
# generate signature and checksums
|
||||||
|
generate_checksums "${PKG_OUT_PATH}/influxdb2-client-${VERSION//-/_}.${ARCH}.rpm"
|
||||||
|
generate_signature "${PKG_OUT_PATH}/influxdb2-client-${VERSION//-/_}.${ARCH}.rpm"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_signature()
|
||||||
|
{
|
||||||
|
if [[ ( "${SIGN_PACKAGES:-}" ) ]]
|
||||||
|
then
|
||||||
|
gpg --passphrase "${PASSPHRASE}" --pinentry-mode=loopback --batch --armor --detach-sign "${1}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_checksums()
|
||||||
|
{
|
||||||
|
md5sum "${1}" >"${1}.md5"
|
||||||
|
sha256sum "${1}" >"${1}.sha256"
|
||||||
|
}
|
||||||
|
|
||||||
|
case ${OS} in
|
||||||
|
linux)
|
||||||
|
build_archive
|
||||||
|
build_package_linux
|
||||||
|
;;
|
||||||
|
darwin)
|
||||||
|
build_archive
|
||||||
|
;;
|
||||||
|
esac
|
@ -1,25 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -o nounset \
|
|
||||||
-o errexit \
|
|
||||||
-o pipefail
|
|
||||||
|
|
||||||
case ${1} in
|
|
||||||
v1.14.0)
|
|
||||||
CHECKSUM=5f832026b88340318caaec5bd985951e7d363bd248bf49f25239ebb802304bcb
|
|
||||||
;;
|
|
||||||
v1.13.1)
|
|
||||||
CHECKSUM=136fecfb2e2f3a7965274ad5e2571985d8b2fa724b6536874f082e4b0bb9f344
|
|
||||||
;;
|
|
||||||
v1.13.0)
|
|
||||||
CHECKSUM=743dea6fa96f3acdf0fe99ce5f8c83f43afe72efedeb1506f88f5321a18f63f2
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
printf 'Could not validate goreleaser version %s...\n' "${1}" 1>&2 ; exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
curl -LO "https://github.com/goreleaser/goreleaser/releases/download/${1}/goreleaser_Linux_x86_64.tar.gz"
|
|
||||||
|
|
||||||
printf '%s goreleaser_Linux_x86_64.tar.gz' "${CHECKSUM}" | sha256sum --check
|
|
||||||
|
|
||||||
tar -xf goreleaser_Linux_x86_64.tar.gz -C "${GOPATH}/bin"
|
|
17
support.mk
Normal file
17
support.mk
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
# Add quotes to a string and escape any internal quotes.
|
||||||
|
# $(call with-quotes,alice bob) -> "alice bob"
|
||||||
|
# $(call with-quotes,) -> ""
|
||||||
|
# $(call with-quotes,Bobby "Drop Tables") -> "Bobby \"Drop Tables\""
|
||||||
|
define with-quotes
|
||||||
|
$(if $(1),"$(subst ",\",$(1))")
|
||||||
|
endef
|
||||||
|
|
||||||
|
# Generate a command line option in the form $(1)"$(2)", but only if $(2)
|
||||||
|
# is not empty.
|
||||||
|
# $(call with-param,-t=,) ->
|
||||||
|
# $(call with-param,-t=,Ralph Wiggum) -> -t="Ralph Wiggum"
|
||||||
|
# $(call with-param,-t=,Bobby "Drop Tables") -> -t="Bobby \"Drop Tables\""
|
||||||
|
define with-param
|
||||||
|
$(if $(2),$(1)$(call with-quotes,$(2)))
|
||||||
|
endef
|
Reference in New Issue
Block a user