Configure for goreleaser

This commit is contained in:
2025-01-23 14:03:58 +01:00
parent a72eead432
commit 56adeaf1b8
3 changed files with 52 additions and 9 deletions

3
.gitignore vendored
View File

@ -29,4 +29,5 @@ go.work.sum
*.sqlite
# exclude built binary
web
web
dist/

44
.goreleaser.yaml Normal file
View File

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

View File

@ -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*
@rm -r dist/