Skip to content

Commit

Permalink
Use goreleaser instead gox and ghr
Browse files Browse the repository at this point in the history
  • Loading branch information
ebc-2in2crc committed May 4, 2021
1 parent db07cf6 commit 5882e8b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
36 changes: 36 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
before:
hooks:
- go mod tidy
dist: ./build
builds:
- env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{.Version}}
goos:
- linux
- windows
- darwin
goarch:
- 386
- amd64
- arm64
ignore:
- goos: darwin
goarch: 386
- goos: windows
goarch: arm64
archives:
- format: zip
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
wrap_in_directory: true
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
21 changes: 6 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ NAME := dango
CURRENT := $(shell pwd)
BUILDDIR := ./build
BINDIR := $(BUILDDIR)/bin
PKGDIR := $(BUILDDIR)/pkg
DISTDIR := $(BUILDDIR)/dist

VERSION := $(shell git describe --tags --abbrev=0)
LDFLAGS := -X 'main.version=$(VERSION)'
GOXOSARCH := "darwin/amd64 darwin/arm64 windows/386 windows/amd64 linux/386 linux/amd64"
GOXOUTPUT := "$(PKGDIR)/$(NAME)_{{.OS}}_{{.Arch}}/{{.Dir}}"

export GO111MODULE=on

Expand All @@ -35,8 +31,8 @@ devel-deps: deps
cd $$tmpdir; \
$(GOGET) \
github.com/golangci/golangci-lint/cmd/golangci-lint \
github.com/goreleaser/goreleaser \
github.com/Songmu/make2help/cmd/make2help \
github.com/mitchellh/gox \
github.com/tcnksm/ghr; \
rm -rf $$tmpdir'

Expand All @@ -48,22 +44,17 @@ build: deps
.PHONY: cross-build
## Cross build binaries
cross-build:
rm -rf $(PKGDIR)
gox -osarch=$(GOXOSARCH) -ldflags "$(LDFLAGS)" -output=$(GOXOUTPUT) .
goreleaser build --rm-dist

.PHONY: package
## Make package
package: cross-build
rm -rf $(DISTDIR)
mkdir $(DISTDIR)
pushd $(PKGDIR) > /dev/null && \
for P in `ls | xargs basename`; do zip -r $(CURRENT)/$(DISTDIR)/$$P.zip $$P; done && \
popd > /dev/null
package:
goreleaser release --snapshot --skip-publish --rm-dist

.PHONY: release
## Release package to Github
release: package
ghr $(VERSION) $(DISTDIR)
release:
goreleaser release --rm-dist

.PHONY: test
## Run tests
Expand Down

0 comments on commit 5882e8b

Please sign in to comment.