Skip to content

Commit 6234d67

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 26d0f72 commit 6234d67

File tree

6 files changed

+10
-28
lines changed

6 files changed

+10
-28
lines changed

workflow-templates/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/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

workflow-templates/check-go-task.yml

Lines changed: 4 additions & 8 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/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -78,7 +74,7 @@ jobs:
7874
- name: Install Go
7975
uses: actions/setup-go@v5
8076
with:
81-
go-version: ${{ env.GO_VERSION }}
77+
go-version-file: ${{ matrix.module.path }}/go.mod
8278

8379
- name: Install Task
8480
uses: arduino/setup-task@v2
@@ -117,7 +113,7 @@ jobs:
117113
- name: Install Go
118114
uses: actions/setup-go@v5
119115
with:
120-
go-version: ${{ env.GO_VERSION }}
116+
go-version-file: ${{ matrix.module.path }}/go.mod
121117

122118
- name: Install Task
123119
uses: arduino/setup-task@v2
@@ -158,7 +154,7 @@ jobs:
158154
- name: Install Go
159155
uses: actions/setup-go@v5
160156
with:
161-
go-version: ${{ env.GO_VERSION }}
157+
go-version-file: ${{ matrix.module.path }}/go.mod
162158

163159
- name: Install Task
164160
uses: arduino/setup-task@v2
@@ -197,7 +193,7 @@ jobs:
197193
- name: Install Go
198194
uses: actions/setup-go@v5
199195
with:
200-
go-version: ${{ env.GO_VERSION }}
196+
go-version-file: ${{ matrix.module.path }}/go.mod
201197

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

workflow-templates/deploy-cobra-mkdocs-versioned-poetry.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
name: Deploy Website
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

@@ -67,7 +65,7 @@ jobs:
6765
- name: Install Go
6866
uses: actions/setup-go@v5
6967
with:
70-
go-version: ${{ env.GO_VERSION }}
68+
go-version-file: go.mod
7169

7270
- name: Install Python
7371
uses: actions/setup-python@v5

workflow-templates/release-go-crosscompile-task.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ env:
1010
AWS_PLUGIN_TARGET: TODO_AWS_PLUGIN_TARGET
1111
AWS_REGION: "us-east-1"
1212
ARTIFACT_PREFIX: dist-
13-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
14-
GO_VERSION: "1.17"
1513

1614
on:
1715
push:
@@ -65,7 +63,7 @@ jobs:
6563
- name: Install Go
6664
uses: actions/setup-go@v5
6765
with:
68-
go-version: ${{ env.GO_VERSION }}
66+
go-version-file: go.mod
6967

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

workflow-templates/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

@@ -83,7 +81,7 @@ jobs:
8381
- name: Install Go
8482
uses: actions/setup-go@v5
8583
with:
86-
go-version: ${{ env.GO_VERSION }}
84+
go-version-file: go.mod
8785

8886
- name: Install Python
8987
uses: actions/setup-python@v5

workflow-templates/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/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -90,7 +86,7 @@ jobs:
9086
- name: Install Go
9187
uses: actions/setup-go@v5
9288
with:
93-
go-version: ${{ env.GO_VERSION }}
89+
go-version-file: go.mod
9490

9591
- name: Install Task
9692
uses: arduino/setup-task@v2

0 commit comments

Comments
 (0)