Skip to content

Commit

Permalink
Add hash and release notes
Browse files Browse the repository at this point in the history
Signed-off-by: Vince Prignano <vincepri@redhat.com>
  • Loading branch information
vincepri committed Apr 16, 2024
1 parent 018a41e commit 46e8cca
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 10 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/tools-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,15 @@ $(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
OS=linux ARCH=s390x $(MAKE) release-envtest-docker-build
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.
Expand Down
1 change: 0 additions & 1 deletion hack/envtest/_matrix/v1.28.0.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
go: 1.21
etcd: v3.5.9

2 changes: 2 additions & 0 deletions hack/envtest/darwin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ 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
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 /
2 changes: 2 additions & 0 deletions hack/envtest/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ 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
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 /
51 changes: 51 additions & 0 deletions hack/envtest/release-notes.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions hack/envtest/windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ 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
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 /

0 comments on commit 46e8cca

Please sign in to comment.