This commit is contained in:
Shelvacu
2025-07-23 19:49:45 -07:00
committed by Shelvacu on fw
parent 6e7e20a088
commit 6b286a8af5

42
update.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
source shellvaculib.bash
function v() {
declare -a cmd=("$@")
declare -p cmd >&2
"${cmd[@]}"
}
function nix_common() {
v nix --show-trace -L -v "$@"
}
what="${1-}"
if ! git diff --quiet --exit-code HEAD; then
svl_die "there must be no changes in working tree to run this"
fi
if [[ $what == 'flake' ]] || [[ -z $what ]]; then
v nix flake update
if ! git diff --quiet --exit-code HEAD -- flake.lock; then
v git commit -m 'nix flake update' -- flake.lock
fi
fi
if [[ $what == 'bandcamp-collection-downloader' ]] || [[ $what == 'bcd' ]] || [[ -z $what ]]; then
tmpdir="$(mktemp -d)"
trap '[[ -d $tmpdir ]] && rm -rf "$tmpdir"' EXIT
commit_message_path="$tmpdir/commit_message.txt"
nix_common run '.#stable.nix-update' -- bandcamp-collection-downloader --version=branch --flake --write-commit-message "$commit_message_path"
# v cat "$commit_message_path"
# exit 0
if ! git diff --quiet --exit-code HEAD -- packages/bandcamp-collection-downloader; then
mitmUpdate="$(nix_common build '.#bandcamp-collection-downloader.mitmCache.updateScript' --no-link --print-out-paths)"
v "$mitmUpdate"
nix_common build '.#bandcamp-collection-downloader' --no-link
v git commit --file="$commit_message_path" packages/bandcamp-collection-downloader
fi
rm -rf "$tmpdir"
fi