From ae298bf4f0e73ce408d4a9dedcd3f0e145d4b1b3 Mon Sep 17 00:00:00 2001 From: wengchaoxi Date: Sun, 17 Mar 2024 22:10:49 +0800 Subject: [PATCH] Use goreleaser to release binary --- .dockerignore | 2 ++ .gitignore | 1 + .goreleaser.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 .goreleaser.yml diff --git a/.dockerignore b/.dockerignore index 952abad..41c6b10 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,5 @@ Dockerfile docker-compose.yml README.md .env +.goreleaser.yml +dist/ diff --git a/.gitignore b/.gitignore index 2e07a4f..887a3ee 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ go.work .env +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..b0e0989 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,49 @@ +version: 1 + +before: + hooks: + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + mod_timestamp: '{{ .CommitTimestamp }}' + flags: + - -trimpath + ldflags: + - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + - arm + goarm: + - 7 + binary: '{{ .ProjectName }}_v{{ .Version }}' + +archives: + - format: tar.gz + name_template: >- + {{ .ProjectName }}_ + v{{.Version}}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + format_overrides: + - goos: windows + format: zip + files: + - ./web + - LICENSE + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + - '^chore:'