build: upload "latest" artifacts (#423)

This commit is contained in:
Brandon Pfeifer 2022-07-13 02:26:42 -04:00 committed by GitHub
parent b9ffcb4b5a
commit c44d2f232b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -339,6 +339,12 @@ jobs:
- run:
name: Publish tagged 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:
path: dist

View File

@ -0,0 +1,26 @@
#!/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)