From c34c5ff1f922f3f736dfdcf3a77f22714b6fa4e1 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Wed, 2 Nov 2022 22:13:54 +0800 Subject: [PATCH] build: fix golang build cache --- .github/workflows/build.yaml | 12 +++++++----- .github/workflows/prerelease.yml | 21 +++++---------------- .github/workflows/release.yaml | 22 +++++++--------------- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 87202e69..3e9d3d93 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -5,12 +5,14 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Set up Go - uses: actions/setup-go@v1 + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3 with: - go-version: 1.18 - - name: Check out code - uses: actions/checkout@v1 + go-version: '1.19' + check-latest: true + cache: true - name: Build run: make all - name: Release diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index daaba026..afd49cff 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -12,26 +12,15 @@ jobs: Build: runs-on: ubuntu-latest steps: - - name: Get latest go version - id: version - run: | - echo ::set-output name=go_version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: ${{ steps.version.outputs.go_version }} - - name: Check out code into the Go module directory uses: actions/checkout@v3 - - name: Cache go module - uses: actions/cache@v2 + - name: Setup Go + uses: actions/setup-go@v3 with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- - + go-version: '1.19' + check-latest: true + cache: true - name: Test if: ${{github.ref_name=='Beta'}} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4b2b60da..c74637a6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -7,24 +7,16 @@ jobs: Build: runs-on: ubuntu-latest steps: - - name: Get latest go version - id: version - run: | - echo ::set-output name=go_version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: ${{ steps.version.outputs.go_version }} - - name: Check out code into the Go module directory uses: actions/checkout@v3 - - name: Cache go module - uses: actions/cache@v2 + + - name: Setup Go + uses: actions/setup-go@v3 with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + go-version: '1.19' + check-latest: true + cache: true + - name: Test run: | go test ./...