From ba8ed8b8e9f68223ca3ee0fa7291deca32026869 Mon Sep 17 00:00:00 2001 From: Derek Smith Date: Mon, 15 Mar 2021 15:37:25 -0500 Subject: [PATCH] chore(ci): port to using golangci-lint and goreleaser github action --- .github/workflows/lint.yml | 12 +++++++++++ .github/workflows/release.yml | 26 +++++++++++++++++++++++ .gitignore | 3 ++- .golangci.yml | 21 +++++++++++++++++++ .goreleaser.yml | 39 +++++++++++++++++++++++++++++++++++ Makefile | 30 +++------------------------ README.md | 22 +++++++++++++++++--- 7 files changed, 122 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/release.yml create mode 100644 .golangci.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3c9671e --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,12 @@ +name: lint +on: [ push, pull_request ] +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.38 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..278ddf9 --- /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.16 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 527a78f..b0ce175 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ vault-key .idea .DS_Store bin -benchmark/results.html \ No newline at end of file +benchmark/results.html +dist/ \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..848c27e --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,21 @@ +# https://golangci-lint.run/usage/configuration/ +run: + timeout: 2m + +output: + format: tab + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + +linters: + enable: + - dupl + - depguard + - gocritic + - gocyclo + - gofmt + - golint + - misspell + - unconvert diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..774e247 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,39 @@ +# This is an example .goreleaser.yml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +project_name: gwvault + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod download + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - 386 + - amd64 + - arm + - arm64 + +archives: + - wrap_in_directory: true + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: 'checksums.txt' + +changelog: + sort: desc + filters: + exclude: + - '^Merge' + +snapshot: + name_template: "{{ .Tag }}-next" diff --git a/Makefile b/Makefile index 8adbf3b..e9edfde 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,7 @@ SHORT_VERSION=$$(git describe --tags --always | awk -F '-' '{print $$1}') LDFLAGS=-ldflags=all="-X main.version=${SHORT_VERSION}" -all: tools build - -tools: - GO111MODULE=off go get -u -v "github.com/mitchellh/gox" +all: build build: @mkdir -p bin/ @@ -16,32 +13,11 @@ build: go test -v ./... go build ${LDFLAGS} -o bin/${NAME} ./main.go -xbuild: clean - @mkdir -p build - gox \ - -os="linux" \ - -os="windows" \ - -os="darwin" \ - -arch="amd64" \ - ${LDFLAGS} \ - -output="build/$(NAME)_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)" \ - ./... - -package: xbuild - $(eval FILES := $(shell ls build)) - @mkdir -p build/tgz - for f in $(FILES); do \ - (cd $(shell pwd)/build && tar -zcvf tgz/$$f.tar.gz $$f); \ - echo $$f; \ - done - docs: DOCS_MD=1 go run ./main.go > docs/${NAME}.md DOCS_MAN=1 go run ./main.go > docs/${NAME}.8 clean: - @rm -rf bin/ && rm -rf build/ - -ci: tools package + @rm -rf bin/ && rm -rf build/ && rm -rf dist/ -.PHONY: all tools build xbuild package clean ci docs +.PHONY: all tools build clean docs diff --git a/README.md b/README.md index 89fbdd2..e1ba796 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ $ curl https://i.jpillora.com/GoodwayGroup/gwvault! | bash Add plugin: ``` -$ asdf plugin-add gwvault https://github.com/GoodwayGroup/asdf-gwvault.git +$ asdf plugin add gwvault ``` Install the latest version: @@ -83,18 +83,34 @@ See [`./benchmark/results.html`](./benchmark/results.html) for a detailed breakd ## Built With -* go v1.14+ +* go v1.16+ * make -* [github.com/mitchellh/gox](https://github.com/mitchellh/gox) +* [goreleaser](https://goreleaser.com/install/) ## Deployment Run `./release.sh $VERSION` +This will update docs, changelog, add the tag, push main and the tag to the repo. The `goreleaser` action will publish the binaries to the Github Release. + +If you want to simulate the `goreleaser` process, run the following command: + +``` +$ curl -sL https://git.io/goreleaser | bash -s -- --rm-dist --skip-publish --snapshot +``` + ## Contributing Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. +1. Fork the [GoodwayGroup/gwvault](https://github.com/GoodwayGroup/gwvault) repo +1. Use `go >= 1.16` +1. Branch & Code +1. Run linters :broom: `golangci-lint run` + - The project uses [golangci-lint](https://golangci-lint.run/usage/install/#local-installation) +1. Commit with a Conventional Commit +1. Open a PR + ## Versioning We employ [git-chglog](https://github.com/git-chglog/git-chglog) to manage the [CHANGELOG.md](CHANGELOG.md). For the versions available, see the [tags on this repository](https://github.com/GoodwayGroup/gwvault/tags).