about summary refs log tree commit diff
path: root/pkgs/by-name/pr/protonmail-desktop/update.sh
blob: a640b40d49e346c8e95c6c76f110cbfd572cda80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts jq

# shellcheck disable=SC1008

set -eu -o pipefail

latestVersion=$(curl https://api.github.com/repos/ProtonMail/inbox-desktop/releases/latest | jq -r '.tag_name')

declare -A platforms
platforms[x86_64-linux]="amd64"
platforms[x86_64-darwin]="x64"
platforms[aarch64-darwin]="arm64"

for platform in "${!platforms[@]}"
do
  arch=${platforms[$platform]}
  os=$(echo "$platform" | cut -d "-" -f2)

  if [[ "$os" == "linux" ]]; then
    downloadUrl="https://github.com/ProtonMail/inbox-desktop/releases/download/${latestVersion}/proton-mail_${latestVersion}_${arch}.deb"
  else
    downloadUrl="https://github.com/ProtonMail/inbox-desktop/releases/download/${latestVersion}/Proton.Mail-${os}-${arch}-${latestVersion}.zip"
  fi
  echo "$downloadUrl"

  latestSha=$(nix store prefetch-file "$downloadUrl" --json | jq -r '.hash')

  update-source-version "protonmail-desktop" "$latestVersion" "$latestSha" --system="$platform" --ignore-same-version --file=./pkgs/by-name/pr/protonmail-desktop/package.nix
done