From a05891f6512ca0613e9c3b95798ed639ad4cf6dc Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Wed, 6 Nov 2024 23:16:26 +0100 Subject: [PATCH 01/11] chore: allow effective version override --- components/demoplugin/Makefile | 4 ++-- components/ecrplugin/Makefile | 4 ++-- components/helmdemo/Makefile | 2 +- components/helminstaller/Makefile | 2 +- components/ocmcli/Makefile | 4 ++-- components/subchartsdemo/Makefile | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/demoplugin/Makefile b/components/demoplugin/Makefile index 43b8b5803..024e92fb2 100644 --- a/components/demoplugin/Makefile +++ b/components/demoplugin/Makefile @@ -3,13 +3,13 @@ PROVIDER ?= ocm.software GITHUBORG ?= open-component-model COMPONENT = $(PROVIDER)/plugins/$(NAME) OCMREPO ?= ghcr.io/$(GITHUBORG)/ocm -PLATFORMS = linux/amd64 linux/arm64 +PLATFORMS ?= linux/amd64 linux/arm64 CTF_TYPE ?= directory REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT = $(shell git rev-parse HEAD) -EFFECTIVE_VERSION = $(VERSION)+$(COMMIT) +EFFECTIVE_VERSION ?= $(VERSION)+$(COMMIT) GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) CMDSRCS=$(shell find $(REPO_ROOT)/cmds/$(NAME) -type f) diff --git a/components/ecrplugin/Makefile b/components/ecrplugin/Makefile index ff96ab485..cb0f76802 100644 --- a/components/ecrplugin/Makefile +++ b/components/ecrplugin/Makefile @@ -3,14 +3,14 @@ PROVIDER ?= ocm.software GITHUBORG ?= open-component-model COMPONENT = $(PROVIDER)/plugins/$(NAME) OCMREPO ?= ghcr.io/$(GITHUBORG)/ocm -PLATFORMS = linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 +PLATFORMS ?= linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 CTF_TYPE ?= directory REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT = $(shell git rev-parse HEAD) -EFFECTIVE_VERSION = $(VERSION)+$(COMMIT) +EFFECTIVE_VERSION ?= $(VERSION)+$(COMMIT) GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) CMDSRCS=$(shell find $(REPO_ROOT)/cmds/$(NAME) -type f) diff --git a/components/helmdemo/Makefile b/components/helmdemo/Makefile index 4ceba662f..34da222a3 100644 --- a/components/helmdemo/Makefile +++ b/components/helmdemo/Makefile @@ -10,7 +10,7 @@ HELMINSTCOMP = $(PROVIDER)/toi/installers/helminstaller REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT = $(shell git rev-parse HEAD) -EFFECTIVE_VERSION = $(VERSION)-$(COMMIT) +EFFECTIVE_VERSION ?= $(VERSION)-$(COMMIT) HELMINSTVERSION ?= $(VERSION) CREDS ?= diff --git a/components/helminstaller/Makefile b/components/helminstaller/Makefile index ed3d368da..0b5dd01f9 100644 --- a/components/helminstaller/Makefile +++ b/components/helminstaller/Makefile @@ -11,7 +11,7 @@ CTF_TYPE ?= directory REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION := $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT := $(shell git rev-parse --verify HEAD) -EFFECTIVE_VERSION := $(VERSION)-$(COMMIT) +EFFECTIVE_VERSION ?= $(VERSION)-$(COMMIT) GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) PLATFORM := $(shell go env GOOS)/$(shell go env GOARCH) CACHE_DIR := $(shell go env GOCACHE) diff --git a/components/ocmcli/Makefile b/components/ocmcli/Makefile index e972f9103..2ac1c8f94 100644 --- a/components/ocmcli/Makefile +++ b/components/ocmcli/Makefile @@ -7,14 +7,14 @@ COMPONENT = $(PROVIDER)/$(NAME) OCMREPO ?= ghcr.io/$(GITHUBORG)/ocm MULTI ?= true IMAGE_PLATFORMS ?= linux/amd64 linux/arm64 -PLATFORMS = $(IMAGE_PLATFORMS) darwin/arm64 darwin/amd64 windows/amd64 +PLATFORMS ?= $(IMAGE_PLATFORMS) darwin/arm64 darwin/amd64 windows/amd64 CTF_TYPE ?= directory REPO_ROOT := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))../.. GIT_TREE_STATE = $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT = $(shell git rev-parse HEAD) -EFFECTIVE_VERSION = $(VERSION)+$(COMMIT) +EFFECTIVE_VERSION ?= $(VERSION)+$(COMMIT) PLATFORM_OS := $(shell go env GOOS) PLATFORM_ARCH := $(shell go env GOARCH) diff --git a/components/subchartsdemo/Makefile b/components/subchartsdemo/Makefile index 93ae7b583..59f424806 100644 --- a/components/subchartsdemo/Makefile +++ b/components/subchartsdemo/Makefile @@ -15,7 +15,7 @@ REPO_ROOT := $(shell dirname $(realpath $(la GIT_TREE_STATE = $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) VERSION = $(shell go run $(REPO_ROOT)/api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT = $(shell git rev-parse HEAD) -EFFECTIVE_VERSION = $(VERSION)-$(COMMIT) +EFFECTIVE_VERSION ?= $(VERSION)-$(COMMIT) HELMINSTVERSION ?= $(VERSION) CREDS ?= From bee175168c6f3e145234a49802ce48a6f69c17b3 Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Tue, 12 Nov 2024 12:00:55 +0100 Subject: [PATCH 02/11] depend on component CTF builds in release --- .github/config/goreleaser.yaml | 1 - .github/workflows/components.yaml | 39 ++++++++++++++++++++----- .github/workflows/release.yaml | 48 +++++++++++++++++++++++++++++-- 3 files changed, 78 insertions(+), 10 deletions(-) diff --git a/.github/config/goreleaser.yaml b/.github/config/goreleaser.yaml index 5f8e6ebec..b42711776 100644 --- a/.github/config/goreleaser.yaml +++ b/.github/config/goreleaser.yaml @@ -8,7 +8,6 @@ release: before: hooks: - go mod tidy - - make CTF_TYPE=directory ctf builds: - <<: &build_defaults diff --git a/.github/workflows/components.yaml b/.github/workflows/components.yaml index ff7f6b9af..73acda8c8 100644 --- a/.github/workflows/components.yaml +++ b/.github/workflows/components.yaml @@ -3,6 +3,22 @@ name: Components on: pull_request: workflow_call: + inputs: + effective-version: + type: string + required: false + description: "The version to use for the build" + default: "" + upload-ctf: + type: boolean + required: false + description: "Whether to upload the final CTF" + default: false + ref: + type: string + description: "The ref to use for the component build, defaults to the ref where the workflow was triggered from" + required: false + default: "" push: branches: - main @@ -12,8 +28,11 @@ permissions: pull-requests: read env: + REF: ${{ inputs.ref == '' && github.ref || inputs.ref }} CTF_TYPE: directory components: '["ocmcli", "helminstaller", "helmdemo", "subchartsdemo", "ecrplugin"]' + PLATFORMS: 'linux/amd64' +# PLATFORMS: 'windows/amd64 darwin/arm64 darwin/amd64 linux/amd64 linux/arm64' jobs: define-matrix: @@ -40,6 +59,8 @@ jobs: uses: TooMuch4U/actions-clean@v2.2 - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ env.REF }} - name: Setup Go uses: actions/setup-go@v5 with: @@ -68,7 +89,11 @@ jobs: - name: CTF run: | cd components/${{ matrix.component }} - PATH=$PATH:$(go env GOPATH)/bin CTF_TYPE=${{ env.CTF_TYPE }} make ctf descriptor describe + PATH=$PATH:$(go env GOPATH)/bin \ + CTF_TYPE=${{ env.CTF_TYPE }} \ + EFFECTIVE_VERSION=${{ inputs.effective-version }} \ + PLATFORMS=${{ env.PLATFORMS }} \ + make ctf descriptor describe - name: Upload CTF uses: actions/upload-artifact@v4 with: @@ -89,6 +114,8 @@ jobs: uses: TooMuch4U/actions-clean@v2.2 - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ env.REF }} - name: Download CTFs uses: actions/download-artifact@v4 with: @@ -96,8 +123,7 @@ jobs: path: gen/downloaded-ctfs - name: Move CTFs into correct directory for aggregation run: | - IFS=" " read -a COMPONENTS <<< "${{ env.components }}" - for i in "${COMPONENTS[@]}"; do + for i in ${{ env.components }}; do mkdir -p ${{ github.workspace }}/gen/${i} mv ${{ github.workspace }}/gen/downloaded-ctfs/ctf-component-${i} ${{ github.workspace }}/gen/${i}/ctf ls -R ${{ github.workspace }}/gen/${i} @@ -130,14 +156,13 @@ jobs: ${{ github.workspace }}/gen/ctf done - name: Upload aggregated CTF - # TODO This is currently permanently disabled, - # until we integrate it with the release build, in which it would be reused - if: false + # only upload the artifact if we are not on a PR + if: inputs.upload-ctf == 'true' uses: actions/upload-artifact@v4 with: if-no-files-found: error overwrite: true - retention-days: 60 + retention-days: 30 name: ctf-aggregated path: gen/ctf - name: Delete old CTFs that lead up to aggregation diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 9c6fdb5d2..3b8fbc36b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -81,18 +81,22 @@ jobs: components: name: Component CTF Builds uses: ./.github/workflows/components.yaml - needs: check + needs: [check,release-version] + with: + effective-version: ${{ needs.release-version.outputs.version_no_prefix }} + upload-ctf: true + ref: ${{ github.ref }} permissions: contents: read pull-requests: read - release: needs: # run check before actual release to make sure we succeed # they will be skipped from the needs check - check - release-version + - components name: Release Build runs-on: large_runner permissions: @@ -124,6 +128,46 @@ jobs: - name: Setup Cosign uses: sigstore/cosign-installer@v3.7.0 + - name: Download CTF + uses: actions/download-artifact@v4 + with: + pattern: 'ctf-aggregated' + path: gen/downloaded-ctfs + - name: Move CTF into correct directory to be recognized by the release process + run: | + mkdir -p ${{ github.workspace }}/gen + mv \ + ${{ github.workspace }}/gen/downloaded-ctfs/ctf-aggregated \ + ${{ github.workspace }}/gen/ctf + + # TODO: Remove Go setup once binaries no longer need to be built by goreleaser. + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: '${{ github.workspace }}/go.mod' + check-latest: false + cache: false + - name: Get go environment for use with cache + run: | + echo "go_cache=$(go env GOCACHE)" >> $GITHUB_ENV + echo "go_modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV + # This step will only reuse the go mod and build cache from main made during the Build, + # see push_ocm.yaml => "ocm-cli-latest" Job + # This means it never caches by itself and PRs cannot cause cache pollution / thrashing + # This is because we have huge storage requirements for our cache because of the mass of dependencies + - name: Restore / Reuse Cache from central build + id: cache-golang-restore + uses: actions/cache/restore@v4 # Only Restore, not build another cache (too big) + with: + path: | + ${{ env.go_cache }} + ${{ env.go_modcache }} + key: ${{ env.cache_name }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/go.mod') }} + restore-keys: | + ${{ env.cache_name }}-${{ runner.os }}-go- + env: + cache_name: ocm-cli-latest-go-cache # needs to be the same key in the end as in the build step + - name: Setup git config run: | git config user.name "GitHub Actions Bot" From bc768674a73234224753c4eb083b88405ebe958c Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Tue, 12 Nov 2024 13:32:01 +0100 Subject: [PATCH 03/11] chore: also override image platforms --- .github/workflows/components.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/components.yaml b/.github/workflows/components.yaml index 73acda8c8..353be9966 100644 --- a/.github/workflows/components.yaml +++ b/.github/workflows/components.yaml @@ -32,6 +32,7 @@ env: CTF_TYPE: directory components: '["ocmcli", "helminstaller", "helmdemo", "subchartsdemo", "ecrplugin"]' PLATFORMS: 'linux/amd64' + IMAGE_PLATFORMS: 'linux/amd64' # PLATFORMS: 'windows/amd64 darwin/arm64 darwin/amd64 linux/amd64 linux/arm64' jobs: @@ -93,6 +94,7 @@ jobs: CTF_TYPE=${{ env.CTF_TYPE }} \ EFFECTIVE_VERSION=${{ inputs.effective-version }} \ PLATFORMS=${{ env.PLATFORMS }} \ + IMAGE_PLATFORMS=${{ env.IMAGE_PLATFORMS }} \ make ctf descriptor describe - name: Upload CTF uses: actions/upload-artifact@v4 From 97e8ce47296c6a34570d5a4f33e94ed40896c9a5 Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Tue, 12 Nov 2024 15:04:48 +0100 Subject: [PATCH 04/11] chore: correct upload ctf flag --- .github/workflows/components.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/components.yaml b/.github/workflows/components.yaml index 353be9966..657fd001f 100644 --- a/.github/workflows/components.yaml +++ b/.github/workflows/components.yaml @@ -159,7 +159,7 @@ jobs: done - name: Upload aggregated CTF # only upload the artifact if we are not on a PR - if: inputs.upload-ctf == 'true' + if: inputs.upload-ctf uses: actions/upload-artifact@v4 with: if-no-files-found: error From e7aa47e027ed61b2f9ab69657d9c294b51b6a644 Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Tue, 12 Nov 2024 15:50:32 +0100 Subject: [PATCH 05/11] chore: setup multi arch components --- .github/workflows/components.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/components.yaml b/.github/workflows/components.yaml index 657fd001f..49f6ed440 100644 --- a/.github/workflows/components.yaml +++ b/.github/workflows/components.yaml @@ -31,9 +31,8 @@ env: REF: ${{ inputs.ref == '' && github.ref || inputs.ref }} CTF_TYPE: directory components: '["ocmcli", "helminstaller", "helmdemo", "subchartsdemo", "ecrplugin"]' - PLATFORMS: 'linux/amd64' - IMAGE_PLATFORMS: 'linux/amd64' -# PLATFORMS: 'windows/amd64 darwin/arm64 darwin/amd64 linux/amd64 linux/arm64' + IMAGE_PLATFORMS: 'linux/amd64 linux/arm64' + PLATFORMS: 'windows/amd64 darwin/arm64 darwin/amd64 linux/amd64 linux/arm64' jobs: define-matrix: From 833e9e55c8df95ad78124e56f52306409eb21ce8 Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Tue, 12 Nov 2024 17:14:54 +0100 Subject: [PATCH 06/11] chore: allow empty effective version --- .github/workflows/components.yaml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/components.yaml b/.github/workflows/components.yaml index 49f6ed440..0a5e418ab 100644 --- a/.github/workflows/components.yaml +++ b/.github/workflows/components.yaml @@ -89,12 +89,17 @@ jobs: - name: CTF run: | cd components/${{ matrix.component }} - PATH=$PATH:$(go env GOPATH)/bin \ - CTF_TYPE=${{ env.CTF_TYPE }} \ - EFFECTIVE_VERSION=${{ inputs.effective-version }} \ - PLATFORMS=${{ env.PLATFORMS }} \ - IMAGE_PLATFORMS=${{ env.IMAGE_PLATFORMS }} \ - make ctf descriptor describe + ARGS="PATH=$PATH:$(go env GOPATH)/bin CTF_TYPE=${{ env.CTF_TYPE }}" + if [ -n "${{ inputs.effective-version }}" ]; then + ARGS="$ARGS EFFECTIVE_VERSION=${{ inputs.effective-version }}" + fi + if [ -n "${{ env.PLATFORMS }}" ]; then + ARGS="$ARGS PLATFORMS=${{ env.PLATFORMS }}" + fi + if [ -n "${{ env.IMAGE_PLATFORMS }}" ]; then + ARGS="$ARGS IMAGE_PLATFORMS=${{ env.IMAGE_PLATFORMS }}" + fi + $ARGS make ctf descriptor describe - name: Upload CTF uses: actions/upload-artifact@v4 with: From 86687f213a1f73057fd77eae22d8c1fe21f9c95c Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Wed, 13 Nov 2024 10:00:46 +0100 Subject: [PATCH 07/11] chore: allow empty EFFECTIVE_VERSION if set to empty value --- .github/workflows/components.yaml | 19 ++++++++----------- Makefile | 5 +++++ components/demoplugin/Makefile | 6 +++++- components/ecrplugin/Makefile | 6 +++++- components/helmdemo/Makefile | 6 +++++- components/helminstaller/Makefile | 6 +++++- components/ocmcli/Makefile | 6 +++++- components/subchartsdemo/Makefile | 6 +++++- 8 files changed, 43 insertions(+), 17 deletions(-) diff --git a/.github/workflows/components.yaml b/.github/workflows/components.yaml index 0a5e418ab..f0e796887 100644 --- a/.github/workflows/components.yaml +++ b/.github/workflows/components.yaml @@ -89,17 +89,14 @@ jobs: - name: CTF run: | cd components/${{ matrix.component }} - ARGS="PATH=$PATH:$(go env GOPATH)/bin CTF_TYPE=${{ env.CTF_TYPE }}" - if [ -n "${{ inputs.effective-version }}" ]; then - ARGS="$ARGS EFFECTIVE_VERSION=${{ inputs.effective-version }}" - fi - if [ -n "${{ env.PLATFORMS }}" ]; then - ARGS="$ARGS PLATFORMS=${{ env.PLATFORMS }}" - fi - if [ -n "${{ env.IMAGE_PLATFORMS }}" ]; then - ARGS="$ARGS IMAGE_PLATFORMS=${{ env.IMAGE_PLATFORMS }}" - fi - $ARGS make ctf descriptor describe + + PATH=$PATH:$(go env GOPATH)/bin \ + CTF_TYPE=${{ env.CTF_TYPE }} \ + EFFECTIVE_VERSION=${{ inputs.effective-version }} \ + PLATFORMS="${{ env.PLATFORMS }}" \ + IMAGE_PLATFORMS="${{ env.IMAGE_PLATFORMS }}" \ + make \ + ctf descriptor describe - name: Upload CTF uses: actions/upload-artifact@v4 with: diff --git a/Makefile b/Makefile index 405434ff3..c5d202b4d 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,12 @@ REPO_ROOT := $(shell dirname $(realpath $(l GITHUBORG ?= open-component-model OCMREPO ?= ghcr.io/$(GITHUBORG)/ocm VERSION := $(shell go run api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) +COMMIT = $(shell git rev-parse HEAD) +# if EFFECTIVE_VERSION is not set, set it to VERSION+HEAD +# this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string +ifeq ($(EFFECTIVE_VERSION),) EFFECTIVE_VERSION := $(VERSION)+$(shell git rev-parse HEAD) +endif GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) COMMIT := $(shell git rev-parse --verify HEAD) diff --git a/components/demoplugin/Makefile b/components/demoplugin/Makefile index 024e92fb2..211a852e9 100644 --- a/components/demoplugin/Makefile +++ b/components/demoplugin/Makefile @@ -9,7 +9,11 @@ CTF_TYPE ?= directory REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT = $(shell git rev-parse HEAD) -EFFECTIVE_VERSION ?= $(VERSION)+$(COMMIT) +# if EFFECTIVE_VERSION is not set, set it to VERSION+COMMIT +# this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string +ifeq ($(EFFECTIVE_VERSION),) +EFFECTIVE_VERSION := $(VERSION)+$(COMMIT) +endif GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) CMDSRCS=$(shell find $(REPO_ROOT)/cmds/$(NAME) -type f) diff --git a/components/ecrplugin/Makefile b/components/ecrplugin/Makefile index cb0f76802..f5e8c2714 100644 --- a/components/ecrplugin/Makefile +++ b/components/ecrplugin/Makefile @@ -10,7 +10,11 @@ CTF_TYPE ?= directory REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT = $(shell git rev-parse HEAD) -EFFECTIVE_VERSION ?= $(VERSION)+$(COMMIT) +# if EFFECTIVE_VERSION is not set, set it to VERSION+COMMIT +# this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string +ifeq ($(EFFECTIVE_VERSION),) +EFFECTIVE_VERSION := $(VERSION)+$(COMMIT) +endif GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) CMDSRCS=$(shell find $(REPO_ROOT)/cmds/$(NAME) -type f) diff --git a/components/helmdemo/Makefile b/components/helmdemo/Makefile index 34da222a3..2f49401ff 100644 --- a/components/helmdemo/Makefile +++ b/components/helmdemo/Makefile @@ -10,7 +10,11 @@ HELMINSTCOMP = $(PROVIDER)/toi/installers/helminstaller REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT = $(shell git rev-parse HEAD) -EFFECTIVE_VERSION ?= $(VERSION)-$(COMMIT) +# if EFFECTIVE_VERSION is not set, set it to VERSION-COMMIT +# this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string +ifeq ($(EFFECTIVE_VERSION),) +EFFECTIVE_VERSION := $(VERSION)-$(COMMIT) +endif HELMINSTVERSION ?= $(VERSION) CREDS ?= diff --git a/components/helminstaller/Makefile b/components/helminstaller/Makefile index 0b5dd01f9..cc51f01a8 100644 --- a/components/helminstaller/Makefile +++ b/components/helminstaller/Makefile @@ -11,7 +11,11 @@ CTF_TYPE ?= directory REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION := $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT := $(shell git rev-parse --verify HEAD) -EFFECTIVE_VERSION ?= $(VERSION)-$(COMMIT) +# if EFFECTIVE_VERSION is not set, set it to VERSION-COMMIT +# this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string +ifeq ($(EFFECTIVE_VERSION),) +EFFECTIVE_VERSION := $(VERSION)-$(COMMIT) +endif GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) PLATFORM := $(shell go env GOOS)/$(shell go env GOARCH) CACHE_DIR := $(shell go env GOCACHE) diff --git a/components/ocmcli/Makefile b/components/ocmcli/Makefile index 2ac1c8f94..3dd4df1cb 100644 --- a/components/ocmcli/Makefile +++ b/components/ocmcli/Makefile @@ -14,7 +14,11 @@ REPO_ROOT := $(dir $(realpath $(lastword $( GIT_TREE_STATE = $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT = $(shell git rev-parse HEAD) -EFFECTIVE_VERSION ?= $(VERSION)+$(COMMIT) +# if EFFECTIVE_VERSION is not set, set it to VERSION+COMMIT +# this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string +ifeq ($(EFFECTIVE_VERSION),) +EFFECTIVE_VERSION := $(VERSION)+$(COMMIT) +endif PLATFORM_OS := $(shell go env GOOS) PLATFORM_ARCH := $(shell go env GOARCH) diff --git a/components/subchartsdemo/Makefile b/components/subchartsdemo/Makefile index 59f424806..fef4796dd 100644 --- a/components/subchartsdemo/Makefile +++ b/components/subchartsdemo/Makefile @@ -15,7 +15,11 @@ REPO_ROOT := $(shell dirname $(realpath $(la GIT_TREE_STATE = $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) VERSION = $(shell go run $(REPO_ROOT)/api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) COMMIT = $(shell git rev-parse HEAD) -EFFECTIVE_VERSION ?= $(VERSION)-$(COMMIT) +# if EFFECTIVE_VERSION is not set, set it to VERSION-COMMIT +# this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string +ifeq ($(EFFECTIVE_VERSION),) +EFFECTIVE_VERSION := $(VERSION)-$(COMMIT) +endif HELMINSTVERSION ?= $(VERSION) CREDS ?= From b06263a7f58b13333872b4731a242ba4b5387f37 Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Wed, 13 Nov 2024 10:26:37 +0100 Subject: [PATCH 08/11] chore: separate helminstaller image platform and platform --- components/helminstaller/Makefile | 6 +++--- components/helminstaller/component-constructor.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/helminstaller/Makefile b/components/helminstaller/Makefile index cc51f01a8..a599024ac 100644 --- a/components/helminstaller/Makefile +++ b/components/helminstaller/Makefile @@ -5,7 +5,7 @@ IMAGE := $(NAME) COMPONENT := $(PROVIDER)/toi/installers/$(NAME) OCMREPO ?= ghcr.io/$(GITHUBORG)/ocm MULTI ?= true -PLATFORMS ?= linux/amd64 linux/arm64 +IMAGE_PLATFORMS ?= linux/amd64 linux/arm64 CTF_TYPE ?= directory REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. @@ -68,7 +68,7 @@ $(GEN)/ctf: $(OCM_BIN) $(GEN)/.exists $(GEN)/image.$(NAME)$(FLAGSUF) component-c PROVIDER="$(PROVIDER)" \ COMMIT="$(COMMIT)" \ GEN="$(GEN)" \ - PLATFORMS="$(PLATFORMS)" \ + IMAGE_PLATFORMS="$(IMAGE_PLATFORMS)" \ MULTI="$(MULTI)" \ IMAGE="$(IMAGE):$(VERSION)" \ component-constructor.yaml @@ -98,7 +98,7 @@ push-image: multi: $(GEN)/image.$(NAME).multi $(GEN)/image.$(NAME).multi: $(GEN)/.exists Dockerfile $(CMDSRCS) $(OCMSRCS) - for i in $(PLATFORMS); do \ + for i in $(IMAGE_PLATFORMS); do \ tag=$$(echo $$i | sed -e s:/:-:g); \ echo building platform $$i; \ docker buildx build --load -t $(IMAGE):$(VERSION)-$$tag --platform $$i --file Dockerfile $(REPO_ROOT) \ diff --git a/components/helminstaller/component-constructor.yaml b/components/helminstaller/component-constructor.yaml index a2223653a..c78b2c88c 100644 --- a/components/helminstaller/component-constructor.yaml +++ b/components/helminstaller/component-constructor.yaml @@ -21,5 +21,5 @@ components: input: type: (( bool(values.MULTI) ? "dockermulti" :"docker" )) repository: (( index(values.IMAGE, ":") >= 0 ? substr(values.IMAGE,0,index(values.IMAGE,":")) :values.IMAGE )) - variants: (( bool(values.MULTI) ? map[split(" ", values.PLATFORMS)|v|-> values.IMAGE "-" replace(v,"/","-")] :~~ )) + variants: (( bool(values.MULTI) ? map[split(" ", values.IMAGE_PLATFORMS)|v|-> values.IMAGE "-" replace(v,"/","-")] :~~ )) path: (( !bool(values.MULTI) ? values.IMAGE :~~ )) \ No newline at end of file From 70e1fc868086fdca3270209cb9914cfe0893d91d Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Fri, 15 Nov 2024 15:47:35 +0100 Subject: [PATCH 09/11] chore: make sure to use correct COMMIT variables in Makefiles Co-authored-by: Hilmar Falkenberg --- Makefile | 4 ++-- components/demoplugin/Makefile | 2 +- components/ecrplugin/Makefile | 2 +- components/helmdemo/Makefile | 2 +- components/ocmcli/Makefile | 2 +- components/subchartsdemo/Makefile | 2 +- examples/make/Makefile | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index c5d202b4d..fb0fa6847 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,11 @@ REPO_ROOT := $(shell dirname $(realpath $(l GITHUBORG ?= open-component-model OCMREPO ?= ghcr.io/$(GITHUBORG)/ocm VERSION := $(shell go run api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) -COMMIT = $(shell git rev-parse HEAD) +COMMIT = $(shell git rev-parse --verify HEAD) # if EFFECTIVE_VERSION is not set, set it to VERSION+HEAD # this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string ifeq ($(EFFECTIVE_VERSION),) -EFFECTIVE_VERSION := $(VERSION)+$(shell git rev-parse HEAD) +EFFECTIVE_VERSION := $(VERSION)+$(COMMIT) endif GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) COMMIT := $(shell git rev-parse --verify HEAD) diff --git a/components/demoplugin/Makefile b/components/demoplugin/Makefile index 211a852e9..ce83a088b 100644 --- a/components/demoplugin/Makefile +++ b/components/demoplugin/Makefile @@ -8,7 +8,7 @@ CTF_TYPE ?= directory REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) -COMMIT = $(shell git rev-parse HEAD) +COMMIT = $(shell git rev-parse --verify HEAD) # if EFFECTIVE_VERSION is not set, set it to VERSION+COMMIT # this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string ifeq ($(EFFECTIVE_VERSION),) diff --git a/components/ecrplugin/Makefile b/components/ecrplugin/Makefile index f5e8c2714..548be8751 100644 --- a/components/ecrplugin/Makefile +++ b/components/ecrplugin/Makefile @@ -9,7 +9,7 @@ CTF_TYPE ?= directory REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) -COMMIT = $(shell git rev-parse HEAD) +COMMIT = $(shell git rev-parse --verify HEAD) # if EFFECTIVE_VERSION is not set, set it to VERSION+COMMIT # this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string ifeq ($(EFFECTIVE_VERSION),) diff --git a/components/helmdemo/Makefile b/components/helmdemo/Makefile index 2f49401ff..967286dfa 100644 --- a/components/helmdemo/Makefile +++ b/components/helmdemo/Makefile @@ -9,7 +9,7 @@ HELMINSTCOMP = $(PROVIDER)/toi/installers/helminstaller REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) -COMMIT = $(shell git rev-parse HEAD) +COMMIT = $(shell git rev-parse --verify HEAD) # if EFFECTIVE_VERSION is not set, set it to VERSION-COMMIT # this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string ifeq ($(EFFECTIVE_VERSION),) diff --git a/components/ocmcli/Makefile b/components/ocmcli/Makefile index 3dd4df1cb..b9ca7a137 100644 --- a/components/ocmcli/Makefile +++ b/components/ocmcli/Makefile @@ -13,7 +13,7 @@ CTF_TYPE ?= directory REPO_ROOT := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))../.. GIT_TREE_STATE = $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) VERSION = $(shell go run ../../api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) -COMMIT = $(shell git rev-parse HEAD) +COMMIT = $(shell git rev-parse --verify HEAD) # if EFFECTIVE_VERSION is not set, set it to VERSION+COMMIT # this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string ifeq ($(EFFECTIVE_VERSION),) diff --git a/components/subchartsdemo/Makefile b/components/subchartsdemo/Makefile index fef4796dd..618396874 100644 --- a/components/subchartsdemo/Makefile +++ b/components/subchartsdemo/Makefile @@ -14,7 +14,7 @@ PODINFO_CHART_VERSION = 6.3.5 REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../.. GIT_TREE_STATE = $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) VERSION = $(shell go run $(REPO_ROOT)/api/version/generate/release_generate.go print-rc-version $(CANDIDATE)) -COMMIT = $(shell git rev-parse HEAD) +COMMIT = $(shell git rev-parse --verify HEAD) # if EFFECTIVE_VERSION is not set, set it to VERSION-COMMIT # this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string ifeq ($(EFFECTIVE_VERSION),) diff --git a/examples/make/Makefile b/examples/make/Makefile index 98fa2abac..c8efdbe94 100644 --- a/examples/make/Makefile +++ b/examples/make/Makefile @@ -3,7 +3,7 @@ OCI_REPO := ghcr.io/mandelsoft/cnudie REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) VERSION = $(shell cat $(REPO_ROOT)/VERSION) -COMMIT = $(shell git rev-parse HEAD) +COMMIT = $(shell git rev-parse --verify HEAD) EFFECTIVE_VERSION = $(VERSION)-$(COMMIT) .PHONY: ctf From f67f8ebdc0b34ebc640783d46876ab777c248b60 Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Fri, 15 Nov 2024 15:50:01 +0100 Subject: [PATCH 10/11] chore: remove unnecessary mkdir because its part of the download already --- .github/workflows/release.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3b8fbc36b..25d224dab 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -135,7 +135,6 @@ jobs: path: gen/downloaded-ctfs - name: Move CTF into correct directory to be recognized by the release process run: | - mkdir -p ${{ github.workspace }}/gen mv \ ${{ github.workspace }}/gen/downloaded-ctfs/ctf-aggregated \ ${{ github.workspace }}/gen/ctf From 5d74e1f763499c0c30e66ea7f0ca1034a6a6b13b Mon Sep 17 00:00:00 2001 From: jakobmoellerdev Date: Wed, 20 Nov 2024 11:05:33 +0100 Subject: [PATCH 11/11] chore: unify commit appending Co-authored-by: Hilmar Falkenberg --- Makefile | 1 - components/helmdemo/Makefile | 2 +- components/helminstaller/Makefile | 2 +- components/subchartsdemo/Makefile | 2 +- examples/make/Makefile | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index fb0fa6847..726de3d3f 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,6 @@ ifeq ($(EFFECTIVE_VERSION),) EFFECTIVE_VERSION := $(VERSION)+$(COMMIT) endif GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) -COMMIT := $(shell git rev-parse --verify HEAD) CONTROLLER_TOOLS_VERSION ?= v0.14.0 CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen diff --git a/components/helmdemo/Makefile b/components/helmdemo/Makefile index 967286dfa..351a5626b 100644 --- a/components/helmdemo/Makefile +++ b/components/helmdemo/Makefile @@ -13,7 +13,7 @@ COMMIT = $(shell git rev-parse --verify # if EFFECTIVE_VERSION is not set, set it to VERSION-COMMIT # this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string ifeq ($(EFFECTIVE_VERSION),) -EFFECTIVE_VERSION := $(VERSION)-$(COMMIT) +EFFECTIVE_VERSION := $(VERSION)+$(COMMIT) endif HELMINSTVERSION ?= $(VERSION) diff --git a/components/helminstaller/Makefile b/components/helminstaller/Makefile index a599024ac..761c0fd44 100644 --- a/components/helminstaller/Makefile +++ b/components/helminstaller/Makefile @@ -14,7 +14,7 @@ COMMIT := $(shell git rev-parse --verify # if EFFECTIVE_VERSION is not set, set it to VERSION-COMMIT # this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string ifeq ($(EFFECTIVE_VERSION),) -EFFECTIVE_VERSION := $(VERSION)-$(COMMIT) +EFFECTIVE_VERSION := $(VERSION)+$(COMMIT) endif GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty) PLATFORM := $(shell go env GOOS)/$(shell go env GOARCH) diff --git a/components/subchartsdemo/Makefile b/components/subchartsdemo/Makefile index 618396874..7f67b5a7c 100644 --- a/components/subchartsdemo/Makefile +++ b/components/subchartsdemo/Makefile @@ -18,7 +18,7 @@ COMMIT = $(shell git rev-parse --verify # if EFFECTIVE_VERSION is not set, set it to VERSION-COMMIT # this is not the same as '?=' because it will also set the value if EFFECTIVE_VERSION is set to an empty string ifeq ($(EFFECTIVE_VERSION),) -EFFECTIVE_VERSION := $(VERSION)-$(COMMIT) +EFFECTIVE_VERSION := $(VERSION)+$(COMMIT) endif HELMINSTVERSION ?= $(VERSION) diff --git a/examples/make/Makefile b/examples/make/Makefile index c8efdbe94..24b19f968 100644 --- a/examples/make/Makefile +++ b/examples/make/Makefile @@ -4,7 +4,7 @@ OCI_REPO := ghcr.io/mandelsoft/cnudie REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) VERSION = $(shell cat $(REPO_ROOT)/VERSION) COMMIT = $(shell git rev-parse --verify HEAD) -EFFECTIVE_VERSION = $(VERSION)-$(COMMIT) +EFFECTIVE_VERSION = $(VERSION)+$(COMMIT) .PHONY: ctf ctf: ca ## Create CTF from component archive