diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-02-18 10:55:07 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-02-18 10:55:07 +0100 |
commit | 50e3840f14c9653568cd66ce610baec36534bc10 (patch) | |
tree | 40dd9c1738026a2df81979a2502c7bcc8615a76f | |
parent | 26e99c817cc983d9b630fe932d9e5c8497fe386c (diff) | |
parent | f0de5fb8e733e45f1d96fdf842eab7cdfc598c60 (diff) |
Merge remote-tracking branch 'origin/script-to-make-docker-release'
-rwxr-xr-x | maintainers/push-docker.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/maintainers/push-docker.sh b/maintainers/push-docker.sh new file mode 100755 index 000000000..2aa953a78 --- /dev/null +++ b/maintainers/push-docker.sh @@ -0,0 +1,71 @@ +#/usr/bin/env bash + +# TODO: parse from .version +MAINTENANCE_VERSION="2.6" +VERSION="$MAINTENANCE_VERSION.1" + +# Should be override `latest` tag, default true +PUSH_AS_LATEST=1 + +PLATFORMS="x86_64-linux aarch64-linux" + +# ensure we are logged to docker hub +docker login + +DOCKER_MANIFEST="" +DOCKER_MANIFEST_LATEST="" + +for PLATFORM in $PLATFORMS; +do + if [ "$PLATFORM" = "x86_64-linux" ]; then DOCKER_PLATFORM="amd64" + elif [ "$PLATFORM" = "aarch64-linux" ]; then DOCKER_PLATFORM="arm64" + else + echo "EROROR: No docker platform found for $PLATFORM platform" + exit 1 + fi + + echo "=> Loading docker image for $PLATFORM platform ..." + + DOCKER_IMAGE_TMP_FILE="$PWD/image-$PLATFORM.tar.gz" + if [ ! -f "$DOCKER_IMAGE_TMP_FILE" ]; then + curl -L https://hydra.nixos.org/job/nix/maintenance-$MAINTENANCE_VERSION/dockerImage.$PLATFORM/latest/download/1 > $DOCKER_IMAGE_TMP_FILE + fi + docker load -i $DOCKER_IMAGE_TMP_FILE + + echo "=> Tagging docker image of version $VERSION for $PLATFORM platform ..." + + docker tag nix:$VERSION nixos/nix:$VERSION-$DOCKER_PLATFORM + if [ $PUSH_AS_LATEST -eq 1 ]; then + echo "=> Tagging docker image of version latest for $PLATFORM platform ..." + docker tag nix:$VERSION nixos/nix:latest-$DOCKER_PLATFORM + fi + + echo "=> Pushing docker image of version $VERSION for $PLATFORM platform ..." + + docker push nixos/nix:$VERSION-$DOCKER_PLATFORM + if [ $PUSH_AS_LATEST -eq 1 ]; then + echo "=> Pushing docker image of version latest for $PLATFORM platform ..." + docker push nixos/nix:latest-$DOCKER_PLATFORM + fi + + DOCKER_MANIFEST="$DOCKER_MANIFEST --amend nixos/nix:$VERSION-$DOCKER_PLATFORM" + DOCKER_MANIFEST_LATEST="$DOCKER_MANIFEST_LATEST --amend nixos/nix:latest-$DOCKER_PLATFORM" + + echo +done + +echo "=> Creating $VERSION multi platform docker manifest for the following platforms: $PLATFORMS ..." +docker manifest rm nixos/nix:$VERSION $DOCKER_MANIFEST +docker manifest create nixos/nix:$VERSION $DOCKER_MANIFEST +if [ $PUSH_AS_LATEST -eq 1 ]; then + echo "=> Creating latest multi platform docker manifest for the following platforms: $PLATFORMS ..." + docker manifest rm nixos/nix:latest $DOCKER_MANIFEST_LATEST + docker manifest create nixos/nix:latest $DOCKER_MANIFEST_LATEST +fi + +echo "=> Pushing $VERSION multi platform docker manifest ..." +docker manifest push nixos/nix:$VERSION +if [ $PUSH_AS_LATEST -eq 1 ]; then + echo "=> Pushing latest multi platform docker manifest ..." + docker manifest push nixos/nix:latest +fi |