From 5e8ebcb077c80a3a702704f5c4da6e31f53dcdc6 Mon Sep 17 00:00:00 2001 From: Jun Nishimura Date: Fri, 26 Apr 2024 00:22:19 +0900 Subject: [PATCH] add workflows (#1) --- .github/dependabot.yml | 13 +++++++++ .github/workflows/lint.yml | 21 +++++++++++++ .github/workflows/release.yml | 55 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 39 +++++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c9210e2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +version: 2 +updates: + - directory: / + package-ecosystem: "gomod" + schedule: + interval: "weekly" + day: "monday" + time: "10:00" + target-branch: "develop" + groups: + dev-dependencies: + patterns: + - "*" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..9dec05d --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,21 @@ +name: lint + +on: + push: + branches: + - '**' + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: 1.22 + - uses: actions/checkout@v3 + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3.4.0 + with: + version: latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..29d234a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: release cli to the GitHub Release + +on: + workflow_dispatch: + inputs: + method: + description: | + Which number to increment in the semantic versioning. + Set 'major', 'minor', or 'patch'. + required: true + +jobs: + release: + name: release + runs-on: ubuntu-latest + steps: + - name: check actor + if: github.actor != 'JunNishimura' + run: exit 1 + - name: check branch + if: github.ref != 'refs/heads/main' + run: exit 1 + - name: wait tests + id: test_result + uses: Sibz/await-status-action@v1.0.1 + with: + contexts: test-status + authToken: ${{ secrets.GITHUB_TOKEN }} + timeout: 30 + - name: check test result + if: steps.test_result.outputs.result != 'success' + run: | + echo "failed ${{ steps.test_result.outputs.failedCheckNames }}" + echo "failed ${{ steps.test_result.outputs.failedCheckStates }}" + exit 1 + - name: checkout sources + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: bump-up semantic version + uses: kyoh86/git-vertag-action@v1.1 + with: + method: "${{ github.event.inputs.method }}" + - name: setup Go + uses: actions/setup-go@v3 + with: + go-version-file: go.mod + cache: true + - name: run goreleaser + uses: goreleaser/goreleaser-action@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} + with: + args: release --rm-dist diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c22dedc --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +name: test + +on: + push: + branches: + - '**' + +jobs: + test: + name: test + strategy: + fail-fast: false + max-parallel: 3 + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: checkout + uses: actions/checkout@v2 + - name: setup Golang + uses: actions/setup-go@v2 + with: + go-version: 1.22 + - name: get dependencies + run: go get -v -t -d ./... + - name: test code + run: go test ./... + + test-status: + name: test status + runs-on: ubuntu-latest + needs: test + steps: + - name: set check status success + uses: Sibz/github-status-action@v1 + with: + context: test-status + authToken: ${{ secrets.GITHUB_TOKEN }} + state: success