From b646372998aaefbfb3fe6b6827ed7ea8a066f4a2 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 10 Jul 2024 15:51:09 +0200 Subject: [PATCH 1/2] [no-relnote] Fix release tooling Signed-off-by: Evan Lezar --- hack/create-release.sh | 7 ++++--- hack/generate-changelog.sh | 31 +++++++++++++++++++++++---- hack/prepare-artifacts.sh | 43 ++++++++++++++++++++++++++++++++++---- 3 files changed, 70 insertions(+), 11 deletions(-) diff --git a/hack/create-release.sh b/hack/create-release.sh index e4ba90f5..532a65dc 100755 --- a/hack/create-release.sh +++ b/hack/create-release.sh @@ -30,8 +30,7 @@ REPOSITORY=NVIDIA/nvidia-container-toolkit echo "Creating draft release" ./hack/generate-changelog.sh --version ${VERSION} | \ - grep -v "### Version v" | \ - echo gh release create ${VERSION} --notes-file "-" \ + gh release create ${VERSION} --notes-file "-" \ --draft \ --title "${VERSION}" \ -R "${REPOSITORY}" \ @@ -43,5 +42,7 @@ echo "Uploading release artifacts for ${VERSION}" PACKAGE_ROOT=release-${VERSION}-${REPO} gh release upload ${VERSION} \ - ${PACKAGE_ROOT}/nvidia-container-toolkit-${VERSION}.*.tar.gz \ + ${PACKAGE_ROOT}/nvidia-container-toolkit_${VERSION#v}_*.tar.gz \ + ${PACKAGE_ROOT}/nvidia-container-toolkit_${VERSION#v}_checksums.txt \ + --clobber \ -R ${REPOSITORY} diff --git a/hack/generate-changelog.sh b/hack/generate-changelog.sh index 32d1ce38..c86d1718 100755 --- a/hack/generate-changelog.sh +++ b/hack/generate-changelog.sh @@ -66,6 +66,12 @@ remote=$( git remote -v | grep -E "NVIDIA/nvidia-container-toolkit(\.git)?\s" | >&2 echo "Detected remote as '${remote}'" git fetch ${remote} --tags +git tag | grep ${VERSION} > /dev/null +if [[ $? -ne 0 ]]; then + >&2 echo "${VERSION} is not a valid git reference, using HEAD" + VERSION=HEAD +fi + # if REFERENCE is not set, get the latest tag if [ -z "$REFERENCE" ]; then most_recent_tag=$(git tag --sort=-creatordate | head -1) @@ -79,9 +85,26 @@ fi >&2 echo "Using ${REFERENCE} as previous version" # Print the changelog -echo "# Changelog" +echo "## What's Changed" echo "" -echo "## $VERSION" - # Iterate over the commit messages and ignore the ones that start with "Merge" or "Bump" -git log --pretty=format:"%s" $REFERENCE..@ | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g' +git log --pretty=format:"%s" $REFERENCE..$VERSION -- ':!deployments/container' ':!tools' | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g' + +echo "" +echo "### Changes in the Toolkit Container" +echo "" +git log --pretty=format:"%s" $REFERENCE..$VERSION -- deployments/container tools | grep -Ev "(^Merge )|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g' + +LIB_NVIDIA_CONTAINER_REFERENCE=$( git ls-tree $REFERENCE third_party/libnvidia-container --object-only ) +LIB_NVIDIA_CONTAINER_VERSION=$( git ls-tree $VERSION third_party/libnvidia-container --object-only ) + +echo "" +if [[ $(git -C third_party/libnvidia-container log --pretty=format:"%s" $LIB_NVIDIA_CONTAINER_REFERENCE..$LIB_NVIDIA_CONTAINER_VERSION | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g' | wc -l) -gt 0 ]]; then +echo "### Changes in libnvidia-container" +echo "" +git -C third_party/libnvidia-container log --pretty=format:"%s" $LIB_NVIDIA_CONTAINER_REFERENCE..$LIB_NVIDIA_CONTAINER_VERSION | grep -Ev "(^Merge )|(^Bump)|(no-rel-?note)|(^---)" | sed 's/^\(.*\)/- \1/g' +fi + +echo "" +echo "**Full Changelog**: https://github.com/NVIDIA/nvidia-container-toolkit/compare/${REFERENCE}...${VERSION}" +echo "" diff --git a/hack/prepare-artifacts.sh b/hack/prepare-artifacts.sh index d6eb0bdb..3591a93f 100755 --- a/hack/prepare-artifacts.sh +++ b/hack/prepare-artifacts.sh @@ -47,7 +47,42 @@ PACKAGE_ROOT=release-${VERSION}-${REPO} PACKAGE_VERSION=${VERSION/-/\~} PACKAGE_VERSION=${PACKAGE_VERSION#v} -tar -czvf ${PACKAGE_ROOT}/nvidia-container-toolkit-${VERSION}.deb.amd64.tar.gz ${PACKAGE_ROOT}/packages/ubuntu18.04/amd64/*_${PACKAGE_VERSION}-1_amd64.deb -tar -czvf ${PACKAGE_ROOT}/nvidia-container-toolkit-${VERSION}.deb.arm64.tar.gz ${PACKAGE_ROOT}/packages/ubuntu18.04/arm64/*_${PACKAGE_VERSION}-1_arm64.deb -tar -czvf ${PACKAGE_ROOT}/nvidia-container-toolkit-${VERSION}.rpm.aarch64.tar.gz ${PACKAGE_ROOT}/packages/centos7/aarch64/*-${PACKAGE_VERSION}-1.aarch64.rpm -tar -czvf ${PACKAGE_ROOT}/nvidia-container-toolkit-${VERSION}.rpm.x86_64.tar.gz ${PACKAGE_ROOT}/packages/centos7/x86_64/*-${PACKAGE_VERSION}-1.x86_64.rpm +tar -czvf ${PACKAGE_ROOT}/nvidia-container-toolkit_${VERSION#v}_deb_amd64.tar.gz ${PACKAGE_ROOT}/packages/ubuntu18.04/amd64/*_${PACKAGE_VERSION}-1_amd64.deb +tar -czvf ${PACKAGE_ROOT}/nvidia-container-toolkit_${VERSION#v}_deb_arm64.tar.gz ${PACKAGE_ROOT}/packages/ubuntu18.04/arm64/*_${PACKAGE_VERSION}-1_arm64.deb +tar -czvf ${PACKAGE_ROOT}/nvidia-container-toolkit_${VERSION#v}_rpm_aarch64.tar.gz ${PACKAGE_ROOT}/packages/centos7/aarch64/*-${PACKAGE_VERSION}-1.aarch64.rpm +tar -czvf ${PACKAGE_ROOT}/nvidia-container-toolkit_${VERSION#v}_rpm_x86_64.tar.gz ${PACKAGE_ROOT}/packages/centos7/x86_64/*-${PACKAGE_VERSION}-1.x86_64.rpm + +is_command() ( + command -v "$1" >/dev/null +) + +hash_sha256() ( + TARGET=${1:-/dev/stdin} + if is_command gsha256sum; then + hash=$(gsha256sum "$TARGET") || return 1 + echo "$hash" | cut -d ' ' -f 1 + elif is_command sha256sum; then + hash=$(sha256sum "$TARGET") || return 1 + echo "$hash" | cut -d ' ' -f 1 + elif is_command shasum; then + hash=$(shasum -a 256 "$TARGET" 2>/dev/null) || return 1 + echo "$hash" | cut -d ' ' -f 1 + elif is_command openssl; then + hash=$(openssl -dst openssl dgst -sha256 "$TARGET") || return 1 + echo "$hash" | cut -d ' ' -f a + else + log_err "hash_sha256 unable to find command to compute sha-256 hash" + return 1 + fi +) + +files=$( ls ${PACKAGE_ROOT}/nvidia-container-toolkit_${VERSION#v}_*.tar.gz ) + +CHECKSUM_FILE=${PACKAGE_ROOT}/nvidia-container-toolkit_${VERSION#v}_checksums.txt +rm -f ${CHECKSUM_FILE} + +set -e +for f in ${files}; do + hash_f=$(hash_sha256 $f) + echo "${hash_f} $f" >> $CHECKSUM_FILE +done From 832fcba5cd6970e024a03b4dbe81e470aaba643f Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Thu, 11 Jul 2024 10:34:28 +0200 Subject: [PATCH 2/2] [no-relnote] fix archive script Signed-off-by: Evan Lezar --- scripts/archive-packages.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/archive-packages.sh b/scripts/archive-packages.sh index 01e19035..688513d8 100755 --- a/scripts/archive-packages.sh +++ b/scripts/archive-packages.sh @@ -61,7 +61,7 @@ PACKAGE_CACHE=release-${VERSION}-${REPO} REMOVE_PACKAGE_CACHE=no if [ ! -d ${PACKAGE_CACHE} ]; then echo "Fetching packages with SHA '${SHA}' as tag '${VERSION}' to ${PACKAGE_CACHE}" -${SCRIPTS_DIR}/pull-packages.sh \ +${SCRIPTS_DIR}/../hack/pull-packages.sh \ ${PACKAGE_IMAGE_NAME}:${PACKAGE_IMAGE_TAG} \ ${PACKAGE_CACHE} REMOVE_PACKAGE_CACHE=yes @@ -113,7 +113,7 @@ function upload_archive() { for var in "CI_PROJECT_ID" "CI_PIPELINE_ID" "CI_JOB_ID" "CI_JOB_URL" "CI_PROJECT_PATH"; do if [ -n "${!var}" ]; then - optionally_add_property "${var}" "${!var}" + props+=("${property}=${value}") fi done local PROPS=$(join_by ";" "${props[@]}")