add multiple architectures builds

main
Simon Vieille 1 month ago
parent e0c8708f0d
commit 3a50ce717d
Signed by: deblan
GPG Key ID: 579388D585F70417
  1. 2
      .gitignore
  2. 2
      .woodpecker.yml
  3. 59
      Makefile
  4. 0
      build/.gitkeep

2
.gitignore vendored

@ -1 +1,3 @@
/bin/*
/build/*
!/build/.gitkeep

@ -16,6 +16,6 @@ pipeline:
from_secret: gitnet_api_key
base_url: https://gitnet.fr
note:
files: bin/mugo
files: build/mugo
when:
event: [tag]

@ -1,5 +1,60 @@
build: fmt
CGO_ENABLED=0 go build -ldflags '-s -w' -v -o bin/mugo ./src
CGO_ENABLED = 0
DIR = ./build
GOARCH = amd64
GOARM = arm64
GOOSWIN = windows
GOOSX = darwin
GOOSLINUX = linux
EXECUTABLE = mugo
WINBIN = $(DIR)/$(EXECUTABLE)-win-$(GOARCH).exe
OSXBIN = $(DIR)/$(EXECUTABLE)-darwin-$(GOARCH)
LINUXBIN = $(DIR)/$(EXECUTABLE)-linux-$(GOARCH)
ARMBIN = $(DIR)/$(EXECUTABLE)-linux-$(GOARM)
CC = go build
CFLAGS = -trimpath
LDFLAGS = all=-w -s
GCFLAGS = all=
ASMFLAGS = all=
.PHONY: all
all: darwin linux win64 arm
.PHONY: linux
linux: $(LINUXBIN)
chmod +x $(LINUXBIN)
.PHONY: arm
arm: $(ARMBIN)
chmod +x $(ARMBIN)
.PHONY: darwin
darwin: $(OSXBIN)
chmod +x $(OSXBIN)
.PHONY: win64
win64: $(WINBIN)
.PHONY: $(OSXBIN)
$(OSXBIN):
GO111MODULE=$(GOMOD) GOARCH=$(GOARCH) GOOS=$(GOOSX) CGO_ENABLED=$(CGO_ENABLED) $(CC) $(CFLAGS) -o $(OSXBIN) -ldflags="$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" ./src
.PHONY: $(ARMBIN)
$(ARMBIN):
GO111MODULE=$(GOMOD) GOARCH=$(GOARCH) GOOS=$(GOOSLINUX) CGO_ENABLED=$(CGO_ENABLED) $(CC) $(CFLAGS) -o $(ARMBIN) -ldflags="$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" ./src
.PHONY: $(LINUXBIN)
$(LINUXBIN):
GO111MODULE=$(GOMOD) GOARCH=$(GOARCH) GOOS=$(GOOSLINUX) CGO_ENABLED=$(CGO_ENABLED) $(CC) $(CFLAGS) -o $(LINUXBIN) -ldflags="$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" ./src
.PHONY: $(WINBIN)
$(WINBIN):
GO111MODULE=$(GOMOD) GOARCH=$(GOARCH) GOOS=$(GOOSWIN) CGO_ENABLED=$(CGO_ENABLED) $(CC) $(CFLAGS) -o $(WINBIN) -ldflags="$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" ./src
.PHONY: clean
clean:
rm -rf $(DIR)/*
tool-gofumpt:
which golangci-lint > /dev/null 2>&1 || go install mvdan.cc/gofumpt@latest

Loading…
Cancel
Save