From 56adeaf1b881545d71123d7c6731c0ab41478f47 Mon Sep 17 00:00:00 2001 From: dylan Date: Thu, 23 Jan 2025 14:03:58 +0100 Subject: [PATCH] Configure for goreleaser --- .gitignore | 3 ++- .goreleaser.yaml | 44 ++++++++++++++++++++++++++++++++++++++++++++ Makefile | 14 ++++++-------- 3 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.gitignore b/.gitignore index 79b2244..a137ee0 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ go.work.sum *.sqlite # exclude built binary -web \ No newline at end of file +web +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..4a83677 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,44 @@ +version: 2 + +before: + hooks: + - go mod tidy + +builds: + - id: qv + main: ./cmd/web + binary: qv + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + goamd64: + - v1 + - v2 + - v3 + - v4 + goarm64: + - v8.0 + ldflags: + - -s -w + +archives: + - id: qv-archive + allow_different_binary_count: true + name_template: >- + {{ .ProjectName }}_ + {{- .Os }}_ + {{- .Arch }}_ + {{- if eq .Arch "amd64" }}{{ .Amd64 }} + {{- else if eq .Arch "arm64" }}{{ .Arm64 }} + {{- end }} + format: tar.gz + format_overrides: + - goos: windows + formats: [ "zip" ] + diff --git a/Makefile b/Makefile index d1f1136..4de3474 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,10 @@ -BINARY_NAME=qv -LD_FLAGS=-s -w - -.PHONY: compile clean +.PHONY: compile compile-snapshot clean compile: - GOOS=windows GOARCH=amd64 go build -ldflags="$(LD_FLAGS)" -o $(BINARY_NAME)-windows-amd64.exe ./cmd/web/ - GOOS=darwin GOARCH=amd64 go build -ldflags="$(LD_FLAGS)" -o $(BINARY_NAME)-darwin-amd64 ./cmd/web/ - GOOS=linux GOARCH=amd64 go build -ldflags="$(LD_FLAGS)" -o $(BINARY_NAME)-linux-amd64 ./cmd/web/ + @goreleaser release --clean --skip=publish + +compile-snapshot: + @goreleaser release --clean --skip=publish clean: - @rm $(BINARY_NAME)-*-amd64* \ No newline at end of file + @rm -r dist/ \ No newline at end of file