From 905a38fcc61ccf81182402b82e872ae7b30d4fc7 Mon Sep 17 00:00:00 2001 From: Simon Beck Date: Thu, 29 Aug 2024 09:20:49 +0200 Subject: [PATCH] Remove image from crossplane.yaml --- .cruft.json | 6 ++++-- .github/workflows/pr.yml | 17 ++++++++++------- .github/workflows/release.yml | 19 ++++++++++++++++++- ci.mk | 24 ++++++++---------------- package/crossplane.yaml | 2 -- 5 files changed, 40 insertions(+), 28 deletions(-) diff --git a/.cruft.json b/.cruft.json index 1ab4d12..d90c1a3 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,12 +1,14 @@ { "template": "https://github.com/vshn/appcat-cookiecutter", - "commit": "f3ff5b20dd78cac35e675813577638ce934a7c71", + "commit": "6a18e430833adf8e515c6050b3ff20268fc47d25", "checkout": null, "context": { "cookiecutter": { "app_name": "provider-cloudscale", "component_repo": "vshn/component-appcat", - "provider": true, + "push_upbound": true, + "push_package": true, + "push_image": false, "_copy_without_render": [ ".github/workflows/cruft-update.yml", ".github/changelog-configuration.json" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1bcae25..8b69e83 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -11,7 +11,9 @@ on: env: APP_NAME: provider-cloudscale COMPONENT_REPO: vshn/component-appcat - UPBOUND_PUSH: True + PUSH_UPBOUND: "True" + PUSH_PACKAGE: "True" + PUSH_IMAGE: "False" jobs: check-labels: @@ -56,24 +58,25 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build branch and push AppCat - if: ${{ env.UPBOUND_PUSH }} == "False" + - name: Build branch and push image + if: env.PUSH_IMAGE == 'true' run: make docker-push-branchtag -e IMG_TAG="${{ steps.extract_branch.outputs.branch }}" - name: Build branch and push package + if: env.PUSH_PACKAGE == 'True' run: make package-push-branchtag -e IMG_TAG="${{ steps.extract_branch.outputs.branch }}" - name: Login to Upbound - if: ${{ env.UPBOUND_PUSH }} == "True" - uses: docker/login-action@v1 + if: env.PUSH_UPBOUND == 'true' + uses: docker/login-action@v3 with: registry: xpkg.upbound.io username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }} - name: Build branch and push package to upbound - if: ${{ env.UPBOUND_PUSH }} == "True" - run: make package-push-upbound-branchtag -e IMG_TAG="${{ steps.extract_branch.outputs.branch }}" + if: env.PUSH_UPBOUND == 'true' && env.PUSH_PACKAGE == 'true' + run: make package-push-branchtag -e IMG_TAG="${{ steps.extract_branch.outputs.branch }}" -e IMG_REPO=xpkg.upbound.io open-pr-component: if: github.event.action == 'opened' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3730a6..d3a56ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,9 @@ on: env: APP_NAME: provider-cloudscale + PUSH_UPBOUND: "True" + PUSH_PACKAGE: "True" + PUSH_IMAGE: "False" jobs: dist: @@ -45,10 +48,24 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Push docker image + if: env.PUSH_IMAGE == 'true' run: make docker-push -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }} - name: Build and push function package - run: make package-push-branchtag -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }} + if: env.PUSH_PACKAGE == 'true' + run: make package-push -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }} + + - name: Login to Upbound + if: env.PUSH_UPBOUND == 'true' + uses: docker/login-action@v1 + with: + registry: xpkg.upbound.io + username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} + password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }} + + - name: Build branch and push package to upbound + if: env.PUSH_UPBOUND == 'true' && env.PUSH_PACKAGE == 'true' + run: make package-push -e IMG_TAG=${GITHUB_REF##*/} -e APP_NAME=${{ env.APP_NAME }} -e IMG_REPO=xpkg.upbound.io - name: Build changelog from PRs with labels id: build_changelog diff --git a/ci.mk b/ci.mk index 8f2d2e6..a63d1bc 100644 --- a/ci.mk +++ b/ci.mk @@ -2,7 +2,8 @@ IMG_TAG ?= latest APP_NAME ?= provider-cloudscale ORG ?= vshn -GHCR_IMG ?= ghcr.io/$(ORG)/$(APP_NAME):$(IMG_TAG) +IMG_REPO ?= ghcr.io +IMG ?= $(IMG_REPO)/$(ORG)/$(APP_NAME):$(IMG_TAG) DOCKER_CMD ?= docker # Upbound push config @@ -17,7 +18,7 @@ DOCKER_IMAGE_GOARCH = amd64 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 ${GHCR_IMG} . + docker build --platform $(DOCKER_IMAGE_GOOS)/$(DOCKER_IMAGE_GOARCH) -t ${IMG} . .PHONY: docker-build-branchtag IMG_TAG ?= $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') @@ -25,7 +26,7 @@ docker-build-branchtag: docker-build ## Build docker image with current branch n .PHONY: docker-push docker-push: docker-build ## Push docker image with the manager. - docker push ${GHCR_IMG} + docker push ${IMG} .PHONY: docker-push-branchtag IMG_TAG ?= $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') @@ -34,28 +35,19 @@ 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=${GHCR_IMG} -o package/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 .PHONY: package-push package-push: package-build - go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg push -f package/package.xpkg ${GHCR_IMG} --verbose + go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg push -f package/package.xpkg ${IMG} --verbose .PHONY: package-build-branchtag IMG_TAG ?= $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') package-build-branchtag: docker-build-branchtag rm -f package/*.xpkg - go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg build -f package --verbose --embed-runtime-image=${GHCR_IMG} -o package/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 .PHONY: package-push-package-branchtag IMG_TAG ?= $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') package-push-branchtag: package-build-branchtag - go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg push -f package/package.xpkg ${GHCR_IMG} --verbose - -.PHONY: package-push-upbound -package-push-upbound: package-build - go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg push -f package/package.xpkg ${GHCR_IMG} --verbose - -.PHONY: package-push-upbound-branchtag -IMG_TAG ?= $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g') -package-push-upbound-branchtag: package-build-branchtag - go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg push -f package/package.xpkg ${GHCR_IMG} --verbose + go run github.com/crossplane/crossplane/cmd/crank@v1.16.0 xpkg push -f package/package.xpkg ${IMG} --verbose diff --git a/package/crossplane.yaml b/package/crossplane.yaml index 8838cce..90d03e9 100644 --- a/package/crossplane.yaml +++ b/package/crossplane.yaml @@ -16,7 +16,5 @@ metadata: If you encounter an issue please create an issue in the [vshn/provider-cloudscale](https://github.com/vshn/provider-cloudscale/issues) repo. spec: - controller: - image: ghcr.io/vshn/provider-cloudscale/controller:latest crossplane: version: ">=v1.9.0"