diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml new file mode 100644 index 0000000..6718f11 --- /dev/null +++ b/.github/actions/release/action.yml @@ -0,0 +1,22 @@ +name: release +description: release gotesplit +inputs: + tag: + description: tag name to be released + default: '' + token: + description: GitHub token + required: true +runs: + using: composite + steps: + - name: setup go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + - name: release + run: | + make crossbuild upload + shell: bash + env: + GITHUB_TOKEN: ${{ inputs.token }} diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..b0c5175 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,4 @@ +changelog: + exclude: + labels: + - tagpr diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 75a62f2..084f9b1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -7,16 +7,8 @@ jobs: release: runs-on: ubuntu-latest steps: - - name: setup go - uses: actions/setup-go@v3 - with: - go-version: 1.x - name: checkout uses: actions/checkout@v3 + - uses: ./.github/actions/release with: - fetch-depth: 0 - - name: release - env: - GITHUB_TOKEN: ${{ secrets.github_token }} - run: | - make crossbuild upload + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/reviewdog.yaml b/.github/workflows/reviewdog.yaml new file mode 100644 index 0000000..67b90ea --- /dev/null +++ b/.github/workflows/reviewdog.yaml @@ -0,0 +1,42 @@ +name: reviewdog +on: [pull_request] + +jobs: + staticcheck: + name: staticcheck + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + with: + persist-credentials: false + - name: staticcheck + uses: reviewdog/action-staticcheck@v1 + with: + reporter: github-pr-review + level: warning + + misspell: + name: misspell + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + with: + persist-credentials: false + - name: misspell + uses: reviewdog/action-misspell@v1 + with: + reporter: github-pr-review + level: warning + locale: "US" + + actionlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: reviewdog/action-actionlint@v1 + with: + reporter: github-pr-review diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml deleted file mode 100644 index ee8cfe7..0000000 --- a/.github/workflows/reviewdog.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: reviewdog -on: [pull_request] -jobs: - staticcheck: - name: staticcheck - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: reviewdog/action-staticcheck@v1 - with: - github_token: ${{ secrets.github_token }} - reporter: github-pr-review - fail_on_error: true diff --git a/.github/workflows/tagpr.yaml b/.github/workflows/tagpr.yaml new file mode 100644 index 0000000..6334d4f --- /dev/null +++ b/.github/workflows/tagpr.yaml @@ -0,0 +1,25 @@ +name: tagpr +on: + push: + branches: + - "main" +jobs: + tagpr: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v3 + - name: setup go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + - name: tagpr + id: tagpr + uses: Songmu/tagpr@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: ./.github/actions/release + with: + tag: ${{ steps.tagpr.outputs.tag }} + token: ${{ secrets.GITHUB_TOKEN }} + if: "steps.tagpr.outputs.tag != ''" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 346ea01..472dce9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -3,7 +3,6 @@ on: push: branches: - "**" - pull_request: {} jobs: test: runs-on: ${{ matrix.os }} @@ -15,18 +14,15 @@ jobs: - macOS-latest - windows-latest steps: + - name: checkout + uses: actions/checkout@v3 - name: setup go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.x - - name: Set git to use LF - run: | - git config --global core.autocrlf false - git config --global core.eol lf - if: "matrix.os == 'windows-latest'" - - name: checkout - uses: actions/checkout@v2 + go-version-file: go.mod - name: test run: go test -race -coverprofile coverage.out -covermode atomic - - name: Upload coverage to Codecov + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + - name: Send coverage uses: codecov/codecov-action@v1 diff --git a/.gitignore b/.gitignore index dc9e330..854dd52 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .* !.gitignore !.github +!.tagpr dist diff --git a/.tagpr b/.tagpr new file mode 100644 index 0000000..b081bce --- /dev/null +++ b/.tagpr @@ -0,0 +1,5 @@ +[tagpr] + vPrefix = true + releaseBranch = main + versionFile = version.go + release = draft diff --git a/Makefile b/Makefile index 75dc17a..073254b 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,8 @@ release: devel-deps CREDITS: deps devel-deps godzil credits -w -DIST_DIR = dist/v$(VERSION) -.PHONY: crossbuild +DIST_DIR = dist +.PHONY: go.sum crossbuild crossbuild: CREDITS rm -rf $(DIST_DIR) env CGO_ENABLED=0 godzil crossbuild -pv=v$(VERSION) -build-ldflags=$(BUILD_LDFLAGS) \ @@ -42,4 +42,4 @@ crossbuild: CREDITS .PHONY: upload upload: - ghr -body="$$(godzil changelog --latest -F markdown)" v$(VERSION) dist/v$(VERSION) + ghr v$(VERSION) $(DIST_DIR) diff --git a/README.md b/README.md index 98a62ca..f5c6a3e 100644 --- a/README.md +++ b/README.md @@ -90,8 +90,8 @@ jobs: parallelism: [3] index: [0,1,2] steps: - - uses: actions/setup-go@v2 - - uses: actions/checkout@v2 + - uses: actions/setup-go@v4 + - uses: actions/checkout@v3 - name: Run tests parallelly run: | curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s