ci: 并入 npm 自动发布(NPM_TOKEN 认证) #4
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: test | |
| on: | |
| push: | |
| branches: [master, main] | |
| pull_request: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| # 从 go.mod 读取版本,避免与 go 指令漂移。 | |
| go-version-file: go.mod | |
| cache: true | |
| - name: gofmt check | |
| run: | | |
| if [ -n "$(gofmt -l .)" ]; then | |
| echo "These files need gofmt:" | |
| gofmt -l . | |
| exit 1 | |
| fi | |
| - name: go vet | |
| run: go vet ./... | |
| - name: go test | |
| run: go test -race ./... |