2021-06-10 08:10:06 +02:00
|
|
|
#!/usr/bin/env nix-shell
|
2022-12-16 15:27:57 +01:00
|
|
|
#!nix-shell -p nix -p coreutils -p bash -p gh -i bash
|
2021-06-10 09:30:10 +02:00
|
|
|
# shellcheck shell=bash
|
2021-06-10 08:10:06 +02:00
|
|
|
set -xeuo pipefail
|
2022-12-13 10:42:30 +01:00
|
|
|
shopt -s lastpipe
|
2021-06-10 08:10:06 +02:00
|
|
|
|
|
|
|
build_netboot_image() {
|
2021-06-10 09:30:10 +02:00
|
|
|
declare -r tag=$1 arch=$2 tmp=$3
|
2022-12-16 15:27:57 +01:00
|
|
|
img=$(nix build --print-out-paths --option accept-flake-config true -L ".#packages.${arch}.netboot-${tag//.}")
|
2021-06-12 09:00:47 +02:00
|
|
|
ln -s "$img/bzImage" "$tmp/bzImage-$arch"
|
2021-06-10 09:02:41 +02:00
|
|
|
echo "$tmp/bzImage-$arch"
|
2021-06-12 09:00:47 +02:00
|
|
|
ln -s "$img/initrd" "$tmp/initrd-$arch"
|
2021-06-10 09:02:41 +02:00
|
|
|
echo "$tmp/initrd-$arch"
|
2021-06-13 09:04:19 +02:00
|
|
|
sed -e "s!^kernel bzImage!kernel https://github.com/nix-community/nixos-images/releases/download/${tag}/bzImage-${arch}!" \
|
|
|
|
-e "s!^initrd initrd!initrd https://github.com/nix-community/nixos-images/releases/download/${tag}/initrd-${arch}!" \
|
2021-06-16 21:48:38 +02:00
|
|
|
-e "s!initrd=initrd!initrd=initrd-${arch}!" \
|
2021-06-13 09:04:19 +02:00
|
|
|
< "$img/netboot.ipxe" \
|
|
|
|
> "$tmp/netboot-$arch.ipxe"
|
2021-06-12 09:00:47 +02:00
|
|
|
echo "$tmp/netboot-$arch.ipxe"
|
2021-06-10 08:10:06 +02:00
|
|
|
}
|
|
|
|
|
2022-09-04 14:57:14 +02:00
|
|
|
build_kexec_installer() {
|
2023-05-07 20:55:45 +02:00
|
|
|
declare -r tag=$1 arch=$2 tmp=$3 variant=$4
|
|
|
|
out=$(nix build --print-out-paths --option accept-flake-config true -L ".#packages.${arch}.kexec-installer-${tag//.}${variant}")
|
2023-05-07 21:06:12 +02:00
|
|
|
echo "$out/nixos-kexec-installer${variant}-$arch.tar.gz"
|
2022-09-04 14:57:14 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 08:10:06 +02:00
|
|
|
main() {
|
2021-06-10 09:30:10 +02:00
|
|
|
declare -r tag=${1:-nixos-unstable} arch=${2:-x86_64-linux}
|
2021-06-10 08:10:06 +02:00
|
|
|
tmp="$(mktemp -d)"
|
|
|
|
trap 'rm -rf -- "$tmp"' EXIT
|
2022-12-13 10:42:30 +01:00
|
|
|
(
|
2023-05-07 20:55:45 +02:00
|
|
|
build_kexec_installer "$tag" "$arch" "$tmp" ""
|
|
|
|
build_kexec_installer "$tag" "$arch" "$tmp" "-noninteractive"
|
2021-06-10 10:06:41 +02:00
|
|
|
build_netboot_image "$tag" "$arch" "$tmp"
|
2022-12-13 10:42:30 +01:00
|
|
|
) | readarray -t assets
|
2021-06-10 08:10:06 +02:00
|
|
|
for asset in "${assets[@]}"; do
|
2021-06-10 09:30:10 +02:00
|
|
|
pushd "$(dirname "$asset")"
|
|
|
|
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 "$@"
|