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

Commit 3104214

Browse files
committed
simplify Go version upgrade procedure
1 parent 676e490 commit 3104214

File tree

7 files changed

+26
-10
lines changed

7 files changed

+26
-10
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,25 @@ 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@v2
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.17.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 2021, Go 1.17 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.16
24+
TARGET_VERSION='${{ matrix.cfg.go.versions[0] }}'
25+
TARGET_VERSION="${TARGET_VERSION%.x}"
2326
2427
# Note that the "<" comparison doesn't understand semver,
2528
# 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:
@@ -20,7 +25,7 @@ jobs:
2025
- uses: actions/checkout@v2
2126
- uses: actions/setup-go@v2
2227
with:
23-
go-version: "1.17.x"
28+
go-version: ${{ inputs.go-version }}
2429
- name: Determine version
2530
run: echo "VERSION=$(jq -r .version version.json)" >> $GITHUB_ENV
2631
- name: Check if this is the initial deployment

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.16.x", "1.17.x" ]
15+
}
1316
},
1417
"repositories": [
1518
{ "target": "filecoin-project/go-amt-ipld" },

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
submodules: recursive
1414
- uses: actions/setup-go@v2
1515
with:
16-
go-version: "1.17.x"
16+
go-version: "${{ go.versions[-1] }}"
1717
- name: Run repo-specific setup
1818
uses: ./.github/actions/go-check-setup
1919
if: hashFiles('./.github/actions/go-check-setup') != ''
@@ -68,4 +68,3 @@ jobs:
6868
git status --short
6969
exit 1
7070
fi
71-

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.16.x", "1.17.x" ]
10+
go: ${{ config.go.versions }}
1111
env:
1212
COVERAGES: ""
1313
runs-on: ${{ matrix.os }}-latest

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: ${{ go.versions[-1] }}

0 commit comments

Comments
 (0)