From 19a65582481fe42f3db6008e6d91e8d3b60dd526 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Thu, 19 Sep 2024 02:20:41 +0900 Subject: [PATCH] Bump all go.mod in the updater script Resolves GH-705 I will test the actual behavior with triggering the workflow after this commit --- .github/workflows/update-flake-lock-and-ci.yml | 2 +- pkgs/bump_gomod/bump_gomod.bash | 9 +++++++-- pkgs/bump_gomod/default.nix | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-flake-lock-and-ci.yml b/.github/workflows/update-flake-lock-and-ci.yml index 52e6e16b..470df733 100644 --- a/.github/workflows/update-flake-lock-and-ci.yml +++ b/.github/workflows/update-flake-lock-and-ci.yml @@ -21,6 +21,6 @@ jobs: pr-title: 'Bump flake.lock and related dependencies' optional-run: | nix run .#bump_completions - nix run .#bump_gomod + nix run .#bump_gomod -- . pkgs/trim-github-user-prefix-for-reponame secrets: APP_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} diff --git a/pkgs/bump_gomod/bump_gomod.bash b/pkgs/bump_gomod/bump_gomod.bash index 5b3c61b6..be4e6ecf 100644 --- a/pkgs/bump_gomod/bump_gomod.bash +++ b/pkgs/bump_gomod/bump_gomod.bash @@ -1,5 +1,10 @@ -go get "go@$(go version | grep -oP '(?<=go)\d\S+')" +# `modRoot` in buildGoModule did not fit for this purpose +# https://github.com/NixOS/nixpkgs/blob/086b448a5d54fd117f4dc2dee55c9f0ff461bdc1/pkgs/build-support/go/module.nix#L12-L13 +for dir in "$@"; do + cd "$dir" || exit + go get "go@$(go version | grep -oP '(?<=go)\d\S+')" +done -git add go.mod go.sum +git ls-files '**go.mod' | xargs git add git update-index -q --really-refresh git diff-index --quiet HEAD || git commit -m 'Update go.mod' go.mod go.sum diff --git a/pkgs/bump_gomod/default.nix b/pkgs/bump_gomod/default.nix index 06ddac5e..934082f6 100644 --- a/pkgs/bump_gomod/default.nix +++ b/pkgs/bump_gomod/default.nix @@ -6,6 +6,7 @@ pkgs.writeShellApplication rec { git go gnugrep + findutils # `xargs` ]; meta = { description = "Update go.mod with method of https://github.com/kachick/times_kachick/issues/265";