Skip to content

Commit

Permalink
chore(ci): port to using golangci-lint and goreleaser github action
Browse files Browse the repository at this point in the history
  • Loading branch information
clok committed Mar 15, 2021
1 parent a86c748 commit ba8ed8b
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 31 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ vault-key
.idea
.DS_Store
bin
benchmark/results.html
benchmark/results.html
dist/
21 changes: 21 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 3 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,19 @@ 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/
go get -t ./...
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
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit ba8ed8b

Please sign in to comment.