From 9304bfe674fd3e466da634001047af5255f464df Mon Sep 17 00:00:00 2001 From: Kemal Hadimli Date: Tue, 14 Feb 2023 14:36:42 +0000 Subject: [PATCH] feat: Add .github workflow for release/test --- .github/workflows/release.yaml | 39 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..92903c6 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,39 @@ +name: release +on: + push: + tags: + - "v*.*.*" +env: + CGO_ENABLED: 0 + +jobs: + release-binary: + runs-on: ubuntu-latest + steps: + # This fails for invalid semver strings + - name: Parse semver string + id: semver_parser + uses: booxmedialtd/ws-action-parse-semver@966a26512c94239a00aa10b1b0c196906f7e1909 + with: + input_string: ${{github.ref_name}} + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Go 1.x + uses: actions/setup-go@v3 + with: + go-version-file: go.mod + cache: true + - name: Run GoReleaser Dry-Run + uses: goreleaser/goreleaser-action@v3 + with: + version: latest + args: release --rm-dist --skip-validate --skip-publish --skip-sign + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v3 + with: + version: latest + args: release --rm-dist --skip-sign + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..f0a9a19 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,38 @@ +name: test + +on: + push: + branches: + - main + pull_request: + branches: [main] + +jobs: + test: + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Set up Go 1.x + uses: actions/setup-go@v3 + with: + go-version-file: go.mod + cache: true + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.50.1 + - name: Get dependencies + run: go get -t -d ./... + - name: Build + run: go build . + - name: Test + run: make test + - name: gen + if: github.event_name == 'pull_request' + run: make gen + - name: Fail if generation updated files + if: github.event_name == 'pull_request' + run: test "$(git status -s | wc -l)" -eq 0 || (git status -s; exit 1)