From e1c7a3ce83e727de0798c18546725c79c21bbe34 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Feb 2026 06:07:39 +0000 Subject: [PATCH 1/2] ci: read Go version from go.mod instead of hardcoding it Replace go-version: '1.25' with go-version-file: 'go.mod' in all GitHub Actions workflows. This ensures the CI always uses the exact Go version declared in go.mod, eliminating version mismatches that cause compilation errors when go.mod is updated. https://claude.ai/code/session_01MJYZTEboQKuBBTGN79ev56 --- .github/workflows/dependabot-build-check.yml | 2 +- .github/workflows/go-build-deploy.yml | 2 +- .github/workflows/newsletter.yml | 2 +- .github/workflows/sync-build-deploy.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dependabot-build-check.yml b/.github/workflows/dependabot-build-check.yml index 54865acc..5ae2da67 100644 --- a/.github/workflows/dependabot-build-check.yml +++ b/.github/workflows/dependabot-build-check.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v6 with: - go-version: '1.25' + go-version-file: 'go.mod' - name: Build Go project run: | diff --git a/.github/workflows/go-build-deploy.yml b/.github/workflows/go-build-deploy.yml index e404caf3..1208130b 100644 --- a/.github/workflows/go-build-deploy.yml +++ b/.github/workflows/go-build-deploy.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-go@v6 with: - go-version: '1.25' + go-version-file: 'go.mod' cache: true - name: Build diff --git a/.github/workflows/newsletter.yml b/.github/workflows/newsletter.yml index 317b20c1..f424270b 100644 --- a/.github/workflows/newsletter.yml +++ b/.github/workflows/newsletter.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-go@v6 with: - go-version: '1.25' + go-version-file: 'go.mod' - name: Build run: go build ./... diff --git a/.github/workflows/sync-build-deploy.yml b/.github/workflows/sync-build-deploy.yml index 2ec4c770..167fbd9b 100644 --- a/.github/workflows/sync-build-deploy.yml +++ b/.github/workflows/sync-build-deploy.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-go@v6 with: - go-version: '1.25' + go-version-file: 'go.mod' - name: Build run: go build ./... From b628ed0cd748344b1bfb5aba35e69723a3235dce Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Feb 2026 06:12:31 +0000 Subject: [PATCH 2/2] ci: extract checkout/setup-go/build into a composite action Add .github/actions/setup-and-build as a local composite action that encapsulates the three repeated steps present in every workflow: checkout, setup-go (from go.mod), and go build ./... All four workflows now reference it with a single `uses` line instead of duplicating these steps. The dependabot workflow's now-redundant manual exit-code check is also removed since `go build` already fails the step on a non-zero exit. https://claude.ai/code/session_01MJYZTEboQKuBBTGN79ev56 --- .github/actions/setup-and-build/action.yml | 16 ++++++++++++++++ .github/workflows/dependabot-build-check.yml | 18 +----------------- .github/workflows/go-build-deploy.yml | 10 +--------- .github/workflows/newsletter.yml | 9 +-------- .github/workflows/sync-build-deploy.yml | 9 +-------- 5 files changed, 20 insertions(+), 42 deletions(-) create mode 100644 .github/actions/setup-and-build/action.yml diff --git a/.github/actions/setup-and-build/action.yml b/.github/actions/setup-and-build/action.yml new file mode 100644 index 00000000..3d36559b --- /dev/null +++ b/.github/actions/setup-and-build/action.yml @@ -0,0 +1,16 @@ +name: Setup Go and Build +description: Checkout repo, set up Go version from go.mod, and compile the project + +runs: + using: composite + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-go@v6 + with: + go-version-file: 'go.mod' + cache: true + + - name: Build + shell: bash + run: go build ./... diff --git a/.github/workflows/dependabot-build-check.yml b/.github/workflows/dependabot-build-check.yml index 5ae2da67..09a5cc26 100644 --- a/.github/workflows/dependabot-build-check.yml +++ b/.github/workflows/dependabot-build-check.yml @@ -12,20 +12,4 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout PR branch - uses: actions/checkout@v6 - - - name: Set up Go - uses: actions/setup-go@v6 - with: - go-version-file: 'go.mod' - - - name: Build Go project - run: | - echo "Building Go project..." - go build ./... - if [ $? -ne 0 ]; then - echo "Go build failed!" - exit 1 - fi - echo "Go build successful!" + - uses: ./.github/actions/setup-and-build diff --git a/.github/workflows/go-build-deploy.yml b/.github/workflows/go-build-deploy.yml index 1208130b..3369cabc 100644 --- a/.github/workflows/go-build-deploy.yml +++ b/.github/workflows/go-build-deploy.yml @@ -12,15 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 - - - uses: actions/setup-go@v6 - with: - go-version-file: 'go.mod' - cache: true - - - name: Build - run: go build ./... + - uses: ./.github/actions/setup-and-build - name: Restore build cache uses: actions/cache@v5 diff --git a/.github/workflows/newsletter.yml b/.github/workflows/newsletter.yml index f424270b..31508614 100644 --- a/.github/workflows/newsletter.yml +++ b/.github/workflows/newsletter.yml @@ -12,14 +12,7 @@ jobs: contents: read steps: - - uses: actions/checkout@v6 - - - uses: actions/setup-go@v6 - with: - go-version-file: 'go.mod' - - - name: Build - run: go build ./... + - uses: ./.github/actions/setup-and-build - name: Post to Buttondown env: diff --git a/.github/workflows/sync-build-deploy.yml b/.github/workflows/sync-build-deploy.yml index 167fbd9b..e4995eec 100644 --- a/.github/workflows/sync-build-deploy.yml +++ b/.github/workflows/sync-build-deploy.yml @@ -15,14 +15,7 @@ jobs: contents: write steps: - - uses: actions/checkout@v6 - - - uses: actions/setup-go@v6 - with: - go-version-file: 'go.mod' - - - name: Build - run: go build ./... + - uses: ./.github/actions/setup-and-build - name: Create credentials.json run: |