From c41bf3ab9a6f36005be6f3514de10137167ddc97 Mon Sep 17 00:00:00 2001 From: Manuel Vogel Date: Sat, 16 Jan 2021 06:48:01 +0100 Subject: [PATCH] ci: switches release process to gh actions and goreleaser (#87) Also preserves coveralls and appveyor. Closes #58 --- .github/workflows/release.yml | 26 +++++++++++++++++++ .github/workflows/test.yml | 37 +++++++++++++++++++++++++++ .goreleaser.yml | 48 +++++++++++++++++++++++++++++++++++ .travis.yml | 24 ------------------ Makefile | 8 +----- scripts/release.sh | 10 -------- 6 files changed, 112 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 .goreleaser.yml delete mode 100644 .travis.yml delete mode 100755 scripts/release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..1ba36fbd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: goreleaser + +on: + push: + tags: + - '*' + +jobs: + goreleaser: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..3139b5da --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: tests + +on: + pull_request: + types: ['opened', 'synchronize'] + paths-ignore: + - 'README.md' + push: + branches: + - master + paths-ignore: + - 'README.md' +jobs: + unit: + runs-on: ubuntu-20.04 + strategy: + fail-fast: true + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + - name: Run tests + run: | + make test + - name: Install goveralls + env: + GO111MODULE: off + run: go get github.com/mattn/goveralls + - name: Send coverage + env: + COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: goveralls -coverprofile=cover.out -service=github diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..84fb9e64 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,48 @@ +# This is an example .goreleaser.yml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +project_name: git-chglog + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod download + +builds: + - dir: cmd/git-chglog + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm + - arm64 + goarm: + - 6 + +archives: + - format_overrides: + - goos: windows + format: zip + +checksum: + name_template: 'checksums.txt' + +changelog: + sort: asc + +snapshot: + name_template: "{{ .Tag }}-next" + +brews: + - tap: + owner: git-chglog + name: homebrew-git-chglog + homepage: "https://godoc.org/github.com/git-chglog/git-chglog" + description: "CHANGELOG generator implemented in Go (Golang)." + test: | + system "#{bin}/git-chglog --help" + install: | + bin.install "git-chglog" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6c40abb9..00000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: go -notifications: - email: false -go: - - 1.15 -before_install: - - GO111MODULE=off go get github.com/mattn/goveralls -before_script: - - export TZ=Asia/Tokyo - - sudo timedatectl set-timezone Asia/Tokyo - - timedatectl -script: - - make test -after_success: - - goveralls -service=travis-ci -before_deploy: - - GO111MODULE=off go get github.com/mitchellh/gox - - GO111MODULE=off go get github.com/tcnksm/ghr -deploy: - provider: script - script: ./scripts/release.sh - on: - tags: true - branch: master diff --git a/Makefile b/Makefile index 1932f8e8..3cc86267 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,7 @@ build: .PHONY: test test: - go test -v `go list ./...` - -.PHONY: coverage -coverage: - goverage -coverprofile=cover.out `go list ./...` - go tool cover -func=cover.out - @rm -rf cover.out + go test -covermode atomic -coverprofile cover.out -v ./... .PHONY: install install: diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index c4f681e4..00000000 --- a/scripts/release.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -REPO_ROOT=$(git rev-parse --show-toplevel) - -echo "Start release ..." - -gox -os="darwin linux windows" -arch="amd64 386" -output="$REPO_ROOT/dist/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/git-chglog -ghr --username git-chglog --token $GITHUB_TOKEN --replace `grep 'Version =' ./cmd/git-chglog/version.go | sed -E 's/.*"(.+)"$$/\1/'` dist/ - -echo "Released!"