Merge pull request #124 from nix-community/ci

ci: improve updating assets
This commit is contained in:
Jörg Thalheim 2023-08-04 21:56:02 +01:00 committed by GitHub
commit 1361e3e22a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View file

@ -14,7 +14,7 @@ jobs:
- nixos-23.05
- nixos-unstable
os:
#- nscloud-ubuntu-22.04-arm64-4x16
- nscloud-ubuntu-22.04-arm64-4x16
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:

View file

@ -6,7 +6,7 @@ shopt -s lastpipe
build_netboot_image() {
declare -r tag=$1 arch=$2 tmp=$3
img=$(nix build --print-out-paths --option accept-flake-config true -L ".#packages.${arch}.netboot-${tag//.}")
img=$(nix build --print-out-paths --option accept-flake-config true -L ".#packages.${arch}.netboot-${tag//./}")
ln -s "$img/bzImage" "$tmp/bzImage-$arch"
echo "$tmp/bzImage-$arch"
ln -s "$img/initrd" "$tmp/initrd-$arch"
@ -21,7 +21,7 @@ build_netboot_image() {
build_kexec_installer() {
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}")
out=$(nix build --print-out-paths --option accept-flake-config true -L ".#packages.${arch}.kexec-installer-${tag//./}${variant}")
echo "$out/nixos-kexec-installer${variant}-$arch.tar.gz"
}
@ -41,9 +41,17 @@ main() {
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
if ! gh release view "$tag"; then
gh release create --title "$tag (build $(date +"%Y-%m-%d"))" "$tag"
fi
gh release upload --clobber "$tag" "${assets[@]}"
gh release view --json assets | jq -r ".assets | map(.name) | .[] | select(test(\"$arch\"))" >"$TMP/existing-assets"
for asset in "${assets[@]}"; do
basename "$asset" >>"$TMP/uploaded-assets"
done
sort "$TMP/uploaded-assets" "$TMP/existing-assets" | uniq -u | xargs --no-run-if-empty -I{} gh release delete-asset --yes "$tag" {}
}
main "$@"