Skip to content

Commit

Permalink
bloomeetunes: add update script
Browse files Browse the repository at this point in the history
  • Loading branch information
aucub committed Dec 24, 2024
1 parent dea553a commit c35b142
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkgs/by-name/bl/bloomeetunes/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ flutter324.buildFlutterApplication rec {
src = fetchFromGitHub {
owner = "HemantKArya";
repo = "BloomeeTunes";
tag = "v${version}+153";
hash = "sha256-Zx64hu+f8b/epGR80Ql2z239oSBfBt9k7crIFJCLlm4=";
tag = "v${version}+154";
hash = "sha256-D3L8tW6ZtUS9UNlykYGcz+V1qZOMARCLKf38d2KYel4=";
};

pubspecLock = lib.importJSON ./pubspec.lock.json;
Expand Down Expand Up @@ -51,6 +51,8 @@ flutter324.buildFlutterApplication rec {
}"
'';

passthru.updateScript = ./update.sh;

meta = {
description = "Cross-platform music app designed to bring you ad-free tunes from various sources";
homepage = "https://github.com/HemantKArya/BloomeeTunes";
Expand Down
24 changes: 24 additions & 0 deletions pkgs/by-name/bl/bloomeetunes/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=./. -i bash -p curl gnused jq yq nixVersions.latest bash coreutils common-updater-scripts

set -eou pipefail

ROOT="$(dirname "$(readlink -f "$0")")"

latestTag=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sL https://api.github.com/repos/HemantKArya/BloomeeTunes/releases/latest | jq --raw-output .tag_name)
latestVersion=$(echo "$latestTag" | sed 's/^v//' | grep -o '^[^+]*')
RunNumber=$(echo "$latestTag" | grep -o '[^+]*$')

currentVersion=$(nix-instantiate --eval -E "with import ./. {}; bloomeetunes.version or (lib.getVersion bloomeetunes)" | tr -d '"')

if [[ "$currentVersion" == "$latestVersion" ]]; then
echo "package is up-to-date: $currentVersion"
exit 0
fi

sed -i "s/\(tag = \"v\${version}+\)[0-9]\+/\1${RunNumber}/" "$ROOT/package.nix"

hash=$(nix hash convert --hash-algo sha256 --to sri $(nix-prefetch-url --unpack "https://github.com/HemantKArya/BloomeeTunes/archive/refs/tags/${latestTag}.tar.gz"))
update-source-version bloomeetunes $latestVersion $hash

curl https://raw.githubusercontent.com/HemantKArya/BloomeeTunes/${latestTag}/pubspec.lock | yq . >$ROOT/pubspec.lock.json

0 comments on commit c35b142

Please sign in to comment.