From 6234d67ec679481f9eb1b697ac2d44b350f04644 Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 17 Jun 2025 15:26:55 -0700 Subject: [PATCH] Use `go.mod` as source of Go version number for workflows Go is used in the development and maintenance of the project. A standardized version of Go is used for all operations. This version is defined in the `go` directive of the `go.mod` metadata file. Go is installed in the GitHub Actions runner environments using the "actions/setup-go" action, which also must be configured to install the correct version of Go. Previously the version number for use by the "actions/setup-go" action was defined in each workflow. This meant that we had multiple copies of the Go version information, all of which had to be kept in sync. Fortunately, support for using `go.mod` as the source of version information for the "actions/setup-go" action was recently added. This means it is now possible for all workflows to get the Go version from a single source. --- workflow-templates/check-go-dependencies-task.yml | 8 ++------ workflow-templates/check-go-task.yml | 12 ++++-------- .../deploy-cobra-mkdocs-versioned-poetry.yml | 4 +--- workflow-templates/release-go-crosscompile-task.yml | 4 +--- workflow-templates/test-go-integration-task.yml | 4 +--- workflow-templates/test-go-task.yml | 6 +----- 6 files changed, 10 insertions(+), 28 deletions(-) diff --git a/workflow-templates/check-go-dependencies-task.yml b/workflow-templates/check-go-dependencies-task.yml index 4f213b30..88807599 100644 --- a/workflow-templates/check-go-dependencies-task.yml +++ b/workflow-templates/check-go-dependencies-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md name: Check Go Dependencies -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.17" - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -87,7 +83,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 @@ -146,7 +142,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 diff --git a/workflow-templates/check-go-task.yml b/workflow-templates/check-go-task.yml index 2883ce0b..3d206b65 100644 --- a/workflow-templates/check-go-task.yml +++ b/workflow-templates/check-go-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-task.md name: Check Go -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.17" - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -78,7 +74,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: ${{ matrix.module.path }}/go.mod - name: Install Task uses: arduino/setup-task@v2 @@ -117,7 +113,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: ${{ matrix.module.path }}/go.mod - name: Install Task uses: arduino/setup-task@v2 @@ -158,7 +154,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: ${{ matrix.module.path }}/go.mod - name: Install Task uses: arduino/setup-task@v2 @@ -197,7 +193,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: ${{ matrix.module.path }}/go.mod - name: Run go mod tidy working-directory: ${{ matrix.module.path }} diff --git a/workflow-templates/deploy-cobra-mkdocs-versioned-poetry.yml b/workflow-templates/deploy-cobra-mkdocs-versioned-poetry.yml index 27e1ce69..433a6052 100644 --- a/workflow-templates/deploy-cobra-mkdocs-versioned-poetry.yml +++ b/workflow-templates/deploy-cobra-mkdocs-versioned-poetry.yml @@ -2,8 +2,6 @@ name: Deploy Website env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.17" # See: https://github.com/actions/setup-python/tree/main#available-versions-of-python PYTHON_VERSION: "3.9" @@ -67,7 +65,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Python uses: actions/setup-python@v5 diff --git a/workflow-templates/release-go-crosscompile-task.yml b/workflow-templates/release-go-crosscompile-task.yml index 975f0e09..c346fb91 100644 --- a/workflow-templates/release-go-crosscompile-task.yml +++ b/workflow-templates/release-go-crosscompile-task.yml @@ -10,8 +10,6 @@ env: AWS_PLUGIN_TARGET: TODO_AWS_PLUGIN_TARGET AWS_REGION: "us-east-1" ARTIFACT_PREFIX: dist- - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.17" on: push: @@ -65,7 +63,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 diff --git a/workflow-templates/test-go-integration-task.yml b/workflow-templates/test-go-integration-task.yml index e00e5f6e..c61e8456 100644 --- a/workflow-templates/test-go-integration-task.yml +++ b/workflow-templates/test-go-integration-task.yml @@ -2,8 +2,6 @@ name: Test Integration env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.17" # See: https://github.com/actions/setup-python/tree/main#available-versions-of-python PYTHON_VERSION: "3.9" @@ -83,7 +81,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Python uses: actions/setup-python@v5 diff --git a/workflow-templates/test-go-task.yml b/workflow-templates/test-go-task.yml index b7f4dd79..35840f4f 100644 --- a/workflow-templates/test-go-task.yml +++ b/workflow-templates/test-go-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/test-go-task.md name: Test Go -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.17" - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -90,7 +86,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2