2023-01-20 10:41:00 +00:00
|
|
|
{ lib
|
2022-12-17 10:02:37 +00:00
|
|
|
, writeScript
|
|
|
|
}:
|
|
|
|
|
|
|
|
{ name ? ""
|
|
|
|
, owner ? ""
|
|
|
|
, repo ? ""
|
2023-11-16 04:20:00 +00:00
|
|
|
, page ? "releases/latest"
|
|
|
|
, filter ? ".tag_name | split(\"-\") | .[1]"
|
2022-12-17 10:02:37 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2023-01-20 10:41:00 +00:00
|
|
|
pname =
|
|
|
|
if lib.hasPrefix "rocm-llvm-" name
|
2023-10-19 13:55:26 +00:00
|
|
|
then "llvm.${lib.removePrefix "rocm-llvm-" name}"
|
2023-01-20 10:41:00 +00:00
|
|
|
else name;
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
updateScript = writeScript "update.sh" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl jq common-updater-scripts
|
|
|
|
version="$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
|
|
|
|
-sL "https://api.github.com/repos/${owner}/${repo}/${page}" | jq '${filter}' --raw-output)"
|
|
|
|
|
|
|
|
IFS='.' read -a version_arr <<< "$version"
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
if (( ''${version_arr[0]} > 5 )); then
|
|
|
|
echo "'rocmPackages_5.${pname}' is already at it's maximum allowed version.''\nAny further upgrades should go into 'rocmPackages_X.${pname}'." 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
if [ "''${#version_arr[*]}" == 2 ]; then
|
|
|
|
version="''${version}.0"
|
|
|
|
fi
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
update-source-version rocmPackages_5.${pname} "$version" --ignore-same-hash
|
2022-12-17 10:02:37 +00:00
|
|
|
'';
|
|
|
|
in [ updateScript ]
|