ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / po / positron-bin / update.sh
blob28081f589ec996699e038e9e228bd2296fcb8f9b
1 #!/usr/bin/env nix-shell
2 #! nix-shell -i bash -p curl jq git
4 nixpkgs="$(git rev-parse --show-toplevel)"
5 positron_nix="$nixpkgs/pkgs/by-name/po/positron-bin/package.nix"
7 current_version=$(grep -oP "version = \"\K.*\d" $positron_nix)
8 new_version=$(curl -sSfL \
9 -H "Accept: application/vnd.github+json" \
10 -H "X-GitHub-Api-Version: 2022-11-28" \
11 "https://api.github.com/repos/posit-dev/positron/releases?per_page=1" \
12 | jq -r '.[0].name')
14 if [[ "$new_version" == "$current_version" ]]; then
15 echo 'Positron is already up to date'
16 exit 0;
19 # Update Darwin hash.
20 current_hash=$(nix store prefetch-file --json --hash-type sha256 \
21 "https://github.com/posit-dev/positron/releases/download/${current_version}/Positron-${current_version}.dmg" \
22 | jq -r .hash)
24 new_hash=$(nix store prefetch-file --json --hash-type sha256 \
25 "https://github.com/posit-dev/positron/releases/download/${new_version}/Positron-${new_version}.dmg" \
26 | jq -r .hash)
28 sed -i "s|$current_hash|$new_hash|g" $positron_nix
30 # Update Linux hash.
31 current_hash=$(nix store prefetch-file --json --hash-type sha256 \
32 "https://github.com/posit-dev/positron/releases/download/${current_version}/Positron-${current_version}.deb" \
33 | jq -r .hash)
35 new_hash=$(nix store prefetch-file --json --hash-type sha256 \
36 "https://github.com/posit-dev/positron/releases/download/${new_version}/Positron-${new_version}.deb" \
37 | jq -r .hash)
39 sed -i "s|$current_hash|$new_hash|g" $positron_nix
41 # Update version
42 sed -i "s|$current_version|$new_version|g" $positron_nix
44 # Attempt to build.
45 export NIXPKGS_ALLOW_UNFREE=1
47 if ! nix-build -A positron-bin "$nixpkgs"; then
48 echo "The updated positron-bin failed to build."
49 exit 1
52 # Commit changes
53 git add "$positron_nix"
54 git commit -m "positron-bin: ${current_version} -> ${new_version}"