From 94f3589623d1bb663b246c700e21fc3733ff8158 Mon Sep 17 00:00:00 2001
From: Earl Warren <contact@earl-warren.org>
Date: Sat, 3 Aug 2024 09:55:09 +0200
Subject: [PATCH] chore(ci): do not hardcode go version, use go.mod instead

---
 .forgejo/testdata/build-release/go.mod |  3 +++
 .forgejo/workflows/build-release.yml   |  3 +--
 .forgejo/workflows/e2e.yml             |  3 +--
 .forgejo/workflows/publish-release.yml |  3 +--
 .forgejo/workflows/testing.yml         | 16 +++++++---------
 go.mod                                 |  4 +---
 6 files changed, 14 insertions(+), 18 deletions(-)
 create mode 100644 .forgejo/testdata/build-release/go.mod

diff --git a/.forgejo/testdata/build-release/go.mod b/.forgejo/testdata/build-release/go.mod
new file mode 100644
index 0000000000..693f9aae19
--- /dev/null
+++ b/.forgejo/testdata/build-release/go.mod
@@ -0,0 +1,3 @@
+module code.gitea.io/gitea
+
+go 1.22.5
diff --git a/.forgejo/workflows/build-release.yml b/.forgejo/workflows/build-release.yml
index eb4297c7ef..3e5c4ea6b2 100644
--- a/.forgejo/workflows/build-release.yml
+++ b/.forgejo/workflows/build-release.yml
@@ -43,8 +43,7 @@ jobs:
 
       - uses: https://code.forgejo.org/actions/setup-go@v4
         with:
-          go-version: "1.22"
-          check-latest: true
+          go-version-file: "go.mod"
 
       - name: version from ref
         id: release-info
diff --git a/.forgejo/workflows/e2e.yml b/.forgejo/workflows/e2e.yml
index cda9991027..eec82953bc 100644
--- a/.forgejo/workflows/e2e.yml
+++ b/.forgejo/workflows/e2e.yml
@@ -19,8 +19,7 @@ jobs:
       - uses: https://code.forgejo.org/actions/checkout@v4
       - uses: https://code.forgejo.org/actions/setup-go@v4
         with:
-          go-version: "1.22"
-          check-latest: true
+          go-version-file: "go.mod"
       - run: |
           apt-get -qq update
           apt-get -qq install -q sudo
diff --git a/.forgejo/workflows/publish-release.yml b/.forgejo/workflows/publish-release.yml
index 19192615dc..e22b4e8c25 100644
--- a/.forgejo/workflows/publish-release.yml
+++ b/.forgejo/workflows/publish-release.yml
@@ -74,8 +74,7 @@ jobs:
         if: vars.ROLE == 'forgejo-experimental' && secrets.OVH_APP_KEY != ''
         uses: https://code.forgejo.org/actions/setup-go@v4
         with:
-          go-version: "1.22"
-          check-latest: true
+          go-version-file: "go.mod"
       - name: update the _release.experimental DNS record
         if: vars.ROLE == 'forgejo-experimental' && secrets.OVH_APP_KEY != ''
         uses: https://code.forgejo.org/actions/ovh-dns-update@v1
diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml
index d6c127a355..13d01011e3 100644
--- a/.forgejo/workflows/testing.yml
+++ b/.forgejo/workflows/testing.yml
@@ -22,8 +22,7 @@ jobs:
       - uses: https://code.forgejo.org/actions/checkout@v3
       - uses: https://code.forgejo.org/actions/setup-go@v4
         with:
-          go-version: "1.22"
-          check-latest: true
+          go-version-file: "go.mod"
       - run: make deps-backend deps-tools
       - run: make --always-make -j$(nproc) lint-backend tidy-check swagger-check fmt-check swagger-validate # ensure the "go-licenses" make target runs
   frontend-checks:
@@ -62,7 +61,7 @@ jobs:
       - uses: https://code.forgejo.org/actions/checkout@v3
       - uses: https://code.forgejo.org/actions/setup-go@v4
         with:
-          go-version: "1.22"
+          go-version-file: "go.mod"
       - run: |
           git config --add safe.directory '*'
           adduser --quiet --comment forgejo --disabled-password forgejo
@@ -121,7 +120,7 @@ jobs:
       - uses: https://code.forgejo.org/actions/checkout@v3
       - uses: https://code.forgejo.org/actions/setup-go@v4
         with:
-          go-version: "1.22"
+          go-version-file: "go.mod"
       - run: |
           git config --add safe.directory '*'
           adduser --quiet --comment forgejo --disabled-password forgejo
@@ -167,7 +166,7 @@ jobs:
       - uses: https://code.forgejo.org/actions/checkout@v3
       - uses: https://code.forgejo.org/actions/setup-go@v4
         with:
-          go-version: "1.22"
+          go-version-file: "go.mod"
       - name: install dependencies & git >= 2.42
         run: |
           export DEBIAN_FRONTEND=noninteractive
@@ -216,7 +215,7 @@ jobs:
       - uses: https://code.forgejo.org/actions/checkout@v3
       - uses: https://code.forgejo.org/actions/setup-go@v4
         with:
-          go-version: "1.22"
+          go-version-file: "go.mod"
       - name: install dependencies & git >= 2.42
         run: |
           export DEBIAN_FRONTEND=noninteractive
@@ -254,7 +253,7 @@ jobs:
       - uses: https://code.forgejo.org/actions/checkout@v3
       - uses: https://code.forgejo.org/actions/setup-go@v4
         with:
-          go-version: "1.22"
+          go-version-file: "go.mod"
       - name: install dependencies & git >= 2.42
         run: |
           export DEBIAN_FRONTEND=noninteractive
@@ -297,7 +296,6 @@ jobs:
       - uses: https://code.forgejo.org/actions/checkout@v3
       - uses: https://code.forgejo.org/actions/setup-go@v4
         with:
-          go-version: "1.22"
-          check-latest: true
+          go-version-file: "go.mod"
       - run: make deps-backend deps-tools
       - run: make security-check
diff --git a/go.mod b/go.mod
index 35237fbac6..4a80405153 100644
--- a/go.mod
+++ b/go.mod
@@ -1,8 +1,6 @@
 module code.gitea.io/gitea
 
-go 1.22.0
-
-toolchain go1.22.5
+go 1.22.5
 
 require (
 	code.forgejo.org/f3/gof3/v3 v3.4.0