blob: 3a822ebce8bf69ad45356ab5f6aeff94b681521c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
{
writeShellApplication,
nix,
nix-update,
curl,
common-updater-scripts,
jq,
}:
writeShellApplication {
name = "update-openlist";
runtimeInputs = [
curl
jq
nix
common-updater-scripts
nix-update
];
text = ''
oldVersion=$(nix-instantiate --eval --strict -A "openlist.version" | jq -e -r)
get_latest_release() {
local repo=$1
curl --fail ''${GITHUB_TOKEN:+ -H "Authorization: bearer $GITHUB_TOKEN"} \
-s "https://api.github.com/repos/OpenListTeam/$repo/releases/latest" | jq -r ".tag_name"
}
get_github_commit_date() {
local repo=$1
local rev=$2
curl --fail ''${GITHUB_TOKEN:+ -H "Authorization: bearer $GITHUB_TOKEN"} \
-s "https://api.github.com/repos/OpenListTeam/$repo/commits/$rev" \
| jq -e -r '.commit.committer.date[0:10]'
}
get_github_package_version_at_rev() {
local repo=$1
local rev=$2
curl --fail ''${GITHUB_TOKEN:+ -H "Authorization: bearer $GITHUB_TOKEN"} \
-s "https://raw.githubusercontent.com/OpenListTeam/$repo/$rev/package.json" \
| jq -e -r '.version'
}
version=$(get_latest_release "OpenList")
version="''${version#v}"
frontendVersion=$(get_latest_release "OpenList-Frontend")
frontendVersion="''${frontendVersion#v}"
if [[ "$oldVersion" == "$version" ]]; then
echo "Already up to date!"
exit 0
fi
nix-update openlist.frontend --version="$frontendVersion"
update-source-version openlist.frontend "$frontendVersion" \
--source-key=i18n --ignore-same-version \
--file=pkgs/by-name/op/openlist/frontend.nix
frontendLockFile="$(nix-build --no-out-link -A openlist.frontend.src)/pnpm-lock.yaml"
mpegtsRev=$(sed -nE 's/.*github:OpenListTeam\/mpegts\.js#([0-9a-f]{40}).*/\1/p' "$frontendLockFile"| head -n1)
mpegtsBaseVersion=$(get_github_package_version_at_rev "mpegts.js" "$mpegtsRev")
mpegtsDate=$(get_github_commit_date "mpegts.js" "$mpegtsRev")
update-source-version openlist.frontend.mpegts-js "$mpegtsBaseVersion-unstable-$mpegtsDate" \
--rev="$mpegtsRev" \
--file=pkgs/by-name/op/openlist/frontend.nix
nix-update openlist.frontend.mpegts-js \
--version=skip \
--override-filename=pkgs/by-name/op/openlist/frontend.nix
nix-update openlist --version="$version"
'';
}
|