1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl jq prefetch-npm-deps nix-prefetch-github coreutils
5 cd "$(dirname "${BASH_SOURCE[0]}")"
7 old_version
=$
(jq
-r ".version" sources.json ||
echo -n "0.0.1")
8 version
=$
(curl
-s "https://api.github.com/repos/immich-app/immich/releases/latest" | jq
-r ".tag_name")
11 echo "Updating to $version"
13 if [[ "$old_version" == "$version" ]]; then
14 echo "Already up to date!"
19 src_hash
=$
(nix-prefetch-github immich-app immich
--rev "v${version}" | jq
-r .
hash)
20 upstream_src
="https://raw.githubusercontent.com/immich-app/immich/v$version"
22 sources_tmp
="$(mktemp)"
23 cat <<EOF > "$sources_tmp"
25 "version": "$version",
32 for npm_component
in cli server web
"open-api/typescript-sdk"; do
33 echo "fetching $npm_component"
34 curl
-s -o "$lock" "$upstream_src/$npm_component/package-lock.json"
35 hash=$
(prefetch-npm-deps
"$lock")
36 echo "$(jq --arg npm_component "$npm_component" \
38 --arg version "$
(jq
-r '.version' <"$lock")" \
39 '.components += {($npm_component): {npmDepsHash: $hash, version: $version}}' \
40 "$sources_tmp")" > "$sources_tmp"
44 mv "$sources_tmp" sources.json