diff options
author | Christoph Heiss <christoph@c8h4.io> | 2024-03-29 00:13:36 +0100 |
---|---|---|
committer | Christoph Heiss <christoph@c8h4.io> | 2024-04-09 23:06:17 +0200 |
commit | 8edd3e2105823c02a60774dc02e2d67136fdb66e (patch) | |
tree | 4f1c6fbc5e96194c74fa9416bf4b9253dce28f48 /pkgs/applications/version-management/sourcehut | |
parent | ae67af30bceb0935d7df51a168fc555f0841a8f6 (diff) |
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>
Diffstat (limited to 'pkgs/applications/version-management/sourcehut')
-rw-r--r-- | pkgs/applications/version-management/sourcehut/fix-gqlgen-trimpath.nix | 2 | ||||
-rwxr-xr-x | pkgs/applications/version-management/sourcehut/update.sh | 18 |
2 files changed, 14 insertions, 6 deletions
diff --git a/pkgs/applications/version-management/sourcehut/fix-gqlgen-trimpath.nix b/pkgs/applications/version-management/sourcehut/fix-gqlgen-trimpath.nix index ee598c5ed9144..5c6f9aa18b2f3 100644 --- a/pkgs/applications/version-management/sourcehut/fix-gqlgen-trimpath.nix +++ b/pkgs/applications/version-management/sourcehut/fix-gqlgen-trimpath.nix @@ -1,5 +1,5 @@ { unzip -, gqlgenVersion ? "0.17.42" +, gqlgenVersion }: { overrideModAttrs = (_: { diff --git a/pkgs/applications/version-management/sourcehut/update.sh b/pkgs/applications/version-management/sourcehut/update.sh index e9efc0816eb13..e5dd0b5baed04 100755 --- a/pkgs/applications/version-management/sourcehut/update.sh +++ b/pkgs/applications/version-management/sourcehut/update.sh @@ -1,5 +1,5 @@ #! /usr/bin/env nix-shell -#! nix-shell -i bash -p git mercurial common-updater-scripts +#! nix-shell -i bash -p gnused git mercurial common-updater-scripts set -eux -o pipefail cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 @@ -34,21 +34,29 @@ get_latest_version() { rm -rf "$tmp" if [ "$1" = "hgsrht" ]; then hg clone "$src" "$tmp" >/dev/null - printf "%s" "$(cd "$tmp" && hg log --limit 1 --template '{latesttag}')" + printf "%s %s\n" \ + "$(cd "$tmp" && hg log --limit 1 --template '{latesttag}')" \ + "$(cd "$tmp" && sed -ne 's/^\s*github\.com\/99designs\/gqlgen v\(.*\)$/\1/p' go.mod)" else git clone "$src" "$tmp" >/dev/null - printf "%s" "$(cd "$tmp" && git describe "$(git rev-list --tags --max-count=1)")" + printf "%s %s\n" \ + "$(cd "$tmp" && git describe "$(git rev-list --tags --max-count=1)")" \ + "$(cd "$tmp" && sed -ne 's/^\s*github\.com\/99designs\/gqlgen v\(.*\)$/\1/p' go.mod)" fi } update_version() { default_nix="$(default "$1")" oldVersion="$(version "$1")" - version="$(get_latest_version "$1")" + read -r version gqlgen_ver < <(get_latest_version "$1") local p="$(attr_path "$1")" (cd "$root" && update-source-version "$p" "$version") + # update `gqlgenVersion` if necessary + old_gqlgen_ver="$(sed -ne 's/^.*gqlgenVersion = "\(.*\)".*$/\1/p' "$default_nix")" + sed -ri "s|gqlgenVersion = \"$old_gqlgen_ver\";|gqlgenVersion = \"$gqlgen_ver\";|w /dev/stdout" "$default_nix" + # Update vendorHash of Go modules retry=true while "$retry"; do @@ -63,7 +71,7 @@ update_version() { done done - if [ "$oldVersion" != "$version" ]; then + if [ "$oldVersion" != "$version" ] || [ "$old_gqlgen_ver" != "$gqlgen_ver" ]; then git add "$default_nix" git commit -m "sourcehut.$1: $oldVersion -> $version" fi |