From 791641bb2d0ab93955b218b9bc6f5335b8ead243 Mon Sep 17 00:00:00 2001 From: Eno Compton Date: Thu, 17 Mar 2022 10:29:05 -0600 Subject: [PATCH] feat: drop support for Go 1.15 (#145) And add support for Go 1.18. --- .github/update_go.sh | 37 ++++++++++++++++++++++++++++++++++++ .github/workflows/cover.yaml | 2 +- .github/workflows/lint.yaml | 4 ++-- .github/workflows/tests.yaml | 2 +- 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100755 .github/update_go.sh diff --git a/.github/update_go.sh b/.github/update_go.sh new file mode 100755 index 00000000..8085c19d --- /dev/null +++ b/.github/update_go.sh @@ -0,0 +1,37 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# update_go.sh updates all GitHub Action workflows to use the provided Go +# version. + +usage() { + echo "Missing Go version." + echo "usage: .github/update_go.sh " + echo " Example:" + echo " .github/update_go.sh 1.18" +} + +if [ -z "$1" ] + then + usage +fi + +# Replace all usages of "go-version: x.xx" with the provided version. +grep -lr "go-version: \"" .github/workflows | xargs \ + sed -i "s/go-version: \".*\"/go-version: \"$1\"/g" + +# Replace the matrix of Go versions with the last two versions and the provided +# version. +grep -lr "go-version: \[" .github | xargs \ + sed -i "s/\[\(.*\), \(.*\), \(.*\)\]/\[\2, \3, $1\]/" diff --git a/.github/workflows/cover.yaml b/.github/workflows/cover.yaml index b319a8b5..22e7687a 100644 --- a/.github/workflows/cover.yaml +++ b/.github/workflows/cover.yaml @@ -22,7 +22,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: "1.17" + go-version: "1.18" - name: Checkout base branch uses: actions/checkout@v3 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4ad8b5e5..7ab4c78d 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -23,9 +23,9 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: "1.17" + go-version: "1.18" - name: Install goimports - run: go get golang.org/x/tools/cmd/goimports + run: go install golang.org/x/tools/cmd/goimports@latest - name: Checkout code uses: actions/checkout@v3 - run: goimports -w . diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5d297b3c..b25ae87f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [1.15, 1.16, 1.17] + go-version: [1.16, 1.17, 1.18] steps: - name: Setup Go ${{ matrix.go-version }} uses: actions/setup-go@v3