From e1cb690d4c54ab58ff3f119304877b77901bb56f Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Fri, 27 Dec 2024 14:42:36 +0100 Subject: [PATCH] Refactor envtest release script to allow local execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Büringer buringerst@vmware.com --- .github/workflows/tools-releases.yml | 10 ---------- Makefile | 1 - ...pdate-releases.sh => update-envtest-releases.sh} | 13 +++++++++---- 3 files changed, 9 insertions(+), 15 deletions(-) rename hack/envtest/{update-releases.sh => update-envtest-releases.sh} (74%) diff --git a/.github/workflows/tools-releases.yml b/.github/workflows/tools-releases.yml index a7106c72f..65c8e4ad4 100644 --- a/.github/workflows/tools-releases.yml +++ b/.github/workflows/tools-releases.yml @@ -48,13 +48,3 @@ jobs: out/envtest-*.tar.gz out/envtest-*.tar.gz.sha512 fail_on_unmatched_files: true - - name: Create Pull Request - uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # tag=v7.0.5 - with: - commit-message: Promote envtest release for Kubernetes ${{ env.KUBERNETES_VERSION }} - title: ":seedling: Promotion of envtest release for Kubernetes ${{ env.KUBERNETES_VERSION }}" - body: | - This PR promotes the 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 c00d60909..09df92d7a 100644 --- a/Makefile +++ b/Makefile @@ -138,7 +138,6 @@ release-envtest: clean-release ## Build the envtest binaries by operating system OS=darwin ARCH=amd64 $(MAKE) release-envtest-docker-build OS=darwin ARCH=arm64 $(MAKE) release-envtest-docker-build OS=windows ARCH=amd64 $(MAKE) release-envtest-docker-build - ./hack/envtest/update-releases.sh .PHONY: release-envtest-docker-build release-envtest-docker-build: $(RELEASE_DIR) ## Build the envtest binaries. diff --git a/hack/envtest/update-releases.sh b/hack/envtest/update-envtest-releases.sh similarity index 74% rename from hack/envtest/update-releases.sh rename to hack/envtest/update-envtest-releases.sh index 21ca91f85..1bb3a9a0e 100755 --- a/hack/envtest/update-releases.sh +++ b/hack/envtest/update-envtest-releases.sh @@ -33,11 +33,16 @@ fi # 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 -for file in "${ROOT}"/out/*.tar.gz; do - file_name=$(basename "${file}") - file_hash=$(awk '{ print $1 }' < "${file}.sha512") - self_link=https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-${KUBERNETES_VERSION}/${file_name} +sha_files=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/kubernetes-sigs/controller-tools/releases/tags/envtest-${KUBERNETES_VERSION} | + jq '.assets[] | select(.name | contains("sha512")) | .name' -r) +for sha_file in ${sha_files}; do + file_name=${sha_file%".sha512"} + file_hash=$(curl -L https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-${KUBERNETES_VERSION}/${sha_file} | awk '{ print $1 }') + self_link=https://github.com/kubernetes-sigs/controller-tools/releases/download/envtest-${KUBERNETES_VERSION}/${file_name} yq eval \ ".releases[\"${KUBERNETES_VERSION}\"] += {\"${file_name}\": {\"hash\": \"${file_hash}\", \"selfLink\": \"${self_link}\"}}" \ -i "${ROOT}"/envtest-releases.yaml