diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..90b73dc8 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,47 @@ +name: Release + +on: + push: + tags: + - 'v*' + +# GitHub settings / example values: +# +# org level vars: +# - PUBLIC_REGISTRY: docker.io +# repo level vars: +# - PUBLIC_REGISTRY_REPO: rancher +# repo level secrets: +# - PUBLIC_REGISTRY_USERNAME +# - PUBLIC_REGISTRY_PASSWORD + +permissions: + contents: read + +jobs: + + publish-public: + runs-on: ubuntu-latest + + steps: + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + registry: ${{ vars.PUBLIC_REGISTRY }} + username: ${{ secrets.PUBLIC_REGISTRY_USERNAME }} + password: ${{ secrets.PUBLIC_REGISTRY_PASSWORD }} + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build and push all image variations + run: | + make image-push + TAG="${TAG}-amd64" TARGET_PLATFORMS=linux/amd64 make image-push + TAG="${TAG}-arm64" TARGET_PLATFORMS=linux/arm64 make image-push + env: + TAG: ${{ github.ref_name }} + REPO: ${{ vars.PUBLIC_REGISTRY }}/${{ vars.PUBLIC_REGISTRY_REPO }} diff --git a/Makefile b/Makefile index b9246d76..32a545e5 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,9 @@ GIT_TAG?=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0" ) endif TAG?=${GIT_TAG}-${GIT_COMMIT_SHORT} REPO?=docker.io/rancher/eks-operator +IMAGE = $(REPO):$(TAG) +TARGET_PLATFORMS := linux/amd64,linux/arm64 +MACHINE := rancher E2E_CONF_FILE ?= $(ROOT_DIR)/test/e2e/config/config.yaml CHART_VERSION?=$(subst v,,$(GIT_TAG)) RAWCOMMITDATE=$(shell git log -n1 --format="%at") @@ -81,6 +84,24 @@ generate: $(MAKE) generate-go $(MAKE) generate-crd +buildx-machine: + @docker buildx ls | grep $(MACHINE) || \ + docker buildx create --name=$(MACHINE) --platform=$(TARGET_PLATFORMS) + +.PHONY: image-build +image-build: buildx-machine ## build (and load) the container image targeting the current platform. + docker buildx build -f package/Dockerfile \ + --builder $(MACHINE) --build-arg VERSION=$(TAG) \ + -t "$(IMAGE)" $(BUILD_ACTION) . + @echo "Built $(IMAGE)" + +.PHONY: image-push +image-push: buildx-machine ## build the container image targeting all platforms defined by TARGET_PLATFORMS and push to a registry. + docker buildx build -f package/Dockerfile \ + --builder $(MACHINE) --build-arg VERSION=$(TAG) \ + --platform=$(TARGET_PLATFORMS) -t "$(IMAGE)" --push . + @echo "Pushed $(IMAGE)" + ALL_VERIFY_CHECKS = generate .PHONY: verify