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

Commit 8ea1e74

Browse files
committed
chore: simplify Go version upgrade procedure
1 parent fabec7e commit 8ea1e74

File tree

7 files changed

+29
-10
lines changed

7 files changed

+29
-10
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,28 @@ 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+
PREVIOUS_TARGET_VERSION="$TARGET_MAJOR_VERSION.$(($TARGET_MINOR_VERSION-1))"
2429
2530
# Note that the "<" comparison doesn't understand semver,
2631
# but it should be good enough for the foreseeable future.

.github/workflows/release-check.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
# See https://github.com/protocol/.github/issues/254 for details.
44

55
name: Release Checker
6-
on: [ workflow_call ]
6+
on:
7+
workflow_call:
8+
inputs:
9+
go-version:
10+
required: true
11+
type: string
712

813
jobs:
914
releaser:
@@ -14,7 +19,7 @@ jobs:
1419
- uses: actions/checkout@v3
1520
- uses: actions/setup-go@v3
1621
with:
17-
go-version: "1.19.x"
22+
go-version: ${{ inputs.go-version }}
1823
- id: version
1924
name: Determine version
2025
if: hashFiles('version.json')

configs/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ 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). Keep the array sorted in an increasing order.

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
submodules: recursive
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
SKIP32BIT: false

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)