sourcehut: update.sh: bump `gqlgenVersion` on update too

This extends the current script to pull the gqlgen version from the
go.mod file in the repository root (which we check out already anyway)
and replace it as necessary.

Makes updating all packages _a lot_ less painful. And since this is now
automated, remove the default value we previously defined for
`gqlgenVersion`.

Signed-off-by: Christoph Heiss <christoph@c8h4.io>

+14 -6
+1 -1
pkgs/applications/version-management/sourcehut/fix-gqlgen-trimpath.nix
··· 1 1 { unzip 2 - , gqlgenVersion ? "0.17.42" 2 + , gqlgenVersion 3 3 }: 4 4 { 5 5 overrideModAttrs = (_: {
+13 -5
pkgs/applications/version-management/sourcehut/update.sh
··· 1 1 #! /usr/bin/env nix-shell 2 - #! nix-shell -i bash -p git mercurial common-updater-scripts 2 + #! nix-shell -i bash -p gnused git mercurial common-updater-scripts 3 3 set -eux -o pipefail 4 4 5 5 cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 ··· 34 34 rm -rf "$tmp" 35 35 if [ "$1" = "hgsrht" ]; then 36 36 hg clone "$src" "$tmp" >/dev/null 37 - printf "%s" "$(cd "$tmp" && hg log --limit 1 --template '{latesttag}')" 37 + printf "%s %s\n" \ 38 + "$(cd "$tmp" && hg log --limit 1 --template '{latesttag}')" \ 39 + "$(cd "$tmp" && sed -ne 's/^\s*github\.com\/99designs\/gqlgen v\(.*\)$/\1/p' go.mod)" 38 40 else 39 41 git clone "$src" "$tmp" >/dev/null 40 - printf "%s" "$(cd "$tmp" && git describe "$(git rev-list --tags --max-count=1)")" 42 + printf "%s %s\n" \ 43 + "$(cd "$tmp" && git describe "$(git rev-list --tags --max-count=1)")" \ 44 + "$(cd "$tmp" && sed -ne 's/^\s*github\.com\/99designs\/gqlgen v\(.*\)$/\1/p' go.mod)" 41 45 fi 42 46 } 43 47 44 48 update_version() { 45 49 default_nix="$(default "$1")" 46 50 oldVersion="$(version "$1")" 47 - version="$(get_latest_version "$1")" 51 + read -r version gqlgen_ver < <(get_latest_version "$1") 48 52 local p="$(attr_path "$1")" 49 53 50 54 (cd "$root" && update-source-version "$p" "$version") 51 55 56 + # update `gqlgenVersion` if necessary 57 + old_gqlgen_ver="$(sed -ne 's/^.*gqlgenVersion = "\(.*\)".*$/\1/p' "$default_nix")" 58 + sed -ri "s|gqlgenVersion = \"$old_gqlgen_ver\";|gqlgenVersion = \"$gqlgen_ver\";|w /dev/stdout" "$default_nix" 59 + 52 60 # Update vendorHash of Go modules 53 61 retry=true 54 62 while "$retry"; do ··· 63 71 done 64 72 done 65 73 66 - if [ "$oldVersion" != "$version" ]; then 74 + if [ "$oldVersion" != "$version" ] || [ "$old_gqlgen_ver" != "$gqlgen_ver" ]; then 67 75 git add "$default_nix" 68 76 git commit -m "sourcehut.$1: $oldVersion -> $version" 69 77 fi