Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1new_version="$( 2 curl --fail --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest" | 3 jq '.tag_name | ltrimstr("v")' --raw-output 4)" 5stockfish_revision="$( 6 curl --fail --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/$GITHUB_REPOSITORY/contents/Stockfish?ref=v$new_version" | 7 jq .sha --raw-output 8)" 9stockfish_header="$( 10 curl --fail --silent "https://raw.githubusercontent.com/official-stockfish/Stockfish/$stockfish_revision/src/evaluate.h" 11)" 12new_nnue_big_file="$( 13 echo "$stockfish_header" | 14 grep --perl-regexp --only-matching 'EvalFileDefaultNameBig "\Knn-(\w+).nnue' 15)" 16new_nnue_big_hash="$( 17 nix --extra-experimental-features nix-command hash to-sri --type sha256 "$( 18 nix-prefetch-url --type sha256 "https://tests.stockfishchess.org/api/nn/${new_nnue_big_file}" 19 )" 20)" 21new_nnue_small_file="$( 22 echo "$stockfish_header" | 23 grep --perl-regexp --only-matching 'EvalFileDefaultNameSmall "\Knn-(\w+).nnue' 24)" 25new_nnue_small_hash="$( 26 nix --extra-experimental-features nix-command hash to-sri --type sha256 "$( 27 nix-prefetch-url --type sha256 "https://tests.stockfishchess.org/api/nn/${new_nnue_small_file}" 28 )" 29)" 30 31# Update NNUE 32pkg_body="$(<"$PKG_FILE")" 33pkg_body="${pkg_body//"$NNUE_BIG_FILE"/"$new_nnue_big_file"}" 34pkg_body="${pkg_body//"$NNUE_BIG_HASH"/"$new_nnue_big_hash"}" 35pkg_body="${pkg_body//"$NNUE_SMALL_FILE"/"$new_nnue_small_file"}" 36pkg_body="${pkg_body//"$NNUE_SMALL_HASH"/"$new_nnue_small_hash"}" 37echo "$pkg_body" >"$PKG_FILE" 38 39# Update version, src 40update-source-version "$PNAME" "$new_version" --ignore-same-version --print-changes 41 42# Update cargoHash 43nix-update --version=skip "$PNAME"