From 46e8cca5724fdc20ca96986c9788f563a14d8374 Mon Sep 17 00:00:00 2001 From: Vince Prignano Date: Tue, 16 Apr 2024 13:22:25 -0700 Subject: [PATCH] Add hash and release notes Signed-off-by: Vince Prignano --- .github/workflows/tools-releases.yml | 9 ++--- Makefile | 7 ++-- hack/envtest/_matrix/v1.28.0.yaml | 1 - hack/envtest/darwin/Dockerfile | 2 ++ hack/envtest/linux/Dockerfile | 2 ++ hack/envtest/release-notes.sh | 51 ++++++++++++++++++++++++++++ hack/envtest/windows/Dockerfile | 2 ++ 7 files changed, 64 insertions(+), 10 deletions(-) create mode 100755 hack/envtest/release-notes.sh diff --git a/.github/workflows/tools-releases.yml b/.github/workflows/tools-releases.yml index 475608ed6..c298cb5b7 100644 --- a/.github/workflows/tools-releases.yml +++ b/.github/workflows/tools-releases.yml @@ -27,7 +27,7 @@ jobs: id: release-version run: | if [[ ${{ steps.changed-files.outputs.all_changed_files_count }} != 1 ]]; then - echo "One Kubernetes patch version files should be changed to create a package, found ${{ steps.changed-files.outputs.all_changed_files_count }}" + echo "One Kubernetes patch version files should be changed for a release, found ${{ steps.changed-files.outputs.all_changed_files_count }}" exit 1 fi @@ -43,16 +43,17 @@ jobs: done - name: Build packages run: | - make release-package-envtest \ + make release-envtest \ KUBERNETES_VERSION=${{ env.KUBERNETES_VERSION }} \ GO_VERSION=${{ env.GO_VERSION }} \ ETCD_VERSION=${{ env.ETCD_VERSION }} - name: Release uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # tag=v2.0.4 with: - name: envtest/${{ env.KUBERNETES_VERSION }} + name: envtest-${{ env.KUBERNETES_VERSION }} draft: true prerelease: true make_latest: false - files: out/* + files: out/envtest-*.tar.gz fail_on_unmatched_files: true + body_path: out/release-notes.md diff --git a/Makefile b/Makefile index ed8fa49a5..4d91d8d5d 100644 --- a/Makefile +++ b/Makefile @@ -108,11 +108,7 @@ $(RELEASE_DIR): mkdir -p $(RELEASE_DIR)/ .PHONY: release-envtest -release-envtest: - ./hack/envtest/build.sh - -.PHONY: release-package-envtest -release-package-envtest: clean-release ## Build the envtest binaries by operating system. +release-envtest: clean-release ## Build the envtest binaries by operating system. OS=linux ARCH=amd64 $(MAKE) release-envtest-docker-build OS=linux ARCH=arm64 $(MAKE) release-envtest-docker-build OS=linux ARCH=ppc64le $(MAKE) release-envtest-docker-build @@ -120,6 +116,7 @@ release-package-envtest: clean-release ## Build the envtest binaries by operatin 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/release-notes.sh .PHONY: release-envtest-docker-build release-envtest-docker-build: $(RELEASE_DIR) ## Build the envtest binaries. diff --git a/hack/envtest/_matrix/v1.28.0.yaml b/hack/envtest/_matrix/v1.28.0.yaml index 6a369c454..83bf3ddd8 100644 --- a/hack/envtest/_matrix/v1.28.0.yaml +++ b/hack/envtest/_matrix/v1.28.0.yaml @@ -1,3 +1,2 @@ go: 1.21 etcd: v3.5.9 - diff --git a/hack/envtest/darwin/Dockerfile b/hack/envtest/darwin/Dockerfile index 74f8a60c0..c5746b5bf 100644 --- a/hack/envtest/darwin/Dockerfile +++ b/hack/envtest/darwin/Dockerfile @@ -53,6 +53,7 @@ RUN curl -sfLO https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/ # Package into tarball. RUN tar -czvf /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz $DEST +RUN sha512sum /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz > /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz.sha512 # Build the final image with the binaries. FROM scratch @@ -60,3 +61,4 @@ ARG OS ARG ARCH ARG KUBERNETES_VERSION COPY --from=builder /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz / +COPY --from=builder /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz.sha512 / diff --git a/hack/envtest/linux/Dockerfile b/hack/envtest/linux/Dockerfile index 9625e17a2..cbc743fd2 100644 --- a/hack/envtest/linux/Dockerfile +++ b/hack/envtest/linux/Dockerfile @@ -47,6 +47,7 @@ RUN curl -sfLO https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/ # Package into tarball. RUN tar -czvf /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz $DEST +RUN sha512sum /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz > /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz.sha512 # Build the final image with the binaries. FROM scratch @@ -54,3 +55,4 @@ ARG OS ARG ARCH ARG KUBERNETES_VERSION COPY --from=builder /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz / +COPY --from=builder /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz.sha512 / diff --git a/hack/envtest/release-notes.sh b/hack/envtest/release-notes.sh new file mode 100755 index 000000000..88fa97029 --- /dev/null +++ b/hack/envtest/release-notes.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# Copyright 2024 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail +set -x + +ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. + +# This script is used to build the test binaries for the envtest package. +if [ -z "${KUBERNETES_VERSION}" ]; then + echo "Missing KUBERNETES_VERSION environment variable" + 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 release notes file +echo -e "# Envtest Kubernetes ${KUBERNETES_VERSION} Binaries\n" > out/release-notes.md + +# 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") + + # 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 +done + +# Close the table +echo "" >> "${ROOT}"/out/release-notes.md diff --git a/hack/envtest/windows/Dockerfile b/hack/envtest/windows/Dockerfile index b02c2bca1..81ee2188c 100644 --- a/hack/envtest/windows/Dockerfile +++ b/hack/envtest/windows/Dockerfile @@ -53,6 +53,7 @@ RUN curl -sfLO https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/ # Package into tarball. RUN tar -czvf /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz $DEST +RUN sha512sum /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz > /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz.sha512 # Build the final image with the binaries. FROM scratch @@ -60,3 +61,4 @@ ARG OS ARG ARCH ARG KUBERNETES_VERSION COPY --from=builder /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz / +COPY --from=builder /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz.sha512 /