Skip to content

Commit

Permalink
automate PR + release process
Browse files Browse the repository at this point in the history
  • Loading branch information
wtait1 committed Sep 12, 2020
1 parent 5cc7e22 commit 7d37d0f
Show file tree
Hide file tree
Showing 8 changed files with 691 additions and 25 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: pr

on:
pull_request:

jobs:
pr:
runs-on: ubuntu-latest
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: Check GoReleaser config
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: check
-
name: Lint, test, etc.
run: make ci

37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: goreleaser

on:
push:
branches:
- 'master'
tags:
- 'v*'

jobs:
goreleaser:
runs-on: ubuntu-latest
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: Check GoReleaser config
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: check
-
name: Run GoReleaser release
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ bin

.vscode
vendor/
dist/
46 changes: 46 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go mod download
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- darwin
# - linux
# - windows
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- -s -w -X main.version={{.Version}}
archives:
- replacements:
darwin: Darwin
# linux: Linux
# windows: Windows
# 386: i386
# amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- Merge pull request
- Merge branch
- go mod tidy
brews:
- tap:
owner: wtait1
name: homebrew-brews
folder: Formula
homepage: https://github.com/wtait1/ddf
description: CLI tool to De-Duplicate Files
test: |
system "#{bin}/ddf -v"
40 changes: 18 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,35 @@ RELEASE_TAG ?= $(TIMESTAMP)
# Default Go linker flags.
GO_LDFLAGS ?= -ldflags="-s -w -X main.Version=v${RELEASE_TAG}"

# Binary name.
DDF_OSX := ./bin/ddf-osx
.PHONY: ci
ci: clean build lint test

.PHONY: all
all: clean lint $(DDF_OSX) test
.PHONY: build
build:
@mkdir -p dist
go build -o ./dist/ddf

$(DDF_OSX):
GOOS=darwin GOARCH=amd64 go build $(GO_LDFLAGS) $(BUILDARGS) -o $@ .

.PHONY: vendor
vendor:
go mod tidy
go mod vendor

.PHONY: lint
# Run all the linters
lint:
@ golangci-lint run --fast
golangci-lint run ./...
misspell -error **/*
.PHONY: lint

.PHONY: test
test:
go test -mod=vendor -timeout=30s $(TESTARGS) ./...
go test -timeout=30s $(TESTARGS) ./...

.PHONY: cover
cover:
@$(MAKE) test TESTARGS="-coverprofile=coverage.out"
@go tool cover -html=coverage.out
@rm -f coverage.out

# Install all the build and lint dependencies
.PHONY: setup
setup:
go mod download
go generate -v ./...

.PHONY: clean
clean:
@rm -rf ./bin

.PHONY: package
package: all
zip -j bin/ddf-osx.zip $(DDF_OSX)
shasum -a 256 bin/ddf-osx.zip > bin/ddf-osx.sha256
@rm -rf ./dist
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
module wtait1/clew
module wtait1/ddf

go 1.15

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golangci/golangci-lint v1.31.0 // indirect
github.com/jessevdk/go-flags v1.4.0
github.com/kr/pretty v0.1.0 // indirect
github.com/labstack/gommon v0.3.0
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/stretchr/testify v1.5.1 // indirect
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)
556 changes: 556 additions & 0 deletions go.sum

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate go install github.com/golangci/golangci-lint/cmd/golangci-lint
//go:generate go install github.com/client9/misspell/cmd/misspell
package main

import (
Expand Down

0 comments on commit 7d37d0f

Please sign in to comment.