Skip to content

Commit 3c57c00

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 0ebd1de commit 3c57c00

File tree

5 files changed

+10
-28
lines changed

5 files changed

+10
-28
lines changed

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

Lines changed: 2 additions & 6 deletions
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/using-workflows/events-that-trigger-workflows
95
on:
106
create:
@@ -84,7 +80,7 @@ jobs:
8480
- name: Install Go
8581
uses: actions/setup-go@v5
8682
with:
87-
go-version: ${{ env.GO_VERSION }}
83+
go-version-file: go.mod
8884

8985
- name: Install Task
9086
uses: arduino/setup-task@v2
@@ -141,7 +137,7 @@ jobs:
141137
- name: Install Go
142138
uses: actions/setup-go@v5
143139
with:
144-
go-version: ${{ env.GO_VERSION }}
140+
go-version-file: go.mod
145141

146142
- name: Install Task
147143
uses: arduino/setup-task@v2

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

Lines changed: 5 additions & 9 deletions
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/en/actions/reference/events-that-trigger-workflows
95
on:
106
push:
@@ -46,7 +42,7 @@ jobs:
4642
- name: Install Go
4743
uses: actions/setup-go@v5
4844
with:
49-
go-version: ${{ env.GO_VERSION }}
45+
go-version-file: ${{ matrix.module.path }}/go.mod
5046

5147
- name: Install Task
5248
uses: arduino/setup-task@v2
@@ -77,7 +73,7 @@ jobs:
7773
- name: Install Go
7874
uses: actions/setup-go@v5
7975
with:
80-
go-version: ${{ env.GO_VERSION }}
76+
go-version-file: ${{ matrix.module.path }}/go.mod
8177

8278
- name: Install Task
8379
uses: arduino/setup-task@v2
@@ -111,7 +107,7 @@ jobs:
111107
- name: Install Go
112108
uses: actions/setup-go@v5
113109
with:
114-
go-version: ${{ env.GO_VERSION }}
110+
go-version-file: ${{ matrix.module.path }}/go.mod
115111

116112
- name: Install Task
117113
uses: arduino/setup-task@v2
@@ -145,7 +141,7 @@ jobs:
145141
- name: Install Go
146142
uses: actions/setup-go@v5
147143
with:
148-
go-version: ${{ env.GO_VERSION }}
144+
go-version-file: ${{ matrix.module.path }}/go.mod
149145

150146
- name: Install Task
151147
uses: arduino/setup-task@v2
@@ -179,7 +175,7 @@ jobs:
179175
- name: Install Go
180176
uses: actions/setup-go@v5
181177
with:
182-
go-version: ${{ env.GO_VERSION }}
178+
go-version-file: ${{ matrix.module.path }}/go.mod
183179

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

.github/workflows/release.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Create Release
22

3-
env:
4-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
5-
GO_VERSION: "1.17"
6-
73
on:
84
push:
95
tags:
@@ -33,7 +29,7 @@ jobs:
3329
- name: Install Go
3430
uses: actions/setup-go@v5
3531
with:
36-
go-version: ${{ env.GO_VERSION }}
32+
go-version-file: go.mod
3733

3834
- name: Build project
3935
run: task go:build

.github/workflows/test-go-integration-task.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
name: Test Integration
33

44
env:
5-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6-
GO_VERSION: "1.17"
75
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
86
PYTHON_VERSION: "3.9"
97

@@ -43,7 +41,7 @@ jobs:
4341
- name: Install Go
4442
uses: actions/setup-go@v5
4543
with:
46-
go-version: ${{ env.GO_VERSION }}
44+
go-version-file: go.mod
4745

4846
- name: Install Python
4947
uses: actions/setup-python@v5

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

Lines changed: 1 addition & 5 deletions
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/test-go-task.md
22
name: Test 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/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
95
on:
106
push:
@@ -51,7 +47,7 @@ jobs:
5147
- name: Install Go
5248
uses: actions/setup-go@v5
5349
with:
54-
go-version: ${{ env.GO_VERSION }}
50+
go-version-file: go.mod
5551

5652
- name: Install Task
5753
uses: arduino/setup-task@v2

0 commit comments

Comments
 (0)