From 24928b7fd66e74a9cdc684c93b9e975d6f2045d3 Mon Sep 17 00:00:00 2001 From: liweiyi88 Date: Sun, 29 Jan 2023 21:05:49 +1100 Subject: [PATCH] update workflow dir --- .github/workflows/release.yaml | 33 +++++++++++++++++++++++ .github/workflows/tests.yaml | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..69ee227 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,33 @@ +name: goreleaser + +on: + push: + tags: + - '*' + +permissions: + contents: write + packages: write + issues: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: docker/setup-qemu-action@v1 + - uses: docker/setup-buildx-action@v1 + - run: git fetch --force --tags + - uses: actions/setup-go@v3 + with: + go-version: '>=1.19.5' + cache: true + - uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..8c1eb86 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,48 @@ +name: tests +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + + workflow_dispatch: +jobs: + test: + strategy: + matrix: + go-version: [1.18, 1.19] + os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + - uses: actions/checkout@v3 + - run: | + go test -v -cover ./... -coverprofile coverage.out -coverpkg ./... + - name: Go Coverage Badge + uses: tj-actions/coverage-badge-go@v1 + if: ${{ runner.os == 'ubuntu-latest' && matrix.go == '1.19' }} + with: + green: 80 + filename: coverage.out + + - uses: stefanzweifel/git-auto-commit-action@v4 + id: auto-commit-action + with: + commit_message: Apply Code Coverage Badge + skip_fetch: true + skip_checkout: true + file_pattern: ./README.md + + - name: Push Changes + if: steps.auto-commit-action.outputs.changes_detected == 'true' + uses: ad-m/github-push-action@master + with: + github_token: ${{ github.token }} + branch: ${{ github.ref }} + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + files: ./coverage.out \ No newline at end of file