Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 2117cef

Browse files
simplify Go version upgrade procedure (#280)
* chore: simplify Go version upgrade procedure * chore: add default for the go-version input of release-check * Update .github/actions/copy-workflow-go/action.yml * Update configs/README.md Co-authored-by: Laurent Senta <[email protected]> --------- Co-authored-by: Laurent Senta <[email protected]>
1 parent 4b2bfa6 commit 2117cef

File tree

7 files changed

+39
-10
lines changed

7 files changed

+39
-10
lines changed

.github/actions/copy-workflow-go/action.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,32 @@ description: Copy workflow steps specific to go
44
runs:
55
using: "composite"
66
steps:
7+
# GitHub Actions Expressions do not support last item access/array length retrieval
8+
- id: go
9+
run: echo "::set-output name=version::$(jq -r '.[-1]' <<< '${{ toJSON(matrix.cfg.go.versions) }}')"
10+
shell: bash
711
- uses: actions/setup-go@v3
812
with:
913
# This should be the same Go version we use in the go-check workflow.
1014
# go mod tidy, go vet, staticcheck and gofmt might behave differently depending on the version.
11-
go-version: "1.19.x"
15+
go-version: ${{ steps.go.outputs.version }}
1216
- name: bump go.mod go version if needed
1317
uses: protocol/[email protected]
1418
with:
1519
working-directory: ${{ env.TARGET_REPO_DIR }}
1620
run: |
1721
# We want our modules to support two Go versions at a time.
18-
# As of August 2022, Go 1.19 is the latest stable.
1922
# go.mod's Go version declares the language version being used.
2023
# As such, it has to be the minimum of all Go versions supported.
21-
# Bump this every six months, as new Go versions come out.
22-
TARGET_VERSION=1.18
23-
PREVIOUS_TARGET_VERSION=1.17
24+
TARGET_VERSION='${{ matrix.cfg.go.versions[0] }}'
25+
TARGET_VERSION="${TARGET_VERSION%.x}"
26+
TARGET_MAJOR_VERSION="${TARGET_VERSION%.[0-9]*}"
27+
TARGET_MINOR_VERSION="${TARGET_VERSION#[0-9]*.}"
28+
# Assumptions:
29+
# - all versions are targetted incrementally
30+
# - no versions are skipped
31+
# - patch version is never pinned explicitly
32+
PREVIOUS_TARGET_VERSION="$TARGET_MAJOR_VERSION.$(($TARGET_MINOR_VERSION-1))"
2433
2534
# Note that the "<" comparison doesn't understand semver,
2635
# but it should be good enough for the foreseeable future.

.github/workflows/release-check.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: Release Checker
2-
on: [ workflow_call ]
2+
on:
3+
workflow_call:
4+
inputs:
5+
go-version:
6+
required: true
7+
type: string
8+
default: 1.19.x # TODO: remove once release-check is upgraded in all the targets
39

410
jobs:
511
releaser:
@@ -10,7 +16,7 @@ jobs:
1016
- uses: actions/checkout@v3
1117
- uses: actions/setup-go@v3
1218
with:
13-
go-version: "1.19.x"
19+
go-version: ${{ inputs.go-version }}
1420
- id: version
1521
name: Determine version
1622
env:

configs/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,12 @@ To customise the copy workflow further, you can add more fields to the `defaults
3838
## Testing
3939

4040
You can use [testing](https://github.com/protocol/.github/tree/testing) branch for worklow/configuration testing. Once you push your changes to the branch, a [dispatch](../.github/workflows/dispatch.yml) workflow will be triggered. The workflow will use [testing.json](testing.json) configuration file only. You can manipalate that configuration file as needed(you can copy all the `defaults` from [go.json](go.json) for [example](https://github.com/protocol/.github/commit/43476995428996a90ca95bf838f084ba1a710c68)).
41+
42+
## Upgrading Go
43+
44+
To upgrade Go, modify the `defaults.go.versions` array in the [Go config](go.json).
45+
46+
Remember to:
47+
- Keep the array sorted in increasing order,
48+
- Upgrade versions incrementally. Do not skip a version,
49+
- never pin the patch version (`"1.19.x"` is correct, `"1.19.8"` is incorrect).

configs/go.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
".github/workflows/tagpush.yml"
1010
],
1111
"deploy_versioning": true,
12-
"deploy_go": true
12+
"deploy_go": true,
13+
"go": {
14+
"versions": [ "1.18.x", "1.19.x" ]
15+
}
1316
},
1417
"repositories": [
1518
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
uses: protocol/.github/.github/actions/read-config@next
1414
- uses: actions/setup-go@v3
1515
with:
16-
go-version: "1.19.x"
16+
go-version: ${{{ config.go.versions[-1] }}}
1717
- name: Run repo-specific setup
1818
uses: ./.github/actions/go-check-setup
1919
if: hashFiles('./.github/actions/go-check-setup') != ''

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
fail-fast: false
88
matrix:
99
os: [ "ubuntu", "windows", "macos" ]
10-
go: [ "1.18.x", "1.19.x" ]
10+
go: ${{{ config.go.versions }}}
1111
env:
1212
COVERAGES: ""
1313
runs-on: ${{ fromJSON(vars[format('UCI_GO_TEST_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }}

templates/.github/workflows/release-check.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ on:
66
jobs:
77
release-check:
88
uses: protocol/.github/.github/workflows/release-check.yml@master
9+
with:
10+
go-version: ${{{ config.go.versions[-1] }}}

0 commit comments

Comments
 (0)