nixos-images/build-images.sh

37 lines
1 KiB
Bash
Raw Normal View History

2021-06-10 08:10:06 +02:00
#!/usr/bin/env nix-shell
#!nix-shell -p nix -p coreutils -p bash -p gh -i bash
set -xeuo pipefail
build_netboot_image() {
tag=$1
arch=$2
2021-06-10 09:02:41 +02:00
tmp=$3
2021-06-10 08:10:06 +02:00
img=$(nix-build --no-out-link -I "nixpkgs=https://github.com/NixOS/nixpkgs/archive/${tag}.tar.gz" '<nixpkgs/nixos/release.nix>' -A "netboot.$arch")
2021-06-10 09:02:41 +02:00
cp "$(readlink $img/bzImage)" "$tmp/bzImage-$arch"
echo "$tmp/bzImage-$arch"
cp "$(readlink $img/initrd)" "$tmp/initrd-$arch"
echo "$tmp/initrd-$arch"
2021-06-10 08:10:06 +02:00
}
main() {
tag=${1:-nixos-unstable}
arch=${2:-x86_64-linux}
sha256s=()
tmp="$(mktemp -d)"
trap 'rm -rf -- "$tmp"' EXIT
2021-06-10 09:02:41 +02:00
assets=($(build_netboot_image "$tag" "$arch" "$tmp"))
2021-06-10 08:10:06 +02:00
for asset in "${assets[@]}"; do
pushd "$(dirname $asset)"
2021-06-10 09:15:20 +02:00
sha256sum "$(basename $asset)" >> "$TMP/sha256sums"
2021-06-10 08:10:06 +02:00
popd
done
assets+=("$TMP/sha256sums")
# Since we cannot atomically update a release, we delete the old one before
gh release delete "$tag" </dev/null || true
gh release create --title "$tag (build $(date +"%Y-%m-%d"))" "$tag" "${assets[@]}" </dev/null
}
main "$@"