diff --git a/.woodpecker.yml b/.woodpecker.yml index 7292217..4e85361 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -12,8 +12,11 @@ pipeline: build: image: *golang volumes: *volumes + environments: + BUILD_DIR: build commands: - - go build -o /artifacts/capture + - mkdir $BUILD_DIR + - make push_release: image: plugins/gitea-release @@ -23,7 +26,7 @@ pipeline: from_secret: gitnet_api_key base_url: https://gitnet.fr note: ${CI_COMMIT_MESSAGE} - files: /artifacts/capture + files: build/* when: event: [tag] diff --git a/Dockerfile b/Dockerfile index 90fe3e9..f125ef2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build -o /app/capture +RUN BUILD_DIR=/app make FROM debian:stable-slim diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8383bec --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +CGO_ENABLED = 0 +CC = go build +CFLAGS = -trimpath +LDFLAGS = all=-w -s +GCFLAGS = all= +ASMFLAGS = all= +GOARCH ?= amd64 + +BUILD_DIR ?= build +LINUX_BIN ?= capture +WIN_BIN ?= capture.exe + +all: build + +deps: + go install github.com/GeertJohan/go.rice/rice@latest + rice embed-go + +.PHONY: +build: deps + export CGO_ENABLED=$(CGO_ENABLED) + export GOARCH=$(GOARCH) + GOOS=linux $(CC) $(CFLAGS) -o $(BUILD_DIR)/$(LINUX_BIN) -ldflags="$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" + GOOS=windows $(CC) $(CFLAGS) -o $(BUILD_DIR)/$(WIN_BIN) -ldflags="$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)"