chore(ci): only release after CI on main passes #117
This file contains 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
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
name: CI | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
env: | |
GOPROXY: direct | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cashapp/activate-hermit@v1 | |
- run: | | |
find . -name go.mod | grep -v /testdata | xargs -n1 dirname | while read dir; do ( | |
cd "$dir" | |
go mod tidy | |
go test -v ./... | |
); done | |
git diff | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
env: | |
GOPROXY: direct | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cashapp/activate-hermit@v1 | |
- run: | | |
find . -name go.mod | grep -v /testdata | xargs -n1 dirname | while read dir; do ( | |
cd "$dir" | |
go mod tidy | |
golangci-lint run | |
); done | |
git diff | |
release: | |
if: github.ref == 'refs/heads/main' | |
needs: ["test", "lint"] | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: cashapp/activate-hermit@v1 | |
- uses: charlesthomas/github-action-svu@v1.0.5+2.1.1 | |
id: svu | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: | | |
git tag ${{ steps.svu.outputs.next }} | |
goreleaser release --fail-fast | |
git push --tags | |
if: ${{ steps.svu.outputs.changed == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |