From e5125515f00c39993750ad621dcc262de248cd25 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 18 May 2022 13:55:05 +0200 Subject: [PATCH] Automatically generate changelogs in docker builds Signed-off-by: Evan Lezar --- docker/Dockerfile.amazonlinux | 2 ++ docker/Dockerfile.centos | 2 ++ docker/Dockerfile.debian | 9 ++++++--- docker/Dockerfile.opensuse-leap | 2 ++ docker/Dockerfile.ubuntu | 9 ++++++--- docker/docker.mk | 1 + 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile.amazonlinux b/docker/Dockerfile.amazonlinux index 77296029..01f738cd 100644 --- a/docker/Dockerfile.amazonlinux +++ b/docker/Dockerfile.amazonlinux @@ -27,6 +27,7 @@ ENV GOPATH /go ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH # packaging +ARG PKG_NAME ARG PKG_VERS ARG PKG_REV @@ -63,6 +64,7 @@ COPY packaging/rpm . CMD arch=$(uname -m) && \ rpmbuild --clean --target=$arch -bb \ -D "_topdir $PWD" \ + -D "release_date $(date +'%a %b %d %Y')" \ -D "version $VERSION" \ -D "libnvidia_container_version ${VERSION}-${RELEASE}" \ -D "release $RELEASE" \ diff --git a/docker/Dockerfile.centos b/docker/Dockerfile.centos index abbec683..3cf6b5ec 100644 --- a/docker/Dockerfile.centos +++ b/docker/Dockerfile.centos @@ -27,6 +27,7 @@ ENV GOPATH /go ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH # packaging +ARG PKG_NAME ARG PKG_VERS ARG PKG_REV @@ -61,6 +62,7 @@ COPY packaging/rpm . CMD arch=$(uname -m) && \ rpmbuild --clean --target=$arch -bb \ -D "_topdir $PWD" \ + -D "release_date $(date +'%a %b %d %Y')" \ -D "version $VERSION" \ -D "libnvidia_container_version ${VERSION}-${RELEASE}" \ -D "release $RELEASE" \ diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index 3dcd9627..e0d64ec6 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -32,6 +32,7 @@ ENV GOPATH /go ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH # packaging +ARG PKG_NAME ARG PKG_VERS ARG PKG_REV @@ -64,9 +65,11 @@ RUN if [ "$(lsb_release -cs)" = "jessie" ]; then \ WORKDIR $DIST_DIR COPY packaging/debian ./debian -RUN sed -i "s;@VERSION@;${REVISION};" debian/changelog && \ - dch --changelog debian/changelog --append "Bump libnvidia-container dependency to ${REVISION}}" && \ - dch --changelog debian/changelog -r "" && \ +RUN dch --create --package="${PKG_NAME}" \ + --newversion "${REVISION}" \ + "See https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/blob/main/CHANGELOG.md for the changelog" && \ + dch --append "Bump libnvidia-container dependency to ${REVISION}" && \ + dch -r "" && \ if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then exit 1; fi CMD export DISTRIB="$(lsb_release -cs)" && \ diff --git a/docker/Dockerfile.opensuse-leap b/docker/Dockerfile.opensuse-leap index fd02f4d5..11386628 100644 --- a/docker/Dockerfile.opensuse-leap +++ b/docker/Dockerfile.opensuse-leap @@ -25,6 +25,7 @@ ENV GOPATH /go ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH # packaging +ARG PKG_NAME ARG PKG_VERS ARG PKG_REV @@ -59,6 +60,7 @@ COPY packaging/rpm . CMD arch=$(uname -m) && \ rpmbuild --clean --target=$arch -bb \ -D "_topdir $PWD" \ + -D "release_date $(date +'%a %b %d %Y')" \ -D "version $VERSION" \ -D "libnvidia_container_version ${VERSION}-${RELEASE}" \ -D "release $RELEASE" \ diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu index 7a5e39b2..a5e152f0 100644 --- a/docker/Dockerfile.ubuntu +++ b/docker/Dockerfile.ubuntu @@ -30,6 +30,7 @@ ENV GOPATH /go ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH # packaging +ARG PKG_NAME ARG PKG_VERS ARG PKG_REV @@ -57,9 +58,11 @@ COPY config/config.toml.${CONFIG_TOML_SUFFIX} $DIST_DIR/config.toml WORKDIR $DIST_DIR COPY packaging/debian ./debian -RUN sed -i "s;@VERSION@;${REVISION};" debian/changelog && \ - dch --changelog debian/changelog --append "Bump libnvidia-container dependency to ${REVISION}}" && \ - dch --changelog debian/changelog -r "" && \ +RUN dch --create --package="${PKG_NAME}" \ + --newversion "${REVISION}" \ + "See https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/blob/main/CHANGELOG.md for the changelog" && \ + dch --append "Bump libnvidia-container dependency to ${REVISION}" && \ + dch -r "" && \ if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then exit 1; fi CMD export DISTRIB="$(lsb_release -cs)" && \ diff --git a/docker/docker.mk b/docker/docker.mk index 614b97bc..a22a504c 100644 --- a/docker/docker.mk +++ b/docker/docker.mk @@ -128,6 +128,7 @@ docker-build-%: --progress=plain \ --build-arg BASEIMAGE="$(BASEIMAGE)" \ --build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \ + --build-arg PKG_NAME="$(LIB_NAME)" \ --build-arg PKG_VERS="$(LIB_VERSION)" \ --build-arg PKG_REV="$(PKG_REV)" \ --build-arg CONFIG_TOML_SUFFIX="$(CONFIG_TOML_SUFFIX)" \