invidious: determine version string components in update script

This commit is contained in:
Sophie Tauchert 2024-04-29 20:00:20 +02:00 committed by Gaetan Lepage
parent 73584c2510
commit 9e0ab0983a
3 changed files with 16 additions and 7 deletions

View file

@ -2,8 +2,8 @@
let
# All versions, revisions, and checksums are stored in ./versions.json.
# The update process is the following:
# * pick the latest commit
# * update .invidious.rev, .invidious.version, and .invidious.hash
# * pick the latest tag
# * update .invidious.version, .invidious.date, .invidious.commit and .invidious.hash
# * prefetch the videojs dependencies with scripts/fetch-player-dependencies.cr
# and update .videojs.hash (they are normally fetched during build
# but nix's sandboxing does not allow that)
@ -21,7 +21,7 @@ crystal.buildCrystalPackage rec {
src = fetchFromGitea {
domain = "gitea.invidious.io";
owner = "iv-org";
repo = pname;
repo = "invidious";
fetchSubmodules = true;
rev = "v${version}";
inherit (versions.invidious) hash;
@ -37,6 +37,8 @@ crystal.buildCrystalPackage rec {
# This always uses the latest commit which invalidates the cache even if
# the assets were not changed
assetCommitTemplate = ''{{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit -- assets`.strip}" }}'';
inherit (versions.invidious) commit date;
in
''
for d in ${videojs}/*; do ln -s "$d" assets/videojs; done
@ -45,9 +47,9 @@ crystal.buildCrystalPackage rec {
# build-time
substituteInPlace src/invidious.cr \
--replace-fail ${lib.escapeShellArg branchTemplate} '"master"' \
--replace-fail ${lib.escapeShellArg commitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"' \
--replace-fail ${lib.escapeShellArg versionTemplate} '"${lib.concatStringsSep "." (lib.drop 2 (lib.splitString "-" version))}"' \
--replace-fail ${lib.escapeShellArg assetCommitTemplate} '"${lib.substring 0 7 versions.invidious.rev}"'
--replace-fail ${lib.escapeShellArg commitTemplate} '"${commit}"' \
--replace-fail ${lib.escapeShellArg versionTemplate} '"${date}"' \
--replace-fail ${lib.escapeShellArg assetCommitTemplate} '"${commit}"'
# Patch the assets and locales paths to be absolute
substituteInPlace src/invidious.cr \

View file

@ -44,7 +44,12 @@ if [ "$new_version" = "$old_version" ]; then
exit
fi
commit="$(git -C "$git_dir" rev-list "$new_tag" --max-count=1 --abbrev-commit)"
date="$(git -C "$git_dir" log -1 --format=%cd --date=format:%Y.%m.%d)"
json_set '.invidious.date' "$date"
json_set '.invidious.commit' "$commit"
json_set '.invidious.version' "$new_version"
new_hash=$(nix-prefetch -I 'nixpkgs=../../..' "$pkg")
json_set '.invidious.hash' "$new_hash"

View file

@ -1,7 +1,9 @@
{
"invidious": {
"hash": "sha256-YZ+uhn1ESuRTZxAMoxKCpxEaUfeCUqOrSr3LkdbrTkU=",
"version": "2.20240427"
"version": "2.20240427",
"date": "2024.04.27",
"commit": "eda7444c"
},
"videojs": {
"hash": "sha256-jED3zsDkPN8i6GhBBJwnsHujbuwlHdsVpVqa1/pzSH4="