github.com/itchyny/rassemble-go@v0.1.1/Makefile (about)

     1  BIN := rassemble
     2  VERSION := $$(make -s show-version)
     3  VERSION_PATH := cmd/$(BIN)
     4  CURRENT_REVISION = $(shell git rev-parse --short HEAD)
     5  BUILD_LDFLAGS = "-s -w -X main.revision=$(CURRENT_REVISION)"
     6  GOBIN ?= $(shell go env GOPATH)/bin
     7  
     8  .PHONY: all
     9  all: build
    10  
    11  .PHONY: build
    12  build:
    13  	go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) ./cmd/$(BIN)
    14  
    15  .PHONY: install
    16  install:
    17  	go install -ldflags=$(BUILD_LDFLAGS) ./cmd/$(BIN)
    18  
    19  .PHONY: show-version
    20  show-version: $(GOBIN)/gobump
    21  	@gobump show -r "$(VERSION_PATH)"
    22  
    23  $(GOBIN)/gobump:
    24  	@go install github.com/x-motemen/gobump/cmd/gobump@latest
    25  
    26  .PHONY: cross
    27  cross: $(GOBIN)/goxz CREDITS
    28  	goxz -n $(BIN) -pv=v$(VERSION) -build-ldflags=$(BUILD_LDFLAGS) ./cmd/$(BIN)
    29  
    30  $(GOBIN)/goxz:
    31  	go install github.com/Songmu/goxz/cmd/goxz@latest
    32  
    33  CREDITS: $(GOBIN)/gocredits
    34  	go mod tidy
    35  	gocredits -w .
    36  
    37  $(GOBIN)/gocredits:
    38  	go install github.com/Songmu/gocredits/cmd/gocredits@latest
    39  
    40  .PHONY: test
    41  test: build
    42  	go test -v -race ./...
    43  
    44  .PHONY: lint
    45  lint: $(GOBIN)/staticcheck
    46  	go vet ./...
    47  	staticcheck -checks all ./...
    48  
    49  $(GOBIN)/staticcheck:
    50  	go install honnef.co/go/tools/cmd/staticcheck@latest
    51  
    52  .PHONY: clean
    53  clean:
    54  	rm -rf $(BIN) goxz CREDITS
    55  	go clean
    56  
    57  .PHONY: bump
    58  bump: $(GOBIN)/gobump
    59  	test -z "$$(git status --porcelain || echo .)"
    60  	test "$$(git branch --show-current)" = "main"
    61  	@gobump up -w "$(VERSION_PATH)"
    62  	git commit -am "bump up version to $(VERSION)"
    63  	git tag "v$(VERSION)"
    64  	git push --atomic origin main tag "v$(VERSION)"