gitlab.com/evatix-go/core@v1.3.55/makefile (about)

     1  BinariesDirectory = ./bin
     2  WindowsBinariesDirectory = bin
     3  MainDirectory = cmd/main
     4  ConfigDirectory = ./configs
     5  ConfigDirectoryForWindows = configs
     6  GoVersion=v1.17.8
     7  MyApp=cli
     8  
     9  .PHONY: clean lint changelog snapshot release
    10  .PHONY: build
    11  .PHONY: deps
    12  
    13  target: run-main
    14  all: run-main
    15  
    16  EXECUTABLES = git go pwd
    17  K := $(foreach exec,$(EXECUTABLES),\
    18          $(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
    19  
    20  GoPathX=$(shell echo $GOPATH)
    21  VERSION ?= $(shell git describe --tags `git rev-list --tags --max-count=1`)
    22  BINARY = cli
    23  MAIN = main.go
    24  
    25  BUILDDIR = build
    26  GITREV = $(shell git rev-parse --short HEAD)
    27  BUILDTIME = $(shell date +'%FT%TZ%z')
    28  GO_BUILDER_VERSION=latest
    29  
    30  run-main:
    31  	go run cmd/main/*.go
    32  
    33  run-server:
    34  	go run cmd/server/*.go
    35  
    36  run-client:
    37  	go run cmd/client/*.go
    38  
    39  run-sample:
    40  	go run cmd/sample/*.go
    41  
    42  build: export-current-binaries
    43  	go build -o $(shell pwd)/$(BUILDDIR)/$(BINARY) $(shell pwd)/$(MainDirectory)/*.go
    44  	@echo "Build $(BINARY) done."
    45  	@echo "Run \"$(shell pwd)/$(BUILDDIR)/$(BINARY)\" to start $(BINARY)."
    46  
    47  run:
    48  	$(shell pwd)/$(BUILDDIR)/$(BINARY)
    49  
    50  build-run: build run
    51  
    52  run-linux-docker:
    53  	cd scripts && sudo chmod +x ./docker-run-linux.sh
    54  	cd scripts && sudo sh ./docker-run-linux.sh
    55  
    56  run-direct:
    57  	"$(BinariesDirectory)/main"
    58  
    59  linux-run:
    60  	cd "$(BinariesDirectory)" && ./main
    61  
    62  run-tests:
    63  	cd tests && go test -v
    64  	
    65  cat-ssh:
    66  	cat ~/.ssh/id_rsa.pub
    67  
    68  ssh-sample:
    69  	echo "ssh-keygen -t rsa -b 4096 -C 'Your email'"
    70  	
    71  modify-authorized-keys:
    72  	sudo vim ~/.ssh/authorized_keys
    73  	
    74  git-clean-get:
    75  	git reset --hard
    76  	git clean -df
    77  	git status
    78  	git pull
    79  
    80  run-docker-build-linux:
    81  	./bin/cli-linux-amd64
    82  
    83  run-docker-build-windows:
    84  	./bin/cli-windows-amd64.exe
    85  
    86  export-private-key:
    87  	export PRIVATE_KEY=$(cat ~/.ssh/id_rsa | base64)
    88  
    89  export-go-version:
    90  	export GO_BUILDER_VERSION=$(GoVersion)
    91  
    92  export-current-binaries:
    93  	echo 'export PATH=$$PATH:$$PWD/bin'
    94  
    95  gopath-export:
    96  	export GOPATH="/root/go"
    97  
    98  all-exports: export-private-key export-go-version export-current-binaries gopath-export
    99  
   100  changelog:
   101  	git-chglog $(VERSION) > CHANGELOG.md
   102  
   103  debug: all-exports
   104      # Example : https://t.ly/pJiQ, https://t.ly/JEjg, https://t.ly/5Rre, https://goreleaser.com/install/
   105  	docker run --rm --privileged \
   106      		-e PRIVATE_KEY=$(PRIVATE_KEY) \
   107      		-v $PWD:/usr/src/$(MyApp) \
   108      		-v $GOPATH:/go \
   109      		-v /var/run/docker.sock:/var/run/docker.sock \
   110      		-w /usr/src/$(MyApp) \
   111      		ghcr.io/gythialy/golang-cross:$(GO_BUILDER_VERSION) --snapshot --rm-dist
   112  
   113  basic-snapshot:
   114  	cd scripts && sudo chmod +x ./docker-deploy.sh
   115  	cd scripts && sudo sh ./docker-deploy.sh
   116  
   117  snapshot: all-exports
   118      # Example : https://t.ly/pJiQ, https://t.ly/JEjg, https://t.ly/5Rre
   119  	docker run --rm -it --privileged \
   120  		-e PRIVATE_KEY=$(PRIVATE_KEY) \
   121  		-v $(CURDIR):/usr/src/myapp \
   122  		-v $(GOPATH):/go \
   123  		-v /var/run/docker.sock:/var/run/docker.sock \
   124  		-w /usr/src/myapp \
   125  		ghcr.io/gythialy/golang-cross:$(GO_BUILDER_VERSION) bash
   126  
   127  release: changelog
   128  	docker run --rm -it --privileged \
   129  		-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
   130  		-e PRIVATE_KEY=$(PRIVATE_KEY) \
   131  		-v $(CURDIR):/golang-cross-example \
   132  		-v /var/run/docker.sock:/var/run/docker.sock \
   133  		-v $(GOPATH)/src:/go/src \
   134  		-w /golang-cross-example \
   135  		ghcr.io/gythialy/golang-cross:$(GO_BUILDER_VERSION) --rm-dist --release-notes=CHANGELOG.md