Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#!/usr/bin/env nix-shell
2#!nix-shell -i bash -p bash nix-update curl coreutils jq
3# shellcheck shell=bash
4
5# adapted from pkgs/by-name/ya/yazi-unwrapped/update.sh
6
7set -eou pipefail
8
9NIXPKGS_DIR="$PWD"
10SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
11
12# Get latest release
13VIDDY_RELEASE=$(
14 curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
15 https://api.github.com/repos/sachaos/viddy/releases/latest
16)
17
18# Get release information
19latestBuildDate=$(echo "$VIDDY_RELEASE" | jq -r ".published_at")
20latestVersion=$(echo "$VIDDY_RELEASE" | jq -r ".tag_name")
21
22latestBuildDate="${latestBuildDate%T*}" # remove the timestamp and get the date
23latestVersion="${latestVersion:1}" # remove first char 'v'
24
25oldVersion=$(nix eval --raw -f "$NIXPKGS_DIR" viddy.version)
26
27if [[ "$oldVersion" == "$latestVersion" ]]; then
28 echo "viddy is up-to-date: ${oldVersion}"
29 exit 0
30fi
31
32echo "Updating viddy $oldVersion -> $latestVersion"
33
34# nix-prefetch broken due to ninja finalAttrs.src.rev
35nix-update viddy --version "$latestVersion"
36
37# Build date
38sed -i 's#env.VERGEN_BUILD_DATE = "[^"]*"#env.VERGEN_BUILD_DATE = "'"${latestBuildDate}"'"#' "$SCRIPT_DIR/package.nix"
39
40