Skip to content

Commit dd03032

Browse files
committed
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.
1 parent bc437e4 commit dd03032

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

.github/workflows/check-go-dependencies-task.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md
22
name: Check Go Dependencies
33

4-
env:
5-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6-
GO_VERSION: "1.17"
7-
84
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -87,7 +83,7 @@ jobs:
8783
- name: Install Go
8884
uses: actions/setup-go@v5
8985
with:
90-
go-version: ${{ env.GO_VERSION }}
86+
go-version-file: go.mod
9187

9288
- name: Install Task
9389
uses: arduino/setup-task@v2
@@ -146,7 +142,7 @@ jobs:
146142
- name: Install Go
147143
uses: actions/setup-go@v5
148144
with:
149-
go-version: ${{ env.GO_VERSION }}
145+
go-version-file: go.mod
150146

151147
- name: Install Task
152148
uses: arduino/setup-task@v2

.github/workflows/check-go-task.yml

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-task.md
22
name: Check Go
33

4-
env:
5-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6-
GO_VERSION: "1.17"
7-
84
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -75,7 +71,7 @@ jobs:
7571
- name: Install Go
7672
uses: actions/setup-go@v5
7773
with:
78-
go-version: ${{ env.GO_VERSION }}
74+
go-version-file: ${{ matrix.module.path }}/go.mod
7975

8076
- name: Install Task
8177
uses: arduino/setup-task@v2
@@ -110,7 +106,7 @@ jobs:
110106
- name: Install Go
111107
uses: actions/setup-go@v5
112108
with:
113-
go-version: ${{ env.GO_VERSION }}
109+
go-version-file: ${{ matrix.module.path }}/go.mod
114110

115111
- name: Install Task
116112
uses: arduino/setup-task@v2
@@ -152,7 +148,7 @@ jobs:
152148
- name: Install Go
153149
uses: actions/setup-go@v5
154150
with:
155-
go-version: ${{ env.GO_VERSION }}
151+
go-version-file: ${{ matrix.module.path }}/go.mod
156152

157153
- name: Install Task
158154
uses: arduino/setup-task@v2
@@ -190,7 +186,7 @@ jobs:
190186
- name: Install Go
191187
uses: actions/setup-go@v5
192188
with:
193-
go-version: ${{ env.GO_VERSION }}
189+
go-version-file: ${{ matrix.module.path }}/go.mod
194190

195191
- name: Install Task
196192
uses: arduino/setup-task@v2
@@ -223,7 +219,7 @@ jobs:
223219

224220
matrix:
225221
module:
226-
- path: ./
222+
- path: .
227223

228224
steps:
229225
- name: Checkout repository
@@ -232,7 +228,7 @@ jobs:
232228
- name: Install Go
233229
uses: actions/setup-go@v5
234230
with:
235-
go-version: ${{ env.GO_VERSION }}
231+
go-version-file: ${{ matrix.module.path }}/go.mod
236232

237233
- name: Run go mod tidy
238234
working-directory: ${{ matrix.module.path }}

.github/workflows/release-go-crosscompile-task.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-go-crosscompile-task.md
22
name: Release
33

4+
on:
5+
push:
6+
tags:
7+
- "[0-9]+.[0-9]+.[0-9]+*"
8+
49
env:
510
# As defined by the Taskfile's PROJECT_NAME variable
611
PROJECT_NAME: arduinoOTA
@@ -9,13 +14,6 @@ env:
914
# The project's folder on Arduino's download server for uploading builds
1015
AWS_PLUGIN_TARGET: /arduinoOTA/
1116
ARTIFACT_PREFIX: dist-
12-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
13-
GO_VERSION: "1.17"
14-
15-
on:
16-
push:
17-
tags:
18-
- "[0-9]+.[0-9]+.[0-9]+*"
1917

2018
jobs:
2119
create-release-artifacts:
@@ -64,7 +62,7 @@ jobs:
6462
- name: Install Go
6563
uses: actions/setup-go@v5
6664
with:
67-
go-version: ${{ env.GO_VERSION }}
65+
go-version-file: go.mod
6866

6967
- name: Install Task
7068
uses: arduino/setup-task@v2

0 commit comments

Comments
 (0)