add makefile
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

update build params
This commit is contained in:
Simon Vieille 2023-08-03 15:09:12 +02:00
parent cf97958081
commit bd0781aec7
Signed by: deblan
GPG key ID: 579388D585F70417
3 changed files with 30 additions and 3 deletions

View file

@ -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]

View file

@ -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

24
Makefile Normal file
View file

@ -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)"