diff --git a/.github/workflows/tools-releases.yml b/.github/workflows/tools-releases.yml index 8c72fd827..aeaf1f99c 100644 --- a/.github/workflows/tools-releases.yml +++ b/.github/workflows/tools-releases.yml @@ -10,6 +10,7 @@ on: permissions: contents: write + pull-requests: write jobs: build-and-push: @@ -53,6 +54,16 @@ jobs: name: envtest-${{ env.KUBERNETES_VERSION }} draft: true make_latest: false - files: out/envtest-*.tar.gz + files: | + out/envtest-*.tar.gz + out/envtest-*.tar.gz.sha512 fail_on_unmatched_files: true body_path: out/release-notes.md + - name: Create Pull Request + uses: peter-evans/create-pull-request@9153d834b60caba6d51c9b9510b087acf9f33f83 # tag=v6.0.4 + with: + commit-message: Promote envtest release for Kubernetes ${{ env.KUBERNETES_VERSION }} + title: ":seedling: Promotion of envtest release for Kubernetes ${{ env.KUBERNETES_VERSION }}" + branch: promote-envtest-${{ env.KUBERNETES_VERSION }} + add-paths: | + envtest-releases.yaml diff --git a/Makefile b/Makefile index 4d91d8d5d..e8424fd8c 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,8 @@ export GOPROXY export GO111MODULE=on # Tools. +ENVTEST_DIR := hack/envtest +ENVTEST_MATRIX_DIR := $(ENVTEST_DIR)/_matrix TOOLS_DIR := hack/tools TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin) GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/golangci-lint) @@ -120,17 +122,14 @@ release-envtest: clean-release ## Build the envtest binaries by operating system .PHONY: release-envtest-docker-build release-envtest-docker-build: $(RELEASE_DIR) ## Build the envtest binaries. - @: $(if $(GO_VERSION),,$(error GO_VERSION is not set)) @: $(if $(KUBERNETES_VERSION),,$(error KUBERNETES_VERSION is not set)) - @: $(if $(ETCD_VERSION),,$(error ETCD_VERSION is not set)) @: $(if $(OS),,$(error OS is not set)) @: $(if $(ARCH),,$(error ARCH is not set)) - docker buildx build \ --file ./hack/envtest/$(OS)/Dockerfile \ - --build-arg GO_VERSION=$(GO_VERSION) \ --build-arg KUBERNETES_VERSION=$(KUBERNETES_VERSION) \ - --build-arg ETCD_VERSION=$(ETCD_VERSION) \ + --build-arg GO_VERSION=$(shell yq eval '.go' $(ENVTEST_MATRIX_DIR)/$(KUBERNETES_VERSION).yaml) \ + --build-arg ETCD_VERSION=$(shell yq eval '.etcd' $(ENVTEST_MATRIX_DIR)/$(KUBERNETES_VERSION).yaml) \ --build-arg OS=$(OS) \ --build-arg ARCH=$(ARCH) \ --tag sigs.k8s.io/controller-tools/envtest:$(KUBERNETES_VERSION)-$(OS)-$(ARCH) \ diff --git a/envtest-releases.yaml b/envtest-releases.yaml new file mode 100644 index 000000000..3a59fc4e7 --- /dev/null +++ b/envtest-releases.yaml @@ -0,0 +1 @@ +releases: diff --git a/hack/envtest/_matrix/v1.28.0.yaml b/hack/envtest/_matrix/v1.28.0.yaml index 83bf3ddd8..6a369c454 100644 --- a/hack/envtest/_matrix/v1.28.0.yaml +++ b/hack/envtest/_matrix/v1.28.0.yaml @@ -1,2 +1,3 @@ go: 1.21 etcd: v3.5.9 + diff --git a/hack/envtest/release-notes.sh b/hack/envtest/release-notes.sh index 88fa97029..862b4ecd1 100755 --- a/hack/envtest/release-notes.sh +++ b/hack/envtest/release-notes.sh @@ -26,25 +26,31 @@ if [ -z "${KUBERNETES_VERSION}" ]; then exit 1 fi -# For each file in out/*.tar.gz, build a out/release-notes.md files containing a table -# with every file and their respective hash +# Create the releases.yaml file in hack/envtest if it does not exist +if [ ! -f "${ROOT}"/envtest-releases.yaml ]; then + echo "releases:" > "${ROOT}"/envtest-releases.yaml +fi # Create the release notes file echo -e "# Envtest Kubernetes ${KUBERNETES_VERSION} Binaries\n" > out/release-notes.md +# Add the newly built Kubernetes version to the releases.yaml file with yq as an object key under releases +yq eval ".releases += {\"${KUBERNETES_VERSION}\": {}}" -i "${ROOT}"/envtest-releases.yaml + # Create the table header echo "filename | sha512 hash" >> out/release-notes.md echo "-------- | -----------" >> out/release-notes.md for file in "${ROOT}"/out/*.tar.gz; do - # Get the file name file_name=$(basename "${file}") - - # Get the hash of the file file_hash=$(awk '{ print $1 }' < "${file}.sha512") + self_link=https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-${KUBERNETES_VERSION}/${file_name} - # Add the file and hash to the release notes - echo "| [${file_name}](https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-${KUBERNETES_VERSION}/${file_name}) | ${file_hash} |" >> out/release-notes.md + # Add the file and hash to the release notes and yaml + echo "| [${file_name}](${self_link}) | ${file_hash} |" >> out/release-notes.md + yq eval \ + ".releases[\"${KUBERNETES_VERSION}\"] += {\"${file_name}\": {\"hash\": \"${file_hash}\", \"self_link\": \"${self_link}\"}}" \ + -i "${ROOT}"/envtest-releases.yaml done # Close the table