github.com/sharovik/devbot@v1.0.1-0.20240308094637-4a0387c40516/Makefile (about) 1 BIN_DIR=bin 2 PROJECT_BUILD_DIR=project-build 3 4 DICTIONARY_SCRIPT_DIR=scripts/dictionary-loader 5 INSTALL_SCRIPT_DIR=scripts/install 6 UPDATE_SCRIPT_DIR=scripts/update 7 8 PROJECT_BUILD_SCRIPTS_DIR=$(PROJECT_BUILD_DIR)/scripts 9 PROJECT_BUILD_SCRIPTS_INSTALL_DIR=$(PROJECT_BUILD_DIR)/$(INSTALL_SCRIPT_DIR) 10 PROJECT_BUILD_SCRIPTS_UPDATE_DIR=$(PROJECT_BUILD_DIR)/$(UPDATE_SCRIPT_DIR) 11 PROJECT_BUILD_SCRIPTS_DICTIONARY_DIR=$(PROJECT_BUILD_DIR)/$(DICTIONARY_SCRIPT_DIR) 12 13 CMD:=$(patsubst cmd/%/main.go,%,$(shell find cmd -type f -name 'main.go')) 14 LDFLAGS=-ldflags="-s -w" 15 16 install-vendors: 17 go mod vendor 18 19 build-devbot-cross-platform: 20 env CGO_ENABLED=1 xgo --targets=darwin/*,linux/amd64,linux/386,windows/* --dest ./$(PROJECT_BUILD_DIR)/$(BIN_DIR)/ --out devbot ./cmd/devbot 21 22 build-devbot-for-current-system: 23 env CGO_ENABLED=1 go build -o ./bin/devbot-current-system ./cmd/devbot/main.go 24 25 code-check: 26 make lint 27 env APP_ENV="testing" make tests 28 29 code-clean: 30 make imports 31 make format 32 33 lint: 34 go install honnef.co/go/tools/cmd/staticcheck@latest 35 staticcheck ./events/... 36 staticcheck ./cmd/... 37 staticcheck ./internal/... 38 39 imports: 40 goimports -d -w $(shell find . -type f -name '*.go' -not -path "./vendor/*") 41 42 format: 43 go fmt $(shell go list ./... | grep -v /vendor/) 44 45 tests: 46 go test ./... 47 48 create-if-not-exists-defined-events: 49 if [ ! -f events/defined-events.go ]; then cp events/defined-events.go.dist events/defined-events.go; fi 50 51 tf-container-definition: 52 if [ ! -f terraform/local.container_definition.tf ]; then cp terraform/local.container_definition.tf.dist terraform/local.container_definition.tf; fi 53 54 create-if-not-exists-env: 55 if [ ! -f .env ]; then cp .env.example .env; fi 56 57 install: 58 make create-missing-files 59 make build-installation-script-for-current-system 60 ./scripts/install/run 61 62 update: 63 make build-update-script-for-current-system 64 make run-update 65 66 run-update: 67 ./scripts/update/run 68 69 create-project-build-dirs: 70 if [[ ! -d $(PROJECT_BUILD_DIR) ]]; then mkdir $(PROJECT_BUILD_DIR); fi 71 if [[ ! -d $(PROJECT_BUILD_SCRIPTS_DIR) ]]; then mkdir $(PROJECT_BUILD_SCRIPTS_DIR); fi 72 if [[ ! -d $(PROJECT_BUILD_SCRIPTS_INSTALL_DIR) ]]; then mkdir $(PROJECT_BUILD_SCRIPTS_INSTALL_DIR); fi 73 if [[ ! -d $(PROJECT_BUILD_SCRIPTS_UPDATE_DIR) ]]; then mkdir $(PROJECT_BUILD_SCRIPTS_UPDATE_DIR); fi 74 75 build-installation-script: 76 env CGO_ENABLED=1 xgo --targets=darwin/*,linux/amd64,linux/386,windows/* --dest ./$(PROJECT_BUILD_SCRIPTS_INSTALL_DIR) --out install ./$(INSTALL_SCRIPT_DIR) 77 78 build-installation-script-for-current-system: 79 go build -o $(INSTALL_SCRIPT_DIR)/run $(INSTALL_SCRIPT_DIR)/main.go 80 81 build-dictionary-script: 82 env CGO_ENABLED=1 xgo --targets=darwin/*,linux/amd64,linux/386,windows/* --dest ./$(PROJECT_BUILD_SCRIPTS_INSTALL_DIR) --out install ./$(DICTIONARY_SCRIPT_DIR) 83 84 build-dictionary-script-for-current-system: 85 go build -o $(DICTIONARY_SCRIPT_DIR)/run $(DICTIONARY_SCRIPT_DIR)/main.go 86 87 build-update-script: 88 env CGO_ENABLED=1 xgo --targets=darwin/*,linux/amd64,linux/386,windows/* --dest ./$(PROJECT_BUILD_SCRIPTS_UPDATE_DIR) --out update ./$(UPDATE_SCRIPT_DIR) 89 90 build-update-script-for-current-system: 91 go build -o $(UPDATE_SCRIPT_DIR)/run $(UPDATE_SCRIPT_DIR)/main.go 92 93 build-project-archive: 94 tar -czvf $(PROJECT_BUILD_DIR)/devbot.tar.gz $(PROJECT_BUILD_DIR) 95 96 prepare-release: 97 make build-project-cross-platform 98 cp -R $(INSTALL_SCRIPT_DIR)/database $(PROJECT_BUILD_SCRIPTS_INSTALL_DIR)/database 99 cp -R $(UPDATE_SCRIPT_DIR)/migrations $(PROJECT_BUILD_SCRIPTS_UPDATE_DIR)/migrations 100 cp .env.example $(PROJECT_BUILD_DIR)/.env 101 cp .env.example $(PROJECT_BUILD_DIR)/.env.example 102 make build-project-archive 103 104 build: 105 make install 106 make update 107 make build-devbot-for-current-system 108 109 refresh-events: 110 ./scripts/project-tools/update-events.sh 111 112 create-missing-files: 113 make create-if-not-exists-defined-events 114 make create-if-not-exists-env 115 116 build-project-cross-platform: 117 make create-missing-files 118 make build-devbot-cross-platform 119 make build-installation-script 120 make build-update-script 121 122 cleanup: 123 rm -rf vendor terraform scripts internal events documentation cmd 124 125 check-security: 126 go install golang.org/x/vuln/cmd/govulncheck@latest 127 govulncheck ./...