From dd030320f8b0c96464696667f21c0174300e9f96 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sat, 15 Mar 2025 13:12:19 -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. --- .github/workflows/check-go-dependencies-task.yml | 8 ++------ .github/workflows/check-go-task.yml | 16 ++++++---------- .../workflows/release-go-crosscompile-task.yml | 14 ++++++-------- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.github/workflows/check-go-dependencies-task.yml b/.github/workflows/check-go-dependencies-task.yml index 002404e..7a2878a 100644 --- a/.github/workflows/check-go-dependencies-task.yml +++ b/.github/workflows/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/.github/workflows/check-go-task.yml b/.github/workflows/check-go-task.yml index d369a64..1e98b5f 100644 --- a/.github/workflows/check-go-task.yml +++ b/.github/workflows/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: @@ -75,7 +71,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 @@ -110,7 +106,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 @@ -152,7 +148,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 @@ -190,7 +186,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 @@ -223,7 +219,7 @@ jobs: matrix: module: - - path: ./ + - path: . steps: - name: Checkout repository @@ -232,7 +228,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/.github/workflows/release-go-crosscompile-task.yml b/.github/workflows/release-go-crosscompile-task.yml index c355b5c..f0f4f8f 100644 --- a/.github/workflows/release-go-crosscompile-task.yml +++ b/.github/workflows/release-go-crosscompile-task.yml @@ -1,6 +1,11 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-go-crosscompile-task.md name: Release +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+*" + env: # As defined by the Taskfile's PROJECT_NAME variable PROJECT_NAME: arduinoOTA @@ -9,13 +14,6 @@ env: # The project's folder on Arduino's download server for uploading builds AWS_PLUGIN_TARGET: /arduinoOTA/ ARTIFACT_PREFIX: dist- - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.17" - -on: - push: - tags: - - "[0-9]+.[0-9]+.[0-9]+*" jobs: create-release-artifacts: @@ -64,7 +62,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