Skip to content

Commit

Permalink
chore: Fix goreleaser, change generating artifacts to global before h…
Browse files Browse the repository at this point in the history
…ook (#298)
  • Loading branch information
cszatmary authored Jul 30, 2021
1 parent 38be007 commit 13e5b6f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 98 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ bin

# Test coverage
coverage/

artifacts
26 changes: 10 additions & 16 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ project_name: tb

before:
hooks:
- go mod download
# you may remove this if you don't need go generate
- go generate ./...
- go mod tidy
- go run scripts/build-artifacts/main.go

builds:
-
env:
- env:
- CGO_ENABLED=0
ldflags:
- -s -w -X github.com/TouchBistro/tb/cmd.version={{.Version}}
Expand All @@ -18,22 +16,19 @@ builds:
goarch:
- amd64
- arm64
hooks:
post: go run scripts/post-build/main.go

archives:
-
replacements:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
files:
- README.md
- dist/tb.bash
- dist/_tb
- dist/man1/*
- artifacts/tb.bash
- artifacts/_tb
- artifacts/man1/*

checksum:
name_template: 'checksums.txt'
Expand All @@ -49,8 +44,7 @@ changelog:
- '^test:'

brews:
-
github:
- tap:
owner: TouchBistro
name: homebrew-tap
commit_author:
Expand All @@ -64,8 +58,8 @@ brews:
install: |
bin.install "tb"
bash_completion.install "dist/tb.bash"
zsh_completion.install "dist/_tb"
bash_completion.install "artifacts/tb.bash"
zsh_completion.install "artifacts/_tb"
man1.install Dir["dist/man1/*.1"]
release:
Expand Down
32 changes: 15 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
.DEFAULT_GOAL = build

# Get all dependencies
setup:
# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help

setup: ## Get all dependencies
# Only install if missing
ifeq (,$(wildcard bin/golangci-lint))
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
endif

go mod download
go mod tidy
.PHONY: setup

# Build tb
build:
build: ## Build tb
go build
go run scripts/post-build/main.go
.PHONY: build

# Clean all build artifacts
clean:
rm -rf dist
clean: ## Clean all build artifacts
rm -rf artifacts
rm -rf coverage
rm -rf dist
rm -f tb
.PHONY: clean

# Run the linter
lint:
lint: ## Run the linter
./bin/golangci-lint run ./...
.PHONY: lint

# Remove version of tb installed with go install
go-uninstall:
go-uninstall: ## Remove version of tb installed with go install
rm $(shell go env GOPATH)/bin/tb
.PHONY: go-uninstall

# Run tests and collect coverage data
test:
test: ## Run tests and collect coverage data
mkdir -p coverage
go test -coverprofile=coverage/coverage.txt ./...
go tool cover -html=coverage/coverage.txt -o coverage/coverage.html
.PHONY: test

# Run tests and print coverage data to stdout
test-ci:
test-ci: ## Run tests and print coverage data to stdout
mkdir -p coverage
go test -coverprofile=coverage/coverage.txt ./...
go tool cover -func=coverage/coverage.txt
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ require (
github.com/containerd/containerd v1.5.5 // indirect
github.com/docker/docker v20.10.7+incompatible
github.com/docker/go-connections v0.4.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.2.1
github.com/stretchr/testify v1.7.0 // indirect
github.com/stretchr/testify v1.7.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)
Loading

0 comments on commit 13e5b6f

Please sign in to comment.