diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 53d79bd..dcf3bdd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -25,8 +25,7 @@ jobs: - name: Build binary run: | - make build_linux_amd64 - make build_linux_arm64 + make build_docker - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/Makefile b/Makefile index 9f32239..4c05537 100644 --- a/Makefile +++ b/Makefile @@ -38,19 +38,25 @@ endif TAGS ?= LDFLAGS ?= -X 'main.Version=$(VERSION)' -all: build +.PHONY: help +help: ## Print this help message. + @echo "Usage: make [target]" + @echo "" + @echo "Targets:" + @echo "" + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -fmt: +fmt: ## Format the code @hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - $(GO) install mvdan.cc/gofumpt; \ + $(GO) install mvdan.cc/gofumpt@latest; \ fi $(GOFMT) -w $(GOFILES) -vet: +vet: ## Run go vet $(GO) vet ./... .PHONY: fmt-check -fmt-check: +fmt-check: ## Check if the code is formatted @hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ $(GO) install mvdan.cc/gofumpt; \ fi @@ -61,30 +67,22 @@ fmt-check: exit 1; \ fi; -test: +test: ## Run tests @$(GO) test -v -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1 -install: $(GOFILES) +install: $(GOFILES) ## Install the package $(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -build: $(EXECUTABLE) +build: $(EXECUTABLE) ## Build the package -$(EXECUTABLE): $(GOFILES) +$(EXECUTABLE): $(GOFILES) ## Build the package $(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o bin/$@ -build_linux_amd64: +build_docker: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/amd64/$(DEPLOY_IMAGE) - -build_linux_i386: - CGO_ENABLED=0 GOOS=linux GOARCH=386 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/i386/$(DEPLOY_IMAGE) - -build_linux_arm64: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm64/$(DEPLOY_IMAGE) -build_linux_arm: - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm/$(DEPLOY_IMAGE) - -ssh-server: +ssh-server: ## Run ssh server adduser -h /home/drone-scp -s /bin/sh -D -S drone-scp echo drone-scp:1234 | chpasswd mkdir -p /home/drone-scp/.ssh @@ -101,12 +99,6 @@ ssh-server: sed -i 's/^#ListenAddress ::/ListenAddress ::/g' /etc/ssh/sshd_config ./tests/entrypoint.sh /usr/sbin/sshd -D & -coverage: - sed -i '/main.go/d' coverage.txt - -clean: +clean: ## Clean the build $(GO) clean -x -i ./... - rm -rf coverage.txt $(EXECUTABLE) $(DIST) - -version: - @echo $(VERSION) + rm -rf coverage.txt $(EXECUTABLE)