summaryrefslogtreecommitdiff
path: root/pkgs/by-name/dr/draupnir/update.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/dr/draupnir/update.sh')
-rwxr-xr-xpkgs/by-name/dr/draupnir/update.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/pkgs/by-name/dr/draupnir/update.sh b/pkgs/by-name/dr/draupnir/update.sh
new file mode 100755
index 000000000000..78842bfcbfc4
--- /dev/null
+++ b/pkgs/by-name/dr/draupnir/update.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p curl common-updater-scripts coreutils jq prefetch-yarn-deps git
+
+set -euo pipefail
+set -x
+
+cd "$(git rev-parse --show-toplevel)"
+
+TMPDIR=$(mktemp -d)
+
+echo "Getting versions..."
+latestVersion="$(curl -sL "https://api.github.com/repos/the-draupnir-project/Draupnir/releases?per_page=1" | jq -r '.[0].tag_name | ltrimstr("v")')"
+echo " --> Latest version: ${latestVersion}"
+currentVersion=$(nix-instantiate --eval -E "with import ./. {}; draupnir.version or (lib.getVersion draupnir)" | tr -d '"')
+echo " --> Current version: ${currentVersion}"
+if [[ "$currentVersion" == "$latestVersion" ]]; then
+ echo "Draupnir is up-to-date: $currentVersion"
+ exit 0
+else
+ echo "We are out of date..."
+fi
+
+curl https://raw.githubusercontent.com/the-draupnir-project/Draupnir/v$latestVersion/package.json -o pkgs/by-name/dr/draupnir/package.json
+
+update-source-version draupnir "$latestVersion"
+
+# Update yarn offline cache hash
+cd $TMPDIR
+
+curl https://raw.githubusercontent.com/the-draupnir-project/Draupnir/v$latestVersion/yarn.lock -o yarn.lock
+TMP_PREFETCH_HASH=`prefetch-yarn-deps yarn.lock`
+NEW_YARN_OFFLINE_HASH=`nix hash to-sri --type sha256 $TMP_PREFETCH_HASH`
+
+cd -
+echo "New yarn offline hash: $NEW_YARN_OFFLINE_HASH"
+
+TMPFILE=$(mktemp)
+jq '.yarn_offline_cache_hash = "'$NEW_YARN_OFFLINE_HASH'"' pkgs/by-name/dr/draupnir/hashes.json > $TMPFILE
+mv -- "$TMPFILE" pkgs/by-name/dr/draupnir/hashes.json