From 69e69c1b17b55a57d70d93cffe179fbcba38cc69 Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 4 Sep 2026 16:12:54 +0200 Subject: [PATCH 1/8] Fix Go bump workflow toolchain Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2faaf54-9531-419e-a272-87d33b1ce488 --- .github/workflows/bump-go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bump-go.yml b/.github/workflows/bump-go.yml index 9da690b3014..c64e690f4ad 100644 --- a/.github/workflows/bump-go.yml +++ b/.github/workflows/bump-go.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: - go-version-file: 'go.mod' + go-version: 'stable' - name: Bump Go version env: From 41b7d3c180e9530698a99a6e0c08b41ea4dec8e6 Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 4 Sep 2026 16:26:24 +0200 Subject: [PATCH 2/8] Validate automated Go version bumps Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2faaf54-9531-419e-a272-87d33b1ce488 --- .github/workflows/bump-go.yml | 6 ++++++ .github/workflows/lint.yml | 2 +- .github/workflows/scripts/bump-go.sh | 18 ++++++++++++++---- git/client.go | 1 + pkg/cmd/repo/create/create.go | 1 + pkg/cmd/repo/fork/fork.go | 1 + 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bump-go.yml b/.github/workflows/bump-go.yml index c64e690f4ad..2422af09fd0 100644 --- a/.github/workflows/bump-go.yml +++ b/.github/workflows/bump-go.yml @@ -18,6 +18,12 @@ jobs: with: go-version: 'stable' + - name: Install golangci-lint + uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 + with: + version: v2.13.2 + install-only: true + - name: Bump Go version env: GIT_COMMITTER_NAME: cli automation diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c78f88314a6..f7a5db1d76c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -40,7 +40,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 with: - version: v2.12.2 + version: v2.13.2 # Verify that license generation succeeds for all release platforms (GOOS/GOARCH). # This catches issues like new dependencies with unrecognized licenses before release time. diff --git a/.github/workflows/scripts/bump-go.sh b/.github/workflows/scripts/bump-go.sh index 16dd346e815..b96656414b7 100755 --- a/.github/workflows/scripts/bump-go.sh +++ b/.github/workflows/scripts/bump-go.sh @@ -81,20 +81,30 @@ go mod edit -go="$GO_DIRECTIVE_VERSION" -toolchain="go$TOOLCHAIN_VERSION" "$GO_M echo " • set go directive → $GO_DIRECTIVE_VERSION" echo " • set toolchain → go$TOOLCHAIN_VERSION" -# Let go mod tidy reconcile dependencies and normalize directives. +# Reconcile the module, apply source migrations, and verify the result before +# creating a pull request. echo " • running go mod tidy..." pushd "$MODULE_DIR" > /dev/null go mod tidy +echo " • running go fix..." +go fix ./... +status=0 +echo " • running tests..." +go test ./... || status=$? +echo " • running golangci-lint..." +golangci-lint run ./... || status=$? +if [[ $status -ne 0 ]]; then + exit "$status" +fi popd > /dev/null # ---- Check if anything actually changed ------------------------------------- -if git diff --quiet -- "$GO_MOD" "$GO_SUM" 2>/dev/null; then +if git diff --quiet; then echo "Already on latest Go version -- no changes needed." exit 0 fi -git add "$GO_MOD" -[[ -f "$GO_SUM" ]] && git add "$GO_SUM" +git add -u # ---- Commit ----------------------------------------------------------------- COMMIT_MSG="Bump Go to $TOOLCHAIN_VERSION" diff --git a/git/client.go b/git/client.go index fe16415651b..c08ac65e4d1 100644 --- a/git/client.go +++ b/git/client.go @@ -46,6 +46,7 @@ var remoteRE = regexp.MustCompile(`(.+)\s+(.+)\s+\((push|fetch)\)`) var commitLogRE = regexp.MustCompile(`(?m)^[0-9a-fA-F]{7,40}\x00.*?\x00[\S\s]*?\x00$`) type errWithExitCode interface { + error ExitCode() int } diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index be0be2dddc2..f10d6a6ff8d 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -26,6 +26,7 @@ import ( ) type errWithExitCode interface { + error ExitCode() int } diff --git a/pkg/cmd/repo/fork/fork.go b/pkg/cmd/repo/fork/fork.go index e1e6a335183..2b17ecef657 100644 --- a/pkg/cmd/repo/fork/fork.go +++ b/pkg/cmd/repo/fork/fork.go @@ -54,6 +54,7 @@ type ForkOptions struct { } type errWithExitCode interface { + error ExitCode() int } From fda2d6138967871a19b13bbfe8868921e97445c3 Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 4 Sep 2026 16:32:48 +0200 Subject: [PATCH 3/8] Defer Go source migrations to bump Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2faaf54-9531-419e-a272-87d33b1ce488 --- git/client.go | 1 - pkg/cmd/repo/create/create.go | 1 - pkg/cmd/repo/fork/fork.go | 1 - 3 files changed, 3 deletions(-) diff --git a/git/client.go b/git/client.go index c08ac65e4d1..fe16415651b 100644 --- a/git/client.go +++ b/git/client.go @@ -46,7 +46,6 @@ var remoteRE = regexp.MustCompile(`(.+)\s+(.+)\s+\((push|fetch)\)`) var commitLogRE = regexp.MustCompile(`(?m)^[0-9a-fA-F]{7,40}\x00.*?\x00[\S\s]*?\x00$`) type errWithExitCode interface { - error ExitCode() int } diff --git a/pkg/cmd/repo/create/create.go b/pkg/cmd/repo/create/create.go index f10d6a6ff8d..be0be2dddc2 100644 --- a/pkg/cmd/repo/create/create.go +++ b/pkg/cmd/repo/create/create.go @@ -26,7 +26,6 @@ import ( ) type errWithExitCode interface { - error ExitCode() int } diff --git a/pkg/cmd/repo/fork/fork.go b/pkg/cmd/repo/fork/fork.go index 2b17ecef657..e1e6a335183 100644 --- a/pkg/cmd/repo/fork/fork.go +++ b/pkg/cmd/repo/fork/fork.go @@ -54,7 +54,6 @@ type ForkOptions struct { } type errWithExitCode interface { - error ExitCode() int } From 3e3eb860c20a2ffc5e7ac0c1b984ad014d1f0e85 Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 4 Sep 2026 16:41:04 +0200 Subject: [PATCH 4/8] Resolve linter version during Go bumps Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2faaf54-9531-419e-a272-87d33b1ce488 --- .github/workflows/bump-go.yml | 2 +- .github/workflows/scripts/bump-go.sh | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bump-go.yml b/.github/workflows/bump-go.yml index 2422af09fd0..bcd4edc43ff 100644 --- a/.github/workflows/bump-go.yml +++ b/.github/workflows/bump-go.yml @@ -21,7 +21,7 @@ jobs: - name: Install golangci-lint uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 with: - version: v2.13.2 + version: latest install-only: true - name: Bump Go version diff --git a/.github/workflows/scripts/bump-go.sh b/.github/workflows/scripts/bump-go.sh index b96656414b7..9b012b5d8a2 100755 --- a/.github/workflows/scripts/bump-go.sh +++ b/.github/workflows/scripts/bump-go.sh @@ -38,6 +38,8 @@ done REPO="cli/cli" MODULE_DIR=$(dirname "$GO_MOD") GO_SUM="$MODULE_DIR/go.sum" +REPO_ROOT=$(git rev-parse --show-toplevel) +LINT_WORKFLOW="$REPO_ROOT/.github/workflows/lint.yml" # ---- Discover latest stable Go release -------------------------------------- echo "Fetching latest stable Go version..." @@ -49,6 +51,15 @@ GO_DIRECTIVE_VERSION="$(cut -d. -f1-2 <<< "$TOOLCHAIN_VERSION").0" echo " → go directive : $GO_DIRECTIVE_VERSION" echo " → toolchain : go$TOOLCHAIN_VERSION" +# Keep regular CI reproducibly pinned to the linter release used to validate +# this bump. +LINTER_VERSION=$(golangci-lint version --short) +if [[ ! "$LINTER_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: unexpected golangci-lint version '$LINTER_VERSION'" >&2 + exit 1 +fi +echo " → golangci-lint: v$LINTER_VERSION" + # ---- Read current go.mod state using go mod edit ---------------------------- GO_MOD_JSON=$(go mod edit -json "$GO_MOD") CURRENT_GO_DIRECTIVE=$(jq -r '.Go // ""' <<< "$GO_MOD_JSON") @@ -81,6 +92,15 @@ go mod edit -go="$GO_DIRECTIVE_VERSION" -toolchain="go$TOOLCHAIN_VERSION" "$GO_M echo " • set go directive → $GO_DIRECTIVE_VERSION" echo " • set toolchain → go$TOOLCHAIN_VERSION" +lint_version_lines=$(grep -Ec '^[[:space:]]+version: v[0-9]+\.[0-9]+\.[0-9]+$' "$LINT_WORKFLOW" || true) +if [[ $lint_version_lines -ne 1 ]]; then + echo "Error: expected exactly one pinned golangci-lint version in '$LINT_WORKFLOW'" >&2 + exit 1 +fi +sed -i.bak -E "s/^([[:space:]]+version: )v[0-9]+\.[0-9]+\.[0-9]+$/\1v$LINTER_VERSION/" "$LINT_WORKFLOW" +rm -f "$LINT_WORKFLOW.bak" +echo " • set golangci-lint → v$LINTER_VERSION" + # Reconcile the module, apply source migrations, and verify the result before # creating a pull request. echo " • running go mod tidy..." @@ -151,6 +171,7 @@ This PR updates Go to the latest stable release. * **go directive:** \`$FINAL_GO\` $TC_LINE +* **golangci-lint:** \`v$LINTER_VERSION\` EOF ) From 05dee02976774b246ce3373dbbb62c01f780e1d6 Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 4 Sep 2026 17:01:20 +0200 Subject: [PATCH 5/8] Keep Go bump inputs scoped Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2faaf54-9531-419e-a272-87d33b1ce488 --- .github/workflows/lint.yml | 2 +- .github/workflows/scripts/bump-go.sh | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f7a5db1d76c..c78f88314a6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -40,7 +40,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 with: - version: v2.13.2 + version: v2.12.2 # Verify that license generation succeeds for all release platforms (GOOS/GOARCH). # This catches issues like new dependencies with unrecognized licenses before release time. diff --git a/.github/workflows/scripts/bump-go.sh b/.github/workflows/scripts/bump-go.sh index 9b012b5d8a2..d449ad07ac8 100755 --- a/.github/workflows/scripts/bump-go.sh +++ b/.github/workflows/scripts/bump-go.sh @@ -35,10 +35,15 @@ done [[ -z "$GO_MOD" ]] && usage [[ -f "$GO_MOD" ]] || { echo "Error: '$GO_MOD' not found" >&2; exit 1; } +REPO_ROOT=$(git rev-parse --show-toplevel) +if ! git -C "$REPO_ROOT" diff --quiet || ! git -C "$REPO_ROOT" diff --cached --quiet; then + echo "Error: tracked changes must be committed or stashed before running this script" >&2 + exit 1 +fi + REPO="cli/cli" MODULE_DIR=$(dirname "$GO_MOD") GO_SUM="$MODULE_DIR/go.sum" -REPO_ROOT=$(git rev-parse --show-toplevel) LINT_WORKFLOW="$REPO_ROOT/.github/workflows/lint.yml" # ---- Discover latest stable Go release -------------------------------------- @@ -92,14 +97,18 @@ go mod edit -go="$GO_DIRECTIVE_VERSION" -toolchain="go$TOOLCHAIN_VERSION" "$GO_M echo " • set go directive → $GO_DIRECTIVE_VERSION" echo " • set toolchain → go$TOOLCHAIN_VERSION" -lint_version_lines=$(grep -Ec '^[[:space:]]+version: v[0-9]+\.[0-9]+\.[0-9]+$' "$LINT_WORKFLOW" || true) -if [[ $lint_version_lines -ne 1 ]]; then - echo "Error: expected exactly one pinned golangci-lint version in '$LINT_WORKFLOW'" >&2 - exit 1 +if ! git diff --quiet -- "$GO_MOD"; then + lint_version_lines=$(grep -Ec '^[[:space:]]+version: v[0-9]+\.[0-9]+\.[0-9]+$' "$LINT_WORKFLOW" || true) + if [[ $lint_version_lines -ne 1 ]]; then + echo "Error: expected exactly one pinned golangci-lint version in '$LINT_WORKFLOW'" >&2 + exit 1 + fi + sed -i.bak -E "s/^([[:space:]]+version: )v[0-9]+\.[0-9]+\.[0-9]+$/\1v$LINTER_VERSION/" "$LINT_WORKFLOW" + rm -f "$LINT_WORKFLOW.bak" + echo " • set golangci-lint → v$LINTER_VERSION" +else + echo " • Go version unchanged; keeping the existing golangci-lint pin" fi -sed -i.bak -E "s/^([[:space:]]+version: )v[0-9]+\.[0-9]+\.[0-9]+$/\1v$LINTER_VERSION/" "$LINT_WORKFLOW" -rm -f "$LINT_WORKFLOW.bak" -echo " • set golangci-lint → v$LINTER_VERSION" # Reconcile the module, apply source migrations, and verify the result before # creating a pull request. From 6232ed14d69f74cae5c74dfa9f9d804932780f6f Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 4 Sep 2026 17:37:20 +0200 Subject: [PATCH 6/8] Harden Go bump version and cleanup Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2faaf54-9531-419e-a272-87d33b1ce488 --- .github/workflows/bump-go.yml | 3 ++- .github/workflows/scripts/bump-go.sh | 32 +++++++++++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bump-go.yml b/.github/workflows/bump-go.yml index bcd4edc43ff..c0f65d6fbee 100644 --- a/.github/workflows/bump-go.yml +++ b/.github/workflows/bump-go.yml @@ -14,6 +14,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up Go + id: setup-go uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version: 'stable' @@ -32,4 +33,4 @@ jobs: GIT_AUTHOR_EMAIL: noreply@github.com GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - bash .github/workflows/scripts/bump-go.sh --apply go.mod + bash .github/workflows/scripts/bump-go.sh --apply --version "${{ steps.setup-go.outputs.go-version }}" go.mod diff --git a/.github/workflows/scripts/bump-go.sh b/.github/workflows/scripts/bump-go.sh index d449ad07ac8..e37d1971ae6 100755 --- a/.github/workflows/scripts/bump-go.sh +++ b/.github/workflows/scripts/bump-go.sh @@ -3,7 +3,7 @@ # bump-go.sh -- Update go.mod `go` directive and toolchain to latest stable Go release. # # Usage: -# ./bump-go.sh [--apply|-a] +# ./bump-go.sh [--apply|-a] [--version ] # # By default the script runs in *dry-run* mode: it creates a local branch, # commits the version bump, shows the exact patch, **checks for an existing PR** @@ -15,17 +15,23 @@ set -euo pipefail usage() { - echo "Usage: $0 [--apply|-a] " >&2 + echo "Usage: $0 [--apply|-a] [--version ] " >&2 exit 1 } # ---- Argument parsing ------------------------------------------------------- APPLY=0 GO_MOD="" +TARGET_GO_VERSION="" while [[ $# -gt 0 ]]; do case "$1" in --apply|-a) APPLY=1 ;; + --version) + shift + [[ $# -gt 0 ]] || usage + TARGET_GO_VERSION="${1#go}" + ;; -h|--help) usage ;; *) [[ -z "$GO_MOD" ]] && GO_MOD="$1" || usage ;; esac @@ -47,10 +53,19 @@ GO_SUM="$MODULE_DIR/go.sum" LINT_WORKFLOW="$REPO_ROOT/.github/workflows/lint.yml" # ---- Discover latest stable Go release -------------------------------------- -echo "Fetching latest stable Go version..." -LATEST_JSON=$(curl -fsSL https://go.dev/dl/?mode=json | jq -c '[.[] | select(.stable==true)][0]') -FULL_VERSION=$(jq -r '.version' <<< "$LATEST_JSON") # e.g. go1.23.4 -TOOLCHAIN_VERSION="${FULL_VERSION#go}" # e.g. 1.23.4 +if [[ -n "$TARGET_GO_VERSION" ]]; then + TOOLCHAIN_VERSION="$TARGET_GO_VERSION" + echo "Using selected Go version..." +else + echo "Fetching latest stable Go version..." + LATEST_JSON=$(curl -fsSL https://go.dev/dl/?mode=json | jq -c '[.[] | select(.stable==true)][0]') + FULL_VERSION=$(jq -r '.version' <<< "$LATEST_JSON") # e.g. go1.23.4 + TOOLCHAIN_VERSION="${FULL_VERSION#go}" # e.g. 1.23.4 +fi +if [[ ! "$TOOLCHAIN_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: unexpected Go version '$TOOLCHAIN_VERSION'" >&2 + exit 1 +fi GO_DIRECTIVE_VERSION="$(cut -d. -f1-2 <<< "$TOOLCHAIN_VERSION").0" echo " → go directive : $GO_DIRECTIVE_VERSION" @@ -79,8 +94,9 @@ BRANCH_CREATED=0 cleanup() { if [[ $BRANCH_CREATED -eq 1 ]]; then - git checkout - >/dev/null 2>&1 || true - git branch -D "$BRANCH" >/dev/null 2>&1 || true + git -C "$REPO_ROOT" restore --source=HEAD --staged --worktree -- :/ >/dev/null 2>&1 || true + git -C "$REPO_ROOT" checkout - >/dev/null 2>&1 || true + git -C "$REPO_ROOT" branch -D "$BRANCH" >/dev/null 2>&1 || true fi } trap cleanup EXIT From a73c594ceea927acce8b3c0c7084f479f8b63c04 Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 4 Sep 2026 18:07:17 +0200 Subject: [PATCH 7/8] Check normalized Go state for lint bump Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2faaf54-9531-419e-a272-87d33b1ce488 --- .github/workflows/scripts/bump-go.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/scripts/bump-go.sh b/.github/workflows/scripts/bump-go.sh index e37d1971ae6..c0132734940 100755 --- a/.github/workflows/scripts/bump-go.sh +++ b/.github/workflows/scripts/bump-go.sh @@ -113,7 +113,12 @@ go mod edit -go="$GO_DIRECTIVE_VERSION" -toolchain="go$TOOLCHAIN_VERSION" "$GO_M echo " • set go directive → $GO_DIRECTIVE_VERSION" echo " • set toolchain → go$TOOLCHAIN_VERSION" -if ! git diff --quiet -- "$GO_MOD"; then +# Reconcile the module, apply source migrations, and verify the result before +# creating a pull request. +echo " • running go mod tidy..." +pushd "$MODULE_DIR" > /dev/null +go mod tidy +if ! git -C "$REPO_ROOT" diff --quiet -- "$GO_MOD"; then lint_version_lines=$(grep -Ec '^[[:space:]]+version: v[0-9]+\.[0-9]+\.[0-9]+$' "$LINT_WORKFLOW" || true) if [[ $lint_version_lines -ne 1 ]]; then echo "Error: expected exactly one pinned golangci-lint version in '$LINT_WORKFLOW'" >&2 @@ -125,12 +130,6 @@ if ! git diff --quiet -- "$GO_MOD"; then else echo " • Go version unchanged; keeping the existing golangci-lint pin" fi - -# Reconcile the module, apply source migrations, and verify the result before -# creating a pull request. -echo " • running go mod tidy..." -pushd "$MODULE_DIR" > /dev/null -go mod tidy echo " • running go fix..." go fix ./... status=0 From a6cb3e8572f2c147b86bd94fd61e80b0ed5b9ab2 Mon Sep 17 00:00:00 2001 From: Areesh Ali Date: Sat, 5 Sep 2026 11:50:22 +0500 Subject: [PATCH 8/8] docs: fix broken "GitHub language" link in primer foundations The "GitHub language" link pointed to `/getting-started/principles#make-it-feel-like-github`, which resolves to a nonexistent path when rendered on GitHub (there is no top-level `getting-started/principles`). The referenced "Make it feel like GitHub" section lives in `docs/primer/getting-started`. Update the link to `/docs/primer/getting-started#make-it-feel-like-github`, matching the `/docs/primer/#` convention already used elsewhere in the primer docs. --- docs/primer/foundations/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/primer/foundations/README.md b/docs/primer/foundations/README.md index e743bac022a..b62a2373679 100644 --- a/docs/primer/foundations/README.md +++ b/docs/primer/foundations/README.md @@ -54,7 +54,7 @@ _Tip: To get a better sense of what feels right, try writing out the commands in **When designing your command’s language system:** -- Use [GitHub language](/getting-started/principles#make-it-feel-like-github) +- Use [GitHub language](/docs/primer/getting-started#make-it-feel-like-github) - Use unambiguous language that can’t be confused for something else - Use shorter phrases if possible and appropriate