build: fix release workflow (#23475)

* build: fix release workflow

* fix: allow for multi-digit minor/patch versions
pull/23487/head
Brandon Pfeifer 2022-06-17 16:33:46 -04:00 committed by GitHub
parent 83bb8ed2fc
commit 85e4e6317e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 12 deletions

View File

@ -101,7 +101,7 @@ workflows:
<<: *any_filter
- build:
<<: *any_filter
name: build-snapshot-<< matrix.os >>-<< matrix.arch >>
name: build-<< matrix.os >>-<< matrix.arch >>
build-type: snapshot
matrix:
parameters:
@ -114,7 +114,7 @@ workflows:
<<: *any_filter
name: build-package-<< matrix.os >>-<< matrix.arch >>
requires:
- build-snapshot-<< matrix.os >>-<< matrix.arch >>
- build-<< matrix.os >>-<< matrix.arch >>
matrix:
parameters:
os: [ linux, darwin, windows ]
@ -125,11 +125,11 @@ workflows:
- test-downgrade:
<<: *any_filter
requires:
- build-snapshot-linux-amd64
- build-linux-amd64
- e2e-monitor-ci:
<<: *nofork_filter
requires:
- build-snapshot-linux-amd64
- build-linux-amd64
- test-linux-packages:
<<: *nofork_filter
requires:
@ -156,14 +156,14 @@ workflows:
- grace-test:
<<: *any_filter
requires:
- build-snapshot-linux-amd64
- build-linux-amd64
- litmus-smoke-test:
<<: *any_filter
requires:
- build-snapshot-linux-amd64
- build-linux-amd64
- litmus-full-test:
requires:
- build-snapshot-linux-amd64
- build-linux-amd64
filters:
branches:
only: master
@ -380,15 +380,33 @@ jobs:
type: string
steps:
- checkout
- run:
name: Get InfluxDB version
command: |
PREFIX=2.x .circleci/scripts/get-version
- run:
name: Generate UI assets
command: make generate-web-assets
- run:
name: Build binaries
command: |
build_type="<< parameters.build-type >>"
# release builds occur from the "build" pipeline
if [[ ${build_type} == snapshot ]]
then
# `get-version` determines whether this is a release build. If
# this is a release build, ensure that the proper version is
# templated into the go binary.
if [[ ${RELEASE:-} ]]
then
build_type=release
fi
fi
export GOOS=<< parameters.os >>
export GOARCH=<< parameters.arch >>
./scripts/ci/build.sh "bin/influxd_$(go env GOOS)_$(go env GOARCH)" "<< parameters.build-type >>" ./cmd/influxd
./scripts/ci/build.sh "bin/influxd_$(go env GOOS)_$(go env GOARCH)" "${build_type}" ./cmd/influxd
- store_artifacts:
path: bin
- persist_to_workspace:

View File

@ -3,6 +3,20 @@ set -o errexit \
-o nounset \
-o pipefail
REGEX_RELEASE_VERSION='[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+'
if [[ ${RELEASE:-} ]]
then
# This ensures that release packages are built with valid versions.
# Unfortunately, `fpm` is fairly permissive with what version tags
# it accepts. This becomes a problem when `apt` or `dpkg` is used
# to install the package (both have strict version requirements).
if ! [[ ${VERSION} =~ ^${REGEX_RELEASE_VERSION}$ ]]
then
printf 'Release version is invalid!\n' >&2 && exit 1
fi
fi
function run_fpm()
{
if [[ ${1} == rpm ]]
@ -59,7 +73,7 @@ function run_fpm()
;;
rpm)
mv "/artifacts/influxdb2-${VERSION//-/_}-1.${ARCH}.rpm" \
"/artifacts/influxdb2-${VERSION//-/_}-${ARCH}.rpm"
"/artifacts/influxdb2-${VERSION//-/_}.${ARCH}.rpm"
;;
esac
}
@ -89,7 +103,7 @@ build_tarfile()
# in the root of the tarfile. The second being that this excludes
# empty directories from the tarfile.
find "influxdb2_${PLAT}_${ARCH}/" -type f \
| tar -czf "/artifacts/influxdb2_${VERSION}_${PLAT}_${ARCH}.tar.gz" -T -
| tar -czf "/artifacts/influxdb2-${VERSION}-${PLAT}-${ARCH}.tar.gz" -T -
popd
}

View File

@ -3,7 +3,7 @@ set -o nounset \
-o errexit \
-o pipefail
REGEX_TAG='v[[:digit:]]+\.[[:digit:]]\.[[:digit:]]'
REGEX_TAG='v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+'
function semver_tags()
{
@ -31,7 +31,7 @@ TAG=$(head -n 1 <<<"$(semver_tags)")
if [[ ${TAG:-} ]]
then
cat <<EOF >>"${BASH_ENV}"
export VERSION="${TAG}"
export VERSION="${TAG:1}"
export RELEASE=1
EOF
else