Skip to content

Commit

Permalink
Use go.mod as source of Go version number for workflows
Browse files Browse the repository at this point in the history
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 appropriate 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.
  • Loading branch information
per1234 committed Feb 26, 2025
1 parent 5d56c66 commit 379ddb5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 33 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/check-go-dependencies-task.yml
Original file line number Diff line number Diff line change
@@ -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.23"

# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
on:
create:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 5 additions & 9 deletions .github/workflows/check-go-task.yml
Original file line number Diff line number Diff line change
@@ -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.23"

# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
on:
create:
Expand Down Expand Up @@ -75,7 +71,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
Expand Down Expand Up @@ -110,7 +106,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
Expand Down Expand Up @@ -148,7 +144,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
Expand Down Expand Up @@ -186,7 +182,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
Expand Down Expand Up @@ -224,7 +220,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
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/publish-go-tester-task.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md
name: Publish Tester Build

env:
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
GO_VERSION: "1.23"

# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
on:
create:
Expand Down Expand Up @@ -72,7 +68,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
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Create Release

env:
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
GO_VERSION: "1.23"

on:
push:
tags:
Expand Down Expand Up @@ -44,7 +40,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: go.mod

- name: Build project
run: task build
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test-go-integration-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
name: Test Integration

env:
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
GO_VERSION: "1.23"
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
PYTHON_VERSION: "3.9"

Expand Down Expand Up @@ -88,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 Python
uses: actions/setup-python@v5
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test-go-task.yml
Original file line number Diff line number Diff line change
@@ -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.23"

# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
on:
create:
Expand Down Expand Up @@ -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 Arduino Lint
run: |
Expand Down

0 comments on commit 379ddb5

Please # to comment.