Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ on:

env:
APP_NAME: provider-minio
PUSH_UPBOUND: "True"
PUSH_PACKAGE: "True"
PUSH_IMAGE: "False"
PUSH_UPBOUND: "true"
PUSH_PACKAGE: "true"
PUSH_IMAGE: "false"
SUFFIX: "/controller"

jobs:
dist:
runs-on: ubuntu-latest
permissions:
contents: write # goreleaser needs this to publish GitHub releases
packages: write # crank xpkg push and docker login need this for GHCR
steps:

- uses: actions/checkout@v4
Expand Down Expand Up @@ -50,11 +53,11 @@ jobs:

- name: Push docker image
if: env.PUSH_IMAGE == 'true'
run: make docker-push -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }}
run: make docker-push -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }} -e ORG=${{ github.repository_owner }}

- name: Build and push function package
if: env.PUSH_PACKAGE == 'true'
run: make package-push -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }}
run: make package-push -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }} -e ORG=${{ github.repository_owner }}

- name: Login to Upbound
if: env.PUSH_UPBOUND == 'true'
Expand Down
31 changes: 24 additions & 7 deletions ci.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,36 @@ UPBOUND_CONTAINER_REGISTRY ?= xpkg.upbound.io
UPBOUND_PACKAGE_IMG ?= $(UPBOUND_CONTAINER_REGISTRY)/$(ORG)/$(APP_NAME):$(IMG_TAG)

# For alpine image it is required the following env before building the application
# DOCKER_IMAGE_GOARCH is a space-separated list; one runtime image is built per
# architecture and the package is pushed as a multi-arch index.
DOCKER_IMAGE_GOOS = linux
DOCKER_IMAGE_GOARCH = amd64
DOCKER_IMAGE_GOARCH ?= amd64 arm64

# Comma-join helper for crank's -f flag
empty :=
space := $(empty) $(empty)
comma := ,
XPKG_FILES = $(patsubst %,package/package-%.xpkg,$(DOCKER_IMAGE_GOARCH))

.PHONY: docker-build
docker-build:
env CGO_ENABLED=0 GOOS=$(DOCKER_IMAGE_GOOS) GOARCH=$(DOCKER_IMAGE_GOARCH) \
go build -o ${BIN_FILENAME}
docker build --platform $(DOCKER_IMAGE_GOOS)/$(DOCKER_IMAGE_GOARCH) -t ${IMG} .
@for arch in $(DOCKER_IMAGE_GOARCH); do \
env CGO_ENABLED=0 GOOS=$(DOCKER_IMAGE_GOOS) GOARCH=$$arch \
go build -o ${BIN_FILENAME} && \
$(DOCKER_CMD) build --platform $(DOCKER_IMAGE_GOOS)/$$arch -t ${IMG}-$$arch . \
|| exit 1; \
done
@# Keep the un-suffixed tag for single-image consumers (kind-load-image);
@# points at the first architecture in the list (amd64 by default).
$(DOCKER_CMD) tag ${IMG}-$(firstword $(DOCKER_IMAGE_GOARCH)) ${IMG}

.PHONY: docker-build-branchtag
docker-build-branchtag: export IMG_TAG=$(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
docker-build-branchtag: docker-build ## Build docker image with current branch name

.PHONY: docker-push
docker-push: docker-build ## Push docker image with the manager.
docker push ${IMG}
$(DOCKER_CMD) push ${IMG}

.PHONY: docker-push-branchtag
docker-push-branchtag: export IMG_TAG=$(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
Expand All @@ -35,11 +49,14 @@ docker-push-branchtag: docker-build-branchtag docker-push ## Push docker image w
.PHONY: package-build
package-build: docker-build
rm -f package/*.xpkg
go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg build -f package --verbose --embed-runtime-image=${IMG} -o package/package.xpkg
@for arch in $(DOCKER_IMAGE_GOARCH); do \
go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg build -f package --verbose --embed-runtime-image=${IMG}-$$arch -o package/package-$$arch.xpkg \
|| exit 1; \
done

.PHONY: package-push
package-push: package-build
go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg push -f package/package.xpkg ${IMG} --verbose
go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg push -f $(subst $(space),$(comma),$(XPKG_FILES)) ${IMG} --verbose

.PHONY: package-build-branchtag
package-build-branchtag: export IMG_TAG=$(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
Expand Down