chore(ci): 替换 GitHub Release Action 工具以增强功能 #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: [ 'v*' ] | |
| env: | |
| GO_VERSION: '1.24.3' | |
| GOLANGCI_LINT_VERSION: 'v2.2.2' | |
| jobs: | |
| build-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Install dependencies | |
| run: | | |
| go mod tidy | |
| go get github.com/stretchr/testify | |
| - name: Install golangci-lint | |
| run: | | |
| curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${{ env.GOLANGCI_LINT_VERSION }} | |
| - name: Lint | |
| run: make lint | |
| - name: Code format | |
| run: | | |
| if [ -f style.sh ]; then bash style.sh; fi | |
| - name: Build (local) | |
| run: make build-local | |
| - name: Test | |
| run: make test | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build-test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| - name: Install dependencies | |
| run: | | |
| go mod tidy | |
| go get github.com/stretchr/testify | |
| - name: Install golangci-lint | |
| run: | | |
| curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${{ env.GOLANGCI_LINT_VERSION }} | |
| - name: Lint | |
| run: make lint | |
| - name: Code format | |
| run: | | |
| if [ -f style.sh ]; then bash style.sh; fi | |
| - name: Build binaries (multi-platform) | |
| run: make build-binaries | |
| - name: Package binaries | |
| run: make package-binaries | |
| - name: Create GitHub Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: dist/* | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| tag: ${{ github.ref_name }} | |
| name: Release ${{ github.ref_name }} | |
| prerelease: false |