Skip to content

Commit

Permalink
Improve release tooling (kubernetes-sigs#340)
Browse files Browse the repository at this point in the history
- Update release image to use a version tag rather than latest
- Add a target for generating the release binaries
  • Loading branch information
detiber authored and k8s-ci-robot committed Oct 30, 2018
1 parent 12306a1 commit 511c6d4
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ envfile
minikube.kubeconfig
kubeconfig

# Example output directory
# Example and binary output directory
/out

# bazel
/bazel-bin
/bazel-cluster-api-provider-aws
/bazel-genfiles
/bazel-out
/bazel-testlogs
/bazel-testlogs
11 changes: 0 additions & 11 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,10 @@ gazelle(
filegroup(
name = "all-images",
srcs = [
"//cmd/clusterawsadm:clusterawsadm-image",
"//cmd/clusterctl:clusterctl-image",
"//cmd/manager:manager-image",
],
)

filegroup(
name = "all-images-dev",
srcs = [
"//cmd/clusterawsadm:clusterawsadm-image-dev",
"//cmd/clusterctl:clusterctl-image-dev",
"//cmd/manager:manager-image-dev",
],
)

workspace_binary(
name = "dep",
cmd = "@com_github_golang_dep//cmd/dep",
Expand Down
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ FASTBUILD ?= n ## Set FASTBUILD=y (case-sensitive) to skip some slow tasks
## Image URL to use all building/pushing image targets
STABLE_DOCKER_REPO ?= gcr.io/cluster-api-provider-aws
MANAGER_IMAGE_NAME ?= cluster-api-aws-controller
MANAGER_IMAGE_TAG ?= latest
MANAGER_IMAGE_TAG ?= 0.0.2
MANAGER_IMAGE ?= $(STABLE_DOCKER_REPO)/$(MANAGER_IMAGE_NAME):$(MANAGER_IMAGE_TAG)
DEV_DOCKER_REPO ?= gcr.io/$(shell gcloud config get-value project)
DEV_MANAGER_IMAGE ?= $(DEV_DOCKER_REPO)/$(MANAGER_IMAGE_NAME):$(MANAGER_IMAGE_TAG)
Expand Down Expand Up @@ -81,6 +81,15 @@ clusterawsadm: dep-ensure ## Build clusterawsadm binary.
cluster-api-dev-helper: dep-ensure ## Build cluster-api-dev-helper binary
bazel build //hack/cluster-api-dev-helper $(BAZEL_ARGS)

.PHONY: release-binaries
release-binaries: ## Build release binaries
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //cmd/clusterctl //cmd/clusterawsadm
bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64 //cmd/clusterctl //cmd/clusterawsadm
install bazel-bin/cmd/clusterawsadm/darwin_amd64_pure_stripped/clusterawsadm out/clusterawsadm-darwin-amd64
install bazel-bin/cmd/clusterawsadm/linux_amd64_pure_stripped/clusterawsadm out/clusterawsadm-linux-amd64
install bazel-bin/cmd/clusterctl/darwin_amd64_pure_stripped/clusterctl out/clusterctl-darwin-amd64
install bazel-bin/cmd/clusterctl/linux_amd64_pure_stripped/clusterctl out/clusterctl-linux-amd64

.PHONY: test
test: generate ## Run tests
bazel test --nosandbox_debug //pkg/... //cmd/... $(BAZEL_ARGS)
Expand All @@ -95,11 +104,11 @@ docker-build: generate ## Build the docker image

.PHONY: docker-push
docker-push: generate ## Push production docker image
bazel run //cmd/manager:manager-push --define=STABLE_DOCKER_REPO=$(STABLE_DOCKER_REPO) --define=MANAGER_IMAGE_NAME=$(MANAGER_IMAGE_NAME) $(BAZEL_ARGS)
bazel run //cmd/manager:manager-push --define=DOCKER_REPO=$(STABLE_DOCKER_REPO) --define=MANAGER_IMAGE_NAME=$(MANAGER_IMAGE_NAME) --define=MANAGER_IMAGE_TAG=$(MANAGER_IMAGE_TAG) $(BAZEL_ARGS)

.PHONY: docker-push-dev
docker-push-dev: generate ## Push development image
bazel run //cmd/manager:manager-push-dev --define=DEV_DOCKER_REPO=$(DEV_DOCKER_REPO) --define=MANAGER_IMAGE_NAME=$(MANAGER_IMAGE_NAME) $(BAZEL_ARGS)
bazel run //cmd/manager:manager-push --define=DOCKER_REPO=$(DEV_DOCKER_REPO) --define=MANAGER_IMAGE_NAME=$(MANAGER_IMAGE_NAME) --define=MANAGER_IMAGE_TAG=$(MANAGER_IMAGE_TAG) $(BAZEL_ARGS)

.PHONY: clean
clean: ## Remove all generated files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,26 @@ load("@io_bazel_rules_docker//container:push.bzl", "container_push")
load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push")
load("@io_bazel_rules_docker//container:container.bzl", "container_bundle")

def cluster_api_binary(name):
def cluster_api_binary_image(name):
go_image(
name = name + "-amd64",
base = "@golang-image//image",
embed = [":go_default_library"],
goarch = "amd64",
goos = "linux",
# goos = select(
# "@io_bazel_rules_go//go/platform:linux": "linux",
# "//conditions:default": fail("only building on Linux supported. Try again with --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 ")
# )
pure = "on",
)

tags = [
"{GIT_COMMIT}",
"{GIT_VERSION}",
"{BUILD_TIMESTAMP}",
"latest",
"$(MANAGER_IMAGE_TAG)",
]

container_bundle(
name = name + "-image",
images = {
"{registry}/{name}:{tag}".format(
registry = "$(STABLE_DOCKER_REPO)",
name = "$(MANAGER_IMAGE_NAME)",
tag = tag,
): ":{name}-amd64".format(name = name)
for tag in tags
},
stamp = True,
tags = ["manual"],
visibility = ["//visibility:public"],
)

docker_push(
name = name + "-push-dev",
bundle = ":{name}-image-dev".format(name = name),
tags = ["manual"],
)

container_bundle(
name = name + "-image-dev",
images = {
"{registry}/{name}:{tag}".format(
registry = "$(DEV_DOCKER_REPO)",
registry = "$(DOCKER_REPO)",
name = "$(MANAGER_IMAGE_NAME)",
tag = tag,
): ":{name}-amd64".format(name = name)
Expand Down
4 changes: 1 addition & 3 deletions cmd/clusterawsadm/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("//build:cluster_api_binary.bzl", "cluster_api_binary")

go_library(
name = "go_default_library",
Expand All @@ -13,6 +12,5 @@ go_binary(
name = "clusterawsadm",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
pure = "on",
)

cluster_api_binary(name = "clusterawsadm")
4 changes: 1 addition & 3 deletions cmd/clusterctl/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("//build:cluster_api_binary.bzl", "cluster_api_binary")

go_library(
name = "go_default_library",
Expand All @@ -17,6 +16,5 @@ go_binary(
name = "clusterctl",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
pure = "on",
)

cluster_api_binary(name = "clusterctl")
5 changes: 3 additions & 2 deletions cmd/manager/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("//build:cluster_api_binary.bzl", "cluster_api_binary")
load("//build:cluster_api_binary_image.bzl", "cluster_api_binary_image")

go_library(
name = "go_default_library",
Expand Down Expand Up @@ -27,6 +27,7 @@ go_binary(
name = "manager",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
pure = "on",
)

cluster_api_binary(name = "manager")
cluster_api_binary_image(name = "manager")
8 changes: 4 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
- [Committing code](#committing-code)
- [Mocks](#mocks)
- [Set up](#set-up)
- [Base requirements](#base-requirements)
- [Using Google Cloud](#using-google-cloud)
- [Using images on Google Cloud](#using-images-on-google-cloud)
- [Base requirements](#base-requirements)
- [Using Google Cloud](#using-google-cloud)
- [Using images on Google Cloud](#using-images-on-google-cloud)
- [cluster-api-dev-helper](#cluster-api-dev-helper)

<!-- /TOC -->
Expand Down Expand Up @@ -58,7 +58,7 @@ Google Container Registry.

1. [Install the gcloud cli][gcloud_sdk].
1. Set project: `gcloud config set project YOUR_PROJECT_NAME`.
1. Pushing dev images: `make dev_push`.
1. Pushing dev images: `make docker-push-dev`.

#### Using images on Google Cloud

Expand Down

0 comments on commit 511c6d4

Please sign in to comment.