diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml new file mode 100644 index 0000000..3378359 --- /dev/null +++ b/.github/actions/release/action.yml @@ -0,0 +1,19 @@ +name: release +description: release maltmill +inputs: + token: + description: GitHub token + required: true +runs: + using: composite + steps: + - name: setup go + uses: actions/setup-go@v3 + with: + go-version: 1.x + - name: release + run: | + make crossbuild upload + shell: bash + env: + GITHUB_TOKEN: ${{ inputs.token }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..084f9b1 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,14 @@ +name: release +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v3 + - uses: ./.github/actions/release + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tagpr.yaml b/.github/workflows/tagpr.yaml new file mode 100644 index 0000000..0e8f5cf --- /dev/null +++ b/.github/workflows/tagpr.yaml @@ -0,0 +1,25 @@ +name: tagpr +on: + push: + branches: + - "master" +jobs: + tagpr: + runs-on: ubuntu-latest + steps: + - name: setup go + uses: actions/setup-go@v3 + with: + go-version: 1.x + - name: checkout + uses: actions/checkout@v3 + - 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.yml b/.github/workflows/test.yml index fbf67c3..3d163a1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,8 @@ name: Test on: push: - pull_request: - + branches: + - "**" jobs: test: name: Test @@ -14,18 +14,13 @@ jobs: - ubuntu-latest - macos-latest - windows-latest - go: - - "1.x" - steps: - - name: Set up Go ${{ matrix.go }} - uses: actions/setup-go@v2 + - name: Set up Go + uses: actions/setup-go@v3 with: - go-version: ${{ matrix.go }} - + go-version: 1.x - name: Check out code into the Go module directory uses: actions/checkout@v2 - - name: restore cache uses: actions/cache@v2 with: @@ -33,18 +28,16 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - - name: Test run: make cover env: GITHUB_TOKEN: ${{ secrets.GHTOOLS_GITHUB_TOKEN }} - - name: Send coverage uses: shogo82148/actions-goveralls@v1 with: path-to-profile: cover.out parallel: true - flag-name: OS-${{ matrix.os }}-Go-${{ matrix.go }} + flag-name: OS-${{ matrix.os }}-Go-1.x # notifies that all test jobs are finished. finish: diff --git a/Makefile b/Makefile index 93bd42a..d759571 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,10 @@ VERSION = $(shell godzil show-version) COMMIT = $(shell git rev-parse --short HEAD) BUILD_LDFLAGS = "-s -w -X main.GitCommit=$(COMMIT)" -EXTERNAL_TOOLS = \ - golang.org/x/lint/golint \ - github.com/Songmu/godzil/cmd/godzil \ - github.com/Songmu/ghch/cmd/ghch \ - github.com/mattn/goveralls \ - github.com/Songmu/gocredits/cmd/gocredits \ - golang.org/x/tools/cmd/cover - ifdef update u=-u endif -export GO111MODULE=on - .PHONY: default default: test @@ -26,26 +16,19 @@ deps: # install external tools for this project .PHONY: devel-deps devel-deps: deps - @for tool in $(EXTERNAL_TOOLS) ; do \ - echo "Installing $$tool" ; \ - go install $$tool@latest; \ - done + go install github.com/Songmu/godzil/cmd/godzil@latest # build generate binary on './bin' directory. .PHONY: build build: go build -ldflags=$(BUILD_LDFLAGS) -o bin/ghr -.PHONY: bump -bump: devel-deps - godzil release - CREDITS: go.sum devel-deps - gocredits -w + godzil credits -w .PHONY: crossbuild crossbuild: CREDITS - goxz -pv=v${VERSION} -build-ldflags=$(BUILD_LDFLAGS) \ + godzil crossbuild -pv=v${VERSION} -build-ldflags=$(BUILD_LDFLAGS) \ -arch=amd64 -d=./pkg/dist/v${VERSION} cd pkg/dist/v${VERSION} && shasum -a 256 * > ./v${VERSION}_SHASUMS @@ -57,10 +40,7 @@ install: .PHONY: upload upload: build devel-deps bin/ghr -v - bin/ghr -body="$$(ghch --latest -F markdown)" v$(VERSION) pkg/dist/v$(VERSION) - -.PHONY: test-all -test-all: lint test + bin/ghr v$(VERSION) pkg/dist/v$(VERSION) .PHONY: test test: deps @@ -70,15 +50,10 @@ test: deps test-race: go test -v -race ./... -.PHONY: lint -lint: devel-deps - go vet ./... - golint -set_exit_status ./... - .PHONY: cover cover: go test -coverprofile=cover.out go tool cover -html cover.out .PHONY: release -release: bump crossbuild upload +release: crossbuild upload