...
1#!/usr/bin/env bash
2
3set -eux
4
5run="$1"
6kust_run="$1"
7config="$2"
8pallets="${3:-config/pallets/...}"
9
10# make sure branch is up to date so that tags dont get overwritten by builds
11# from an older revision
12branch=$(git branch --show-current)
13git fetch origin "$branch"
14git branch --set-upstream-to=origin/"$branch"
15
16if [ "$(git rev-parse HEAD)" != "$(git rev-parse "@{u}")" ]; then
17 echo "Local branch was behind remote, refusing to publish"
18 exit 1
19fi
20
21# tag artifacts according to their version and release status. releases, ie builds
22# of release/* branches, get two tags according to their semver, eg 0.15 and 0.15.0
23# master builds will have a "-rc" suffix and are additionally tagged as latest
24semver=$(cat .version)
25minor=$(cut -d. -f1,2 < .version)
26if [[ "$branch" == "release/"* ]]; then
27 tag="${semver},${minor}"
28 config="--bazel-configs=$config,release"
29 kust_run="$kust_run --config=release"
30elif [[ "$branch" == "master" ]]; then
31 tag="${semver}-rc,${minor}-rc,latest"
32 config="--bazel-configs=$config,release"
33 kust_run="$kust_run --config=release"
34else
35 tag="$branch"
36 config="--bazel-configs=$config"
37fi
38
39# Run the early-adopters of rules_kustomize so their images are present
40# Images aren't pushed via lift for now, so we need to ensure they're present
41bazel query 'kind("kustomization_push", //config/components/edge-iam-v2/...)' | xargs -n1 $kust_run
42
43# Remainder of images will be pushed via the "old" bzl:// tags until rules_warehouse
44# Alternatively, we could start querying all kustomize_push rules and
45$run //:lift -- pack \
46 --push \
47 "$config" \
48 --tag="$tag" \
49 "$pallets"
50
View as plain text