mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 16:01:55 +03:00
Merge pull request #264 from 9seconds/goreleaser-v1
Use goreleaser for v1
This commit is contained in:
+1
-1
@@ -7,5 +7,5 @@
|
|||||||
*.out
|
*.out
|
||||||
mtg
|
mtg
|
||||||
vendor/
|
vendor/
|
||||||
ccbuilds/
|
|
||||||
.bin/
|
.bin/
|
||||||
|
dist/
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
project_name: mtg
|
||||||
|
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy
|
||||||
|
- go generate ./...
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- binary: '{{ .ProjectName }}'
|
||||||
|
goos:
|
||||||
|
- darwin
|
||||||
|
- freebsd
|
||||||
|
- linux
|
||||||
|
- netbsd
|
||||||
|
- openbsd
|
||||||
|
goarch:
|
||||||
|
- 386
|
||||||
|
- amd64
|
||||||
|
- arm
|
||||||
|
- arm64
|
||||||
|
goarm:
|
||||||
|
- 6
|
||||||
|
- 7
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
- -mod=readonly
|
||||||
|
ldflags: -s -w -X main.version={{ .Version }}
|
||||||
|
ignore:
|
||||||
|
- goos: darwin
|
||||||
|
goarch: 386
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm64
|
||||||
|
- goos: netbsd
|
||||||
|
goarch: arm64
|
||||||
|
- goos: openbsd
|
||||||
|
goarch: arm64
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
|
||||||
|
format: tar.gz
|
||||||
|
wrap_in_directory: true
|
||||||
|
format_overrides:
|
||||||
|
- goos: windows
|
||||||
|
format: zip
|
||||||
|
files:
|
||||||
|
- LICENSE
|
||||||
|
- README.md
|
||||||
|
- SECURITY.md
|
||||||
|
|
||||||
|
gomod:
|
||||||
|
proxy: true
|
||||||
|
|
||||||
|
snapshot:
|
||||||
|
name_template: '{{ .Version }}'
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
name_template: '{{ .ProjectName }}-{{ .Version }}-checksums.txt'
|
||||||
|
|
||||||
|
source:
|
||||||
|
enabled: true
|
||||||
|
name_template: '{{ .ProjectName }}-sources'
|
||||||
@@ -2,14 +2,12 @@ ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|||||||
IMAGE_NAME := mtg
|
IMAGE_NAME := mtg
|
||||||
APP_NAME := $(IMAGE_NAME)
|
APP_NAME := $(IMAGE_NAME)
|
||||||
|
|
||||||
CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
|
|
||||||
|
|
||||||
GOLANGCI_LINT_VERSION := v1.45.0
|
GOLANGCI_LINT_VERSION := v1.45.0
|
||||||
|
|
||||||
VERSION_GO := $(shell go version)
|
VERSION_GO := $(shell go version)
|
||||||
VERSION_DATE := $(shell date -Ru)
|
VERSION_DATE := $(shell date -Ru)
|
||||||
VERSION_TAG := $(shell git describe --tags --always)
|
VERSION_TAG := $(shell git describe --tags --always)
|
||||||
COMMON_BUILD_FLAGS := -mod=readonly -ldflags="-s -w -X 'main.version=$(VERSION_TAG) ($(VERSION_GO)) [$(VERSION_DATE)]'"
|
COMMON_BUILD_FLAGS := -trimpath -mod=readonly -ldflags="-s -w -X 'main.version=$(VERSION_TAG) ($(VERSION_GO)) [$(VERSION_DATE)]'"
|
||||||
|
|
||||||
GOBIN := $(ROOT_DIR)/.bin
|
GOBIN := $(ROOT_DIR)/.bin
|
||||||
GOTOOL := env "GOBIN=$(GOBIN)" "PATH=$(ROOT_DIR)/.bin:$(PATH)"
|
GOTOOL := env "GOBIN=$(GOBIN)" "PATH=$(ROOT_DIR)/.bin:$(PATH)"
|
||||||
@@ -29,18 +27,6 @@ $(APP_NAME): build
|
|||||||
static:
|
static:
|
||||||
@env CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
|
@env CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
|
||||||
|
|
||||||
$(APP_NAME)-%: GOOS=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f1 -d-)
|
|
||||||
$(APP_NAME)-%: GOARCH=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f2 -d-)
|
|
||||||
$(APP_NAME)-%: ccbuilds
|
|
||||||
@env "GOOS=$(GOOS)" "GOARCH=$(GOARCH)" \
|
|
||||||
go build \
|
|
||||||
$(COMMON_BUILD_FLAGS) \
|
|
||||||
-o "./ccbuilds/$(APP_NAME)-$(GOOS)-$(GOARCH)"
|
|
||||||
|
|
||||||
.PHONY: ccbuilds
|
|
||||||
ccbuilds:
|
|
||||||
@rm -rf ./ccbuilds && mkdir -p ./ccbuilds
|
|
||||||
|
|
||||||
vendor: go.mod go.sum
|
vendor: go.mod go.sum
|
||||||
@$(MOD_ON) go mod vendor
|
@$(MOD_ON) go mod vendor
|
||||||
|
|
||||||
@@ -52,9 +38,6 @@ test:
|
|||||||
citest:
|
citest:
|
||||||
@go test -coverprofile=coverage.txt -covermode=atomic -race -v ./...
|
@go test -coverprofile=coverage.txt -covermode=atomic -race -v ./...
|
||||||
|
|
||||||
.PHONY: crosscompile
|
|
||||||
crosscompile: $(CC_BINARIES)
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
@git clean -xfd && \
|
@git clean -xfd && \
|
||||||
@@ -77,8 +60,14 @@ doc:
|
|||||||
fmt:
|
fmt:
|
||||||
@$(GOTOOL) gofumpt -w -extra "$(ROOT_DIR)"
|
@$(GOTOOL) gofumpt -w -extra "$(ROOT_DIR)"
|
||||||
|
|
||||||
|
.PHONY: release
|
||||||
|
release:
|
||||||
|
@$(GOTOOL) goreleaser release --snapshot --rm-dist && \
|
||||||
|
find "$(ROOT_DIR)/dist" -type d | grep -vP "dist$$" | xargs -r rm -rf && \
|
||||||
|
rm -f "$(ROOT_DIR)/dist/config.yaml"
|
||||||
|
|
||||||
.PHONY: install-tools
|
.PHONY: install-tools
|
||||||
install-tools: install-tools-lint install-tools-godoc install-tools-gofumpt
|
install-tools: install-tools-lint install-tools-godoc install-tools-gofumpt install-tools-goreleaser
|
||||||
|
|
||||||
.PHONY: install-tools-lint
|
.PHONY: install-tools-lint
|
||||||
install-tools-lint:
|
install-tools-lint:
|
||||||
@@ -95,6 +84,10 @@ install-tools-godoc:
|
|||||||
install-tools-gofumpt: .bin
|
install-tools-gofumpt: .bin
|
||||||
@$(GOTOOL) go install mvdan.cc/gofumpt@latest
|
@$(GOTOOL) go install mvdan.cc/gofumpt@latest
|
||||||
|
|
||||||
|
.PHONY: goreleaser
|
||||||
|
install-tools-goreleaser: .bin
|
||||||
|
@$(GOTOOL) go install github.com/goreleaser/goreleaser@latest
|
||||||
|
|
||||||
.PHONY: update-deps
|
.PHONY: update-deps
|
||||||
update-deps:
|
update-deps:
|
||||||
@go get -u && go mod tidy -go=1.18
|
@go get -u && go mod tidy -go=1.18
|
||||||
|
|||||||
Reference in New Issue
Block a user