Repository: grafana/tanka (go)

Issue:
Go version mismatch
There is currently a bit of a version mismatch regarding which Go version is used in the Docker image vs. in the binaries that are part of the GH releases. The Docker images are already on the latest 1.21 (as updated by Dependabot) while the binaries are on the latest 1.20 (due to the GH actions being hard-coded to that).

It would be awesome if there was a single source that specified which Go version to use and that is then used by both artifact-paths. Perhaps something like Dagger might help here?

Pull request description:
chore: Use Dockerfile as source for the Go version
Resolves #954

Patch:
diff --git a/.github/actions/setup-goversion/action.yml b/.github/actions/setup-goversion/action.yml
new file mode 100644
index 00000000..2570615a
--- /dev/null
+++ b/.github/actions/setup-goversion/action.yml
@@ -0,0 +1,11 @@
+name: setup-goversion
+runs:
+  using: composite
+  steps:
+    - id: goversion
+      run: |
+        cat Dockerfile | awk '/^FROM golang:.* as build$/ {v=$2;split(v,a,":")}; END {printf("version=%s", a[2])}' >> $GITHUB_OUTPUT
+      shell: bash
+    - uses: actions/setup-go@v5
+      with:
+        go-version: "${{steps.goversion.outputs.version}}"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d374c8eb..863a658e 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -15,9 +15,7 @@ jobs:
       - uses: actions/checkout@v4
         with:
           fetch-tags: true
-      - uses: actions/setup-go@v5
-        with:
-          go-version: '1.20'
+      - uses: ./.github/actions/setup-goversion
       - run: make cross
       - id: docker_tag
         run: echo "DOCKER_TAG=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index cccee894..24969d89 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -13,18 +13,14 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
-      - uses: actions/setup-go@v5
-        with:
-          go-version: '1.20'
+      - uses: ./.github/actions/setup-goversion
       - run: make lint
   
   test:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
-      - uses: actions/setup-go@v5
-        with:
-          go-version: '1.20'
+      - uses: ./.github/actions/setup-goversion
       - uses: azure/setup-helm@v3
         with:
           version: '3.13.1' 
@@ -36,7 +32,5 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
-      - uses: actions/setup-go@v5
-        with:
-          go-version: '1.20'
+      - uses: ./.github/actions/setup-goversion
       - run: make cross