Skip to content

Commit

Permalink
Add goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
markruler committed Mar 8, 2021
1 parent 574b324 commit 9aef146
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ bin/
.DS_Store
*.xlsx
.~lock.*.xlsx#
dist/
52 changes: 52 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# http://goreleaser.com
release:
prerelease: false

env_files:
github_token: ~/.config/goreleaser/github_token

before:
hooks:
- go mod tidy
# - go generate ./...

builds:
# - binary: swage
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- 386
- arm64
ldflags:
- -s -w -extldflags='-static' -X github.com/cxsu/swage/pkg/cmd.swageVersion={{ .Version }}

archives:
- replacements:
# 386: i386 # 32-bit
# amd64: x86_64 # 64-bit
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
format: tar.gz
format_overrides:
- goos: windows
format: zip

snapshot:
name_template: '{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}'

checksum:
name_template: '{{ .ProjectName }}_{{ .Tag }}_checksums'

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- Merge pull request
- Merge branch
- go mod tidy
43 changes: 26 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
SHELL := bash
.ONESHELL:

NAME := swage
BIN_DIR := bin
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
VERSION := $(file < ./VERSION)
# GOBIN := $(shell go env GOPATH)/bin
# TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x windows/amd64

.SHELLFLAGS := -eu -o pipefail -c
NAME := swage
BUILD_DIR := bin
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
VERSION := $(file < ./VERSION)
# GOBIN := $(shell go env GOPATH)/bin
# TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x windows/amd64

.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := all
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --warn-undefined-variables
# go tool link (https://golang.org/cmd/link/)
LDFLAGS := -s -w -extldflags='-static' \
-X 'github.com/cxsu/swage/pkg/cmd.swageVersion=${VERSION}'
LDFLAGS := -s -w -extldflags='-static' -X 'github.com/cxsu/swage/pkg/cmd.swageVersion=${VERSION}'

all: version deps test cover build
.PHONY: all
Expand All @@ -23,16 +22,12 @@ version:
@echo $(VERSION)
.PHONY: version

tag:
git tag $(VERSION)
.PHONY: tag

deps:
@#go get -u
@#rm -rf vendor/
@go get -t -d -v ./...
@go mod tidy
@go mod vendorbi
@go mod vendor
.PHONY: deps

fmt:
Expand Down Expand Up @@ -67,6 +62,7 @@ clean:
go clean
rm -f *.xlsx
rm -rf $(BIN_DIR)
rm -rf dist
.PHONY: clean

build: test
Expand All @@ -76,3 +72,16 @@ build: test
docker:
@scripts/docker.sh
.PHONY: docker

release-snapshot:
@rm -rf dist
@goreleaser --snapshot --skip-publish
.PHONY: release

release-publish:
@rm -rf dist
@#git tag --annotate=$(VERSION) --message="release message"
git tag $(VERSION)
git push origin $(VERSION)
goreleaser release --rm-dist
.PHONY: release-publish

0 comments on commit 9aef146

Please sign in to comment.