diff --git a/.github/actions/copy-workflow-go/action.yml b/.github/actions/copy-workflow-go/action.yml index 50b2f282..3b5b4075 100644 --- a/.github/actions/copy-workflow-go/action.yml +++ b/.github/actions/copy-workflow-go/action.yml @@ -4,23 +4,32 @@ description: Copy workflow steps specific to go runs: using: "composite" steps: + # GitHub Actions Expressions do not support last item access/array length retrieval + - id: go + run: echo "::set-output name=version::$(jq -r '.[-1]' <<< '${{ toJSON(matrix.cfg.go.versions) }}')" + shell: bash - uses: actions/setup-go@v3 with: # This should be the same Go version we use in the go-check workflow. # go mod tidy, go vet, staticcheck and gofmt might behave differently depending on the version. - go-version: "1.19.x" + go-version: ${{ steps.go.outputs.version }} - name: bump go.mod go version if needed uses: protocol/multiple-go-modules@v1.2 with: working-directory: ${{ env.TARGET_REPO_DIR }} run: | # We want our modules to support two Go versions at a time. - # As of August 2022, Go 1.19 is the latest stable. # go.mod's Go version declares the language version being used. # As such, it has to be the minimum of all Go versions supported. - # Bump this every six months, as new Go versions come out. - TARGET_VERSION=1.18 - PREVIOUS_TARGET_VERSION=1.17 + TARGET_VERSION='${{ matrix.cfg.go.versions[0] }}' + TARGET_VERSION="${TARGET_VERSION%.x}" + TARGET_MAJOR_VERSION="${TARGET_VERSION%.[0-9]*}" + TARGET_MINOR_VERSION="${TARGET_VERSION#[0-9]*.}" + # Assumptions: + # - all versions are targetted incrementally + # - no versions are skipped + # - patch version is never pinned explicitly + PREVIOUS_TARGET_VERSION="$TARGET_MAJOR_VERSION.$(($TARGET_MINOR_VERSION-1))" # Note that the "<" comparison doesn't understand semver, # but it should be good enough for the foreseeable future. diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml index d1420659..2a8e7941 100644 --- a/.github/workflows/release-check.yml +++ b/.github/workflows/release-check.yml @@ -1,5 +1,11 @@ name: Release Checker -on: [ workflow_call ] +on: + workflow_call: + inputs: + go-version: + required: true + type: string + default: 1.19.x # TODO: remove once release-check is upgraded in all the targets jobs: releaser: @@ -10,7 +16,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: "1.19.x" + go-version: ${{ inputs.go-version }} - id: version name: Determine version env: diff --git a/configs/README.md b/configs/README.md index 1c6a2775..ba569665 100644 --- a/configs/README.md +++ b/configs/README.md @@ -38,3 +38,12 @@ To customise the copy workflow further, you can add more fields to the `defaults ## Testing 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)). + +## Upgrading Go + +To upgrade Go, modify the `defaults.go.versions` array in the [Go config](go.json). + +Remember to: +- Keep the array sorted in increasing order, +- Upgrade versions incrementally. Do not skip a version, +- never pin the patch version (`"1.19.x"` is correct, `"1.19.8"` is incorrect). diff --git a/configs/go.json b/configs/go.json index 39994638..6fdd6968 100644 --- a/configs/go.json +++ b/configs/go.json @@ -9,7 +9,10 @@ ".github/workflows/tagpush.yml" ], "deploy_versioning": true, - "deploy_go": true + "deploy_go": true, + "go": { + "versions": [ "1.18.x", "1.19.x" ] + } }, "repositories": [ { diff --git a/templates/.github/workflows/go-check.yml b/templates/.github/workflows/go-check.yml index f9c8352c..3f52a160 100644 --- a/templates/.github/workflows/go-check.yml +++ b/templates/.github/workflows/go-check.yml @@ -13,7 +13,7 @@ jobs: uses: protocol/.github/.github/actions/read-config@next - uses: actions/setup-go@v3 with: - go-version: "1.19.x" + go-version: ${{{ config.go.versions[-1] }}} - name: Run repo-specific setup uses: ./.github/actions/go-check-setup if: hashFiles('./.github/actions/go-check-setup') != '' diff --git a/templates/.github/workflows/go-test.yml b/templates/.github/workflows/go-test.yml index 0f26e3ec..637a76aa 100644 --- a/templates/.github/workflows/go-test.yml +++ b/templates/.github/workflows/go-test.yml @@ -7,7 +7,7 @@ jobs: fail-fast: false matrix: os: [ "ubuntu", "windows", "macos" ] - go: [ "1.18.x", "1.19.x" ] + go: ${{{ config.go.versions }}} env: COVERAGES: "" runs-on: ${{ fromJSON(vars[format('UCI_GO_TEST_RUNNER_{0}', matrix.os)] || format('"{0}-latest"', matrix.os)) }} diff --git a/templates/.github/workflows/release-check.yml b/templates/.github/workflows/release-check.yml index fd823694..036e96ad 100644 --- a/templates/.github/workflows/release-check.yml +++ b/templates/.github/workflows/release-check.yml @@ -6,3 +6,5 @@ on: jobs: release-check: uses: protocol/.github/.github/workflows/release-check.yml@master + with: + go-version: ${{{ config.go.versions[-1] }}}