1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl jq gnused
6 ROOT
="$(dirname "$
(readlink
-f "$0")")"
7 if [[ ! "$(basename $ROOT)" == "miru" ||
! -f "$ROOT/package.nix" ]]; then
8 echo "error: Not in the miru folder" >&2
12 PACKAGE_NIX
="$ROOT/package.nix"
13 LINUX_NIX
="$ROOT/linux.nix"
14 DARWIN_NIX
="$ROOT/darwin.nix"
16 MIRU_LATEST_VER
="$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https
://api.github.com
/repos
/ThaUnknown
/miru
/releases
/latest
" | jq -r .tag_name | sed 's/^v//')"
17 MIRU_CURRENT_VER
="$(grep -oP 'version = "\K
[^
"]+' "$PACKAGE_NIX")"
19 if [[ "$MIRU_LATEST_VER" == "null" ]]; then
20 echo "error: could not fetch miru latest version from GitHub API" >&2
24 if [[ "$MIRU_LATEST_VER" == "$MIRU_CURRENT_VER" ]]; then
25 echo "miru is up-to-date"
31 nix-hash
--to-sri --type sha256
"$(nix-prefetch-url --type sha256 "$1")"
34 replace_hash_in_file
() {
37 sed -i "s#hash = \".*\"#hash = \"$2\"#g" "$1"
40 replace_version_in_file
() {
43 sed -i "s#version = \".*\";#version = \"$2\";#g" "$1"
46 MIRU_LINUX_HASH
="$(get_hash "https
://github.com
/ThaUnknown
/miru
/releases
/download
/v
${MIRU_LATEST_VER}/linux-Miru-
${MIRU_LATEST_VER}.AppImage
")"
47 MIRU_DARWIN_HASH
="$(get_hash "https
://github.com
/ThaUnknown
/miru
/releases
/download
/v
${MIRU_LATEST_VER}/mac-Miru-
${MIRU_LATEST_VER}-mac.
zip")"
49 replace_hash_in_file
"$LINUX_NIX" "$MIRU_LINUX_HASH"
50 replace_hash_in_file
"$DARWIN_NIX" "$MIRU_DARWIN_HASH"
52 replace_version_in_file
"$PACKAGE_NIX" "$MIRU_LATEST_VER"