1#! /usr/bin/env nix-shell
2#!nix-shell -i bash -p bash curl gawk gnugrep gnused jq nix nix-prefetch nix-prefetch-scripts common-updater-scripts
3
4set -eou pipefail
5
6latestVersion=$(curl --fail --silent https://api.github.com/repos/Microsoft/vscode/releases/latest | jq --raw-output .tag_name)
7currentVersion=$(nix eval --raw -f . vscode.version)
8
9echo "latest version: $latestVersion"
10echo "current version: $currentVersion"
11
12if [[ "$latestVersion" == "$currentVersion" ]]; then
13 echo "package is up-to-date"
14 exit 0
15fi
16
17update-source-version vscode $latestVersion
18
19systems=$(nix eval --json -f . vscode.meta.platforms | jq --raw-output '.[]')
20for system in $systems; do
21 hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 $(nix-prefetch-url $(nix eval --raw -f . vscode.src.url --system "$system")))
22 update-source-version vscode $latestVersion $hash --system=$system --ignore-same-version --ignore-same-hash
23done
24
25rev=$(curl --fail --silent https://api.github.com/repos/Microsoft/vscode/git/ref/tags/$latestVersion | jq --raw-output .object.sha)
26update-source-version vscode $rev --version-key=rev --source-key=vscodeServer.src --ignore-same-version --ignore-same-hash