Merge pull request #203372 from schnusch/nix-update-nitter

nitter: use nix-update in update script
This commit is contained in:
figsoda 2022-11-28 09:07:50 -05:00 committed by GitHub
commit f8035e172c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts curl jq nix nix-prefetch-git patchutils
#!nix-shell -i bash -p curl jq nix nix-update patchutils
set -euo pipefail
info() {
@ -11,19 +11,9 @@ info() {
printf "$@" >&2
}
nitter_old_version=$(nix-instantiate --eval --strict --json -A nitter.version . | jq -r .)
nitter_old_rev=$(nix-instantiate --eval --strict --json -A nitter.src.rev . | jq -r .)
today=$(LANG=C date -u +'%Y-%m-%d')
# use latest commit before today, we should not call the version *today*
# because there might still be commits coming
# use the day of the latest commit we picked as version
commit=$(curl -Sfs "https://api.github.com/repos/zedeus/nitter/compare/$nitter_old_rev~1...master" \
| jq '.commits | map(select(.commit.committer.date < $today) | {sha, date: .commit.committer.date}) | .[-1]' --arg today "$today")
nitter_new_rev=$(jq -r '.sha' <<< "$commit")
nitter_new_version="unstable-$(jq -r '.date[0:10]' <<< "$commit")"
info "latest commit before $today: $nitter_new_rev ($(jq -r '.date' <<< "$commit"))"
nix-update --version=branch --commit nitter
nitter_new_rev=$(nix-instantiate --eval --strict --json -A nitter.src.rev . | jq -r .)
if [ "$nitter_new_rev" = "$nitter_old_rev" ]; then
info "nitter is up-to-date."
exit
@ -33,8 +23,3 @@ if curl -Sfs "https://github.com/zedeus/nitter/compare/$nitter_old_rev...$nitter
| lsdiff | grep -Fxe 'a/nitter.nimble' -e 'b/nitter.nimble' > /dev/null; then
info "nitter.nimble changed, some dependencies probably need updating."
fi
nitter_new_sha256=$(nix-prefetch-git --rev "$nitter_new_rev" "https://github.com/zedeus/nitter.git" | jq -r .sha256)
update-source-version nitter "$nitter_new_version" "$nitter_new_sha256" --rev="$nitter_new_rev"
git commit --all --verbose --message "nitter: $nitter_old_version -> $nitter_new_version"
info "Updated nitter to $nitter_new_version."