Skip to content

Commit

Permalink
Merge pull request #445 from mjura/github_release
Browse files Browse the repository at this point in the history
Add image build and release for github actions
  • Loading branch information
mjura committed Apr 5, 2024
2 parents 05ff054 + c0104c0 commit f8f0165
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f8f0165

Please sign in to comment.