From ce85f15c4bfde04d9a3d7ac2b33cf75511048215 Mon Sep 17 00:00:00 2001 From: nadoo <287492+nadoo@users.noreply.github.com> Date: Tue, 14 Sep 2021 00:56:10 +0800 Subject: [PATCH] ci: use the latest go version --- .github/workflows/build.yml | 40 ++++++++++++++++------------------- .github/workflows/release.yml | 28 ------------------------ 2 files changed, 18 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd28e72..636497a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,35 +1,31 @@ name: Build -on: [push] +on: [push, pull_request] jobs: - - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: '1.17' - - name: Go Env - run: go env - - name: Test - run: go test -v . - build: name: Build runs-on: ubuntu-latest - needs: [test] steps: - name: Checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Get Go version + run: | + echo "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,})?"' | grep $(grep -P "go \d+\." go.mod | cut -d " " -f2) | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g')" >> $GITHUB_ENV - name: Set up Go uses: actions/setup-go@v2 with: - go-version: '1.17' - - name: Go Env - run: go env + go-version: ${{ env.GO_VERSION}} + - name: Test + run: go test -v . - name: Build - run: go build -v . \ No newline at end of file + run: go build -v . + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index c427818..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Release -on: - push: - tags: - - v* - -jobs: - release: - name: Release on GitHub - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: '1.17' - - name: Go Env - run: go env - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file