From 681ec0061f3be5a1116de87d6235aec36c922712 Mon Sep 17 00:00:00 2001 From: iTanken <23544702+iTanken@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:13:27 +0800 Subject: [PATCH] Update releaser.yml --- .github/workflows/releaser.yml | 66 +++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml index 1ebe4af..e0a9df8 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -5,39 +5,47 @@ on: tags: - "v*" +permissions: + contents: write + jobs: goreleaser: strategy: matrix: - go-version: [1.20.x] + go-version: [1.x] os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Cache-Go - uses: actions/cache@v4 - with: - path: | - ~/go/pkg/mod # Module download cache - ~/.cache/go-build # Build cache (Linux) - ~/Library/Caches/go-build # Build cache (Mac) - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - - name: Test - run: go test ./... - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 - with: - distribution: goreleaser - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + + - name: Cache-Go + uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod # Module download cache + ~/.cache/go-build # Build cache (Linux) + ~/Library/Caches/go-build # Build cache (Mac) + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + + - name: Test + run: go test ./... + + - name: Get Tag Name + id: tag + run: echo "tagName=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + generateReleaseNotes: true + token: ${{ secrets.GITHUB_TOKEN }}