This repository has been archived on 2024-10-01. You can view files and clone it, but cannot push or open issues or pull requests.
container-images/release.sh
Pim Kunis 02dea6fe5c
Some checks failed
/ push (push) Failing after 1m4s
Allow to specify git directory when releasing
2024-04-28 17:21:12 +02:00

25 lines
709 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
flakeref="${1-}"
name="${2-}"
gitdir="${3:-.}"
if [ -z "$flakeref" ] || [ -z "$name" ];
then
echo "Usage: $0 FLAKEREF NAME [GITDIR]"
exit 1
fi
imagename=$(nix eval --no-allow-dirty --raw $flakeref.imageName)
imagetag=$(nix eval --no-allow-dirty --raw $flakeref.imageTag)
image=$(nix build --no-allow-dirty $flakeref --print-out-paths --no-link)
gitrev=$(git --git-dir $gitdir/.git --work-tree $gitdir rev-parse HEAD)
docker load < $image
docker tag $imagename:$imagetag git.kun.is/home/$name:$gitrev
docker tag $imagename:$imagetag git.kun.is/home/$name:latest
docker push git.kun.is/home/$name:$gitrev
docker push git.kun.is/home/$name:latest