Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
50 lines
1.5 KiB
Bash
Executable File
50 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env nix-shell
|
|
#! nix-shell -i bash -p curl jq gitMinimal gnused gnugrep
|
|
|
|
#
|
|
# Get latest version of TradingView from Snapcraft.
|
|
#
|
|
|
|
snap_info=($(
|
|
curl --silent --header 'X-Ubuntu-Series: 16' \
|
|
'https://api.snapcraft.io/api/v1/snaps/details/tradingview' |
|
|
jq --raw-output \
|
|
'.revision,.download_sha512,.version,.last_updated'
|
|
))
|
|
|
|
# "revision" is the actual version identifier; "version" is for human consumption.
|
|
revision="${snap_info[0]}"
|
|
sha512="${snap_info[1]}"
|
|
sri=$(nix --extra-experimental-features nix-command hash to-sri --type "sha512" $sha512)
|
|
upstream_version="${snap_info[2]}"
|
|
last_updated="${snap_info[3]}"
|
|
|
|
echo "Latest release is $upstream_version from $last_updated."
|
|
|
|
#
|
|
# Read the current TradingView version.
|
|
#
|
|
|
|
nixpkgs="$(git rev-parse --show-toplevel)"
|
|
tradingview_nix="$nixpkgs/pkgs/by-name/tr/tradingview/package.nix"
|
|
current_nix_version=$(nix eval --raw --file . tradingview.version)
|
|
|
|
echo "Current nix version: $current_nix_version"
|
|
|
|
if [[ "$current_nix_version" = "$upstream_version" ]]; then
|
|
echo "TradingView is already up-to-date"
|
|
exit 0
|
|
fi
|
|
|
|
#
|
|
# Find and replace.
|
|
#
|
|
|
|
echo "Updating from ${current_nix_version} to ${upstream_version}, released ${last_updated}"
|
|
echo 's/hash\s*=\s*"[^"]*"\s*;/hash = "'"${sri}"'";/'
|
|
sed --regexp-extended \
|
|
-e 's/revision\s*=\s*"[0-9]+"\s*;/revision = "'"${revision}"'";/' \
|
|
-e 's#hash\s*=\s*"[^"]*"\s*;#hash = "'"${sri}"'";#' \
|
|
-e 's/version\s*=\s*".*"\s*;/version = "'"${upstream_version}"'";/' \
|
|
-i "$tradingview_nix"
|