feat: split release build and deploy (#3879)

* feat: split release build and deploy

* fix: only build_release on main

* chore: fix build_perf CI

* fix: deploy_release checkout

* fix: update deploy_release image

* fix: deploy_release credentials

* fix: add COMMIT_SHA to env

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/24376/head
Raphael Taylor-Davies 2022-03-01 16:35:39 +00:00 committed by GitHub
parent 01f4d3ed3b
commit 63bea75ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 48 additions and 13 deletions

View File

@ -425,14 +425,12 @@ jobs:
COMMIT_SHA="$(git rev-parse --short HEAD)" COMMIT_SHA="$(git rev-parse --short HEAD)"
RUST_VERSION="$(sed -E -ne 's/channel = "(.*)"/\1/p' rust-toolchain.toml)" RUST_VERSION="$(sed -E -ne 's/channel = "(.*)"/\1/p' rust-toolchain.toml)"
BRANCH="$(echo "$CIRCLE_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/_/g')"
docker buildx build \ docker buildx build \
--build-arg RUST_VERSION="$RUST_VERSION" \ --build-arg RUST_VERSION="$RUST_VERSION" \
--build-arg RUSTFLAGS="-C target-feature=+avx2 -C link-arg=-fuse-ld=lld" \ --build-arg RUSTFLAGS="-C target-feature=+avx2 -C link-arg=-fuse-ld=lld" \
--progress plain \ --progress plain \
--tag quay.io/influxdb/iox:"$COMMIT_SHA" \ --tag quay.io/influxdb/iox:"$COMMIT_SHA" \
--tag quay.io/influxdb/iox:"$BRANCH" \
. .
docker buildx build \ docker buildx build \
--build-arg FEATURES="" \ --build-arg FEATURES="" \
@ -441,7 +439,6 @@ jobs:
--build-arg RUSTFLAGS="-C target-feature=+avx2 -C link-arg=-fuse-ld=lld" \ --build-arg RUSTFLAGS="-C target-feature=+avx2 -C link-arg=-fuse-ld=lld" \
--progress plain \ --progress plain \
--tag quay.io/influxdb/iox_data_generator:"$COMMIT_SHA" \ --tag quay.io/influxdb/iox_data_generator:"$COMMIT_SHA" \
--tag quay.io/influxdb/iox_data_generator:"$BRANCH" \
. .
docker buildx build \ docker buildx build \
--build-arg FEATURES="" \ --build-arg FEATURES="" \
@ -450,24 +447,52 @@ jobs:
--build-arg RUSTFLAGS="-C target-feature=+avx2 -C link-arg=-fuse-ld=lld" \ --build-arg RUSTFLAGS="-C target-feature=+avx2 -C link-arg=-fuse-ld=lld" \
--progress plain \ --progress plain \
--tag quay.io/influxdb/iox_gitops_adapter:"$COMMIT_SHA" \ --tag quay.io/influxdb/iox_gitops_adapter:"$COMMIT_SHA" \
--tag quay.io/influxdb/iox_gitops_adapter:"$BRANCH" \
. .
docker run -it --rm quay.io/influxdb/iox:$COMMIT_SHA debug print-cpu docker run -it --rm quay.io/influxdb/iox:$COMMIT_SHA debug print-cpu
docker push --all-tags quay.io/influxdb/iox docker push quay.io/influxdb/iox:"$COMMIT_SHA"
docker push --all-tags quay.io/influxdb/iox_data_generator docker push quay.io/influxdb/iox_data_generator:"$COMMIT_SHA"
docker push --all-tags quay.io/influxdb/iox_gitops_adapter docker push quay.io/influxdb/iox_gitops_adapter:"$COMMIT_SHA"
echo "export COMMIT_SHA=${COMMIT_SHA}" >> $BASH_ENV
# linking might take a while and doesn't produce CLI output # linking might take a while and doesn't produce CLI output
no_output_timeout: 20m no_output_timeout: 30m
- cache_save
deploy_release:
docker:
- image: cimg/base:2021.04
steps:
- setup_remote_docker:
version: 19.03.13
docker_layer_caching: true
- checkout
- run: |
echo "$QUAY_INFLUXDB_IOX_PASS" | docker login quay.io --username $QUAY_INFLUXDB_IOX_USER --password-stdin
- run:
name: Update docker branch tags
command: |
COMMIT_SHA="$(git rev-parse --short HEAD)"
BRANCH="$(echo "$CIRCLE_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/_/g')"
docker pull quay.io/influxdb/iox:"$COMMIT_SHA"
docker pull quay.io/influxdb/iox_data_generator:"$COMMIT_SHA"
docker pull quay.io/influxdb/iox_gitops_adapter:"$COMMIT_SHA"
docker tag quay.io/influxdb/iox:"$COMMIT_SHA" quay.io/influxdb/iox:"$BRANCH"
docker tag quay.io/influxdb/iox_data_generator:"$COMMIT_SHA" quay.io/influxdb/iox_data_generator:"$BRANCH"
docker tag quay.io/influxdb/iox_gitops_adapter:"$COMMIT_SHA" quay.io/influxdb/iox_gitops_adapter:"$BRANCH"
docker push quay.io/influxdb/iox:"$BRANCH"
docker push quay.io/influxdb/iox_data_generator:"$BRANCH"
docker push quay.io/influxdb/iox_gitops_adapter:"$BRANCH"
echo "export COMMIT_SHA=${COMMIT_SHA}" >> $BASH_ENV
- run: - run:
name: Deploy tags name: Deploy tags
command: | command: |
echo "$QUAY_PASS" | docker login quay.io --username $QUAY_USER --password-stdin echo "$QUAY_PASS" | docker login quay.io --username $QUAY_USER --password-stdin
./.circleci/get-deploy-tags.sh "${COMMIT_SHA}" ./.circleci/get-deploy-tags.sh "${COMMIT_SHA}"
- cache_save
# Prepare the CI image used for other tasks. # Prepare the CI image used for other tasks.
# #
@ -512,7 +537,9 @@ workflows:
# CI for all pull requests. # CI for all pull requests.
ci: ci:
when: when:
not: << pipeline.parameters.ci_image >> and:
- not: << pipeline.parameters.ci_image >>
- not: << pipeline.parameters.build_perf >>
jobs: jobs:
- fmt - fmt
- lint - lint
@ -529,7 +556,11 @@ workflows:
filters: filters:
branches: branches:
only: main only: main
requires: # Only do a release build if all tests have passed - deploy_release:
filters:
branches:
only: main
requires: # Only deploy if all tests have passed
- fmt - fmt
- lint - lint
- cargo_audit - cargo_audit
@ -539,6 +570,7 @@ workflows:
- test_heappy - test_heappy
- test_perf - test_perf
- build_dev - build_dev
- build_release
- doc - doc
# Manual build of CI image # Manual build of CI image
@ -563,6 +595,9 @@ workflows:
when: << pipeline.parameters.build_perf >> when: << pipeline.parameters.build_perf >>
jobs: jobs:
- build_release - build_release
- deploy_release:
requires:
- build_release
# Nightly rebuild of the build container # Nightly rebuild of the build container
ci_image_nightly: ci_image_nightly: