diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000000..6b845d4d0a --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,26 @@ +name: build + +on: + push: + +jobs: + buildx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: linux/amd64,linux/arm64 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build images + run: | + make push-multiarch-images \ No newline at end of file diff --git a/Makefile b/Makefile index 8a6ff104f6..a27e12647a 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ SOURCES := Makefile go.mod go.sum $(shell find $(DEST) -name '*.go' 2>/dev/null) HAS_GOX := $(shell command -v gox;) GOX_PARALLEL ?= 3 -TARGETS ?= linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x +TARGETS ?= linux/amd64 linux/arm64 DIST_DIRS = find * -type d -exec TEMP_DIR :=$(shell mktemp -d) @@ -32,31 +32,21 @@ TAR_FILE ?= rootfs.tar GOOS ?= $(shell go env GOOS) GOPROXY ?= $(shell go env GOPROXY) -VERSION ?= $(shell git describe --dirty --tags --match='v*') +VERSION ?= $(shell git describe --dirty --tags --match='v*' --always) GOARCH := GOFLAGS := TAGS := LDFLAGS := "-w -s -X 'k8s.io/component-base/version.gitVersion=$(VERSION)' -X 'k8s.io/cloud-provider-openstack/pkg/version.Version=$(VERSION)'" GOX_LDFLAGS := $(shell echo "$(LDFLAGS) -extldflags \"-static\"") REGISTRY ?= reg.infra.ske.eu01.stackit.cloud/stackitcloud +GHCR ?= ghcr.io/stackitcloud IMAGE_OS ?= linux IMAGE_NAMES ?= openstack-cloud-controller-manager \ - cinder-csi-plugin \ - k8s-keystone-auth \ - octavia-ingress-controller \ - manila-csi-plugin \ - barbican-kms-plugin \ - magnum-auto-healer + cinder-csi-plugin ARCH ?= amd64 -ARCHS ?= amd64 arm arm64 ppc64le s390x +ARCHS ?= amd64 arm64 BUILD_CMDS ?= openstack-cloud-controller-manager \ - cinder-csi-plugin \ - k8s-keystone-auth \ - octavia-ingress-controller \ - manila-csi-plugin \ - barbican-kms-plugin \ - magnum-auto-healer \ - client-keystone-auth + cinder-csi-plugin # CTI targets @@ -172,7 +162,7 @@ build-local-images: $(addprefix build-image-,$(IMAGE_NAMES)) push-multiarch-image-%: $(CONTAINER_ENGINE) buildx build --output type=registry \ --build-arg VERSION=$(VERSION) \ - --tag $(REGISTRY)/$*:$(VERSION) \ + --tag $(GHCR)/$*:$(VERSION) \ --platform $(shell echo $(addprefix linux/,$(ARCHS)) | sed 's/ /,/g') \ --target $* \ . @@ -191,11 +181,6 @@ ifndef HAS_GOX endif CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(GOX_LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/openstack-cloud-controller-manager/ CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(GOX_LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/cinder-csi-plugin/ - CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(GOX_LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/k8s-keystone-auth/ - CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(GOX_LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/client-keystone-auth/ - CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(GOX_LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/octavia-ingress-controller/ - CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(GOX_LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/manila-csi-plugin/ - CGO_ENABLED=0 gox -parallel=$(GOX_PARALLEL) -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(GOX_LDFLAGS)' $(GIT_HOST)/$(BASE_DIR)/cmd/magnum-auto-healer/ .PHONY: dist dist: build-cross