github.com/grafviktor/keep-my-secret@v0.9.10-0.20230908165355-19f35cce90e5/Makefile (about)

     1  LD_FLAGS = -ldflags="-X main.buildVersion=v0.9.9 -X main.buildDate=$(shell date +%Y-%m-%d) -X main.buildCommit=$(shell git rev-parse --short=8 HEAD)"
     2  LD_FLAGS_WIN_LIN = -ldflags="-X main.buildVersion=v0.9.9 -X main.buildDate=$(shell date +%Y-%m-%d) -X main.buildCommit=$(shell git rev-parse --short=8 HEAD) -linkmode external -extldflags -static"
     3  
     4  ## help: print this help message
     5  help:
     6  	@echo 'Usage:'
     7  	@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' |  sed -e 's/^/ /'
     8  
     9  ## audit: tidy dependencies and format, vet and test all code
    10  .PHONY: audit
    11  audit:
    12  	@echo 'Tidying and verifying module dependencies...'
    13  	go mod tidy
    14  	go mod verify
    15  	@echo 'Formatting code...'
    16  	gofumpt -l -w ./..
    17  	goimports -w -local github.com/grafviktor/keep-my-secret .
    18  	@echo 'Vetting code...'
    19  	go vet ./...
    20  	staticcheck ./...
    21  	@echo 'Linting code...'
    22  	golangci-lint run
    23  	@$(MAKE) test
    24  
    25  ## test: run unit tests
    26  .PHONY: test
    27  test:
    28  	@echo 'Running unit tests'
    29  	go test -race -vet=off -count=1 -coverprofile unit.txt -covermode atomic ./...
    30  
    31  ## build-server: create binary with debugging symbols in /cmd/kms folder
    32  .PHONY: build-server
    33  build-server:
    34  	# https://www.andrewheiss.com/blog/2020/01/10/makefile-subdirectory-zips/
    35  	# https://github.com/mattn/go-sqlite3/issues/384
    36  	# @-rm -r ./build
    37  	@echo 'Creating debug build'
    38  	GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build $(LD_FLAGS) -o ./build/kms-darwin-amd64 ./cmd/kms/*.go
    39  	# https://words.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/
    40  	# brew install FiloSottile/musl-cross/musl-cross
    41  	CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++ GOARCH=amd64 GOOS=linux CGO_ENABLED=1 go build $(LD_FLAGS_WIN_LIN) -o ./build/kms-linux-amd64 ./cmd/kms/*.go
    42  	# https://words.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/
    43  	# 1. brew install FiloSottile/musl-cross/musl-cross + 2. brew install mingw-w64
    44  	CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ GOARCH=amd64 GOOS=windows CGO_ENABLED=1 go build $(LD_FLAGS_WIN_LIN) -o ./build/kms-windows-amd64.exe ./cmd/kms/*.go
    45  
    46  ## build-client: create client application
    47  .PHONY: build-client
    48  build-client:
    49  	@echo 'Creating client build'
    50  	@cd website && npm install && npm run build
    51  
    52  ## build: build the whole project
    53  .PHONY: build
    54  build:
    55  	@echo 'Building the whole project'
    56  	@$(MAKE) build-server
    57  	@$(MAKE) build-client
    58  
    59  ## http-tls-key: create self-signed certificate and store it in /tls folder
    60  .PHONY: http-tls-key
    61  http-tls-key:
    62  	@echo 'Creating self-signed HTTP TLS certificate'
    63  	@cd tls && go run $$GOPATH/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost
    64  
    65  ## run: start application
    66  .PHONY: run
    67  run:
    68  	@echo 'Attempting to start the app'
    69  	DEV=true go run $(LD_FLAGS) ./cmd/kms/*.go
    70  
    71  ## lint: run linter
    72  .PHONY: lint
    73  lint:
    74  	@echo 'Running linter'
    75  	@golangci-lint run
    76  
    77  ## swagger: runs swag utility which generates API documentation
    78  # 'swag' should be installed: go install github.com/swaggo/swag/cmd/swag@latest
    79  # you should only run it from a folder where "main.go" file is located
    80  .PHONY: swagger
    81  swagger:
    82  	@echo 'Generating API docs in cmd/kms/swagger folder'
    83  	@cd cmd/kms/ && swag init --output ./swagger/