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" \
14 if [[ "$new_version" == "$current_version" ]]; then
15 echo 'Positron is already up to date'
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" \
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" \
28 sed -i "s|$current_hash|$new_hash|g" $positron_nix
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" \
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" \
39 sed -i "s|$current_hash|$new_hash|g" $positron_nix
42 sed -i "s|$current_version|$new_version|g" $positron_nix
45 export NIXPKGS_ALLOW_UNFREE
=1
47 if ! nix-build
-A positron-bin
"$nixpkgs"; then
48 echo "The updated positron-bin failed to build."
53 git add
"$positron_nix"
54 git commit
-m "positron-bin: ${current_version} -> ${new_version}"