#!/usr/bin/env bash set -eux run="$1" kust_run="$1" config="$2" pallets="${3:-config/pallets/...}" # make sure branch is up to date so that tags dont get overwritten by builds # from an older revision branch=$(git branch --show-current) git fetch origin "$branch" git branch --set-upstream-to=origin/"$branch" if [ "$(git rev-parse HEAD)" != "$(git rev-parse "@{u}")" ]; then echo "Local branch was behind remote, refusing to publish" exit 1 fi # tag artifacts according to their version and release status. releases, ie builds # of release/* branches, get two tags according to their semver, eg 0.15 and 0.15.0 # master builds will have a "-rc" suffix and are additionally tagged as latest semver=$(cat .version) minor=$(cut -d. -f1,2 < .version) if [[ "$branch" == "release/"* ]]; then tag="${semver},${minor}" config="--bazel-configs=$config,release" kust_run="$kust_run --config=release" elif [[ "$branch" == "master" ]]; then tag="${semver}-rc,${minor}-rc,latest" config="--bazel-configs=$config,release" kust_run="$kust_run --config=release" else tag="$branch" config="--bazel-configs=$config" fi # Run the early-adopters of rules_kustomize so their images are present # Images aren't pushed via lift for now, so we need to ensure they're present bazel query 'kind("kustomization_push", //config/components/edge-iam-v2/...)' | xargs -n1 $kust_run # Remainder of images will be pushed via the "old" bzl:// tags until rules_warehouse # Alternatively, we could start querying all kustomize_push rules and $run //:lift -- pack \ --push \ "$config" \ --tag="$tag" \ "$pallets"