From 8b4d38e017f8edc8cd8e48ff85d6666d25c28881 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Sun, 26 Nov 2023 22:30:25 -0600 Subject: [PATCH] Using goreleaser to build binaries --- .goreleaser.yaml | 53 +++++++++++++++++++++++++++++++++++++++++++ Makefile | 59 +++--------------------------------------------- 2 files changed, 56 insertions(+), 56 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..1aaf22a --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,53 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +version: 1 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + # - go generate ./... + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + ignore: + - goos: windows + goarch: 386 + + main: ./cmd/we + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +release: + github: + owner: ionrock + name: we + + prerelease: auto + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/Makefile b/Makefile index 47d9cd9..dd0b7d9 100644 --- a/Makefile +++ b/Makefile @@ -41,59 +41,6 @@ $(BINDIR): mkdir -p build -### Release / deploy targets -GH_RELEASE=$(GOPATH)/bin/github-release -UPLOAD_CMD = ./we -e .release.yml $(GH_RELEASE) upload -t $(LAST_TAG) -n $(subst /,-,$(FILE)) -f $(FILE) - -OSLIST = darwin freebsd linux -PLATS = amd64 - -EXE_TMPL = bin/$(OS)-$(PLAT)-$(EXECUTABLE) -EXE_TMPL_BZ2 = $(FN).tar.bz2 - -UNIX_EXECUTABLES = $(foreach OS,$(OSLIST),$(foreach PLAT,$(PLATS),$(EXE_TMPL))) -WIN_EXECUTABLES = bin/windows-amd64-$(EXECUTABLE).exe - -COMPRESSED_EXECUTABLES = $(UNIX_EXECUTABLES:%=%.tar.bz2) $(WIN_EXECUTABLES).zip -COMPRESSED_EXECUTABLE_TARGETS = $(COMPRESSED_EXECUTABLES:%=%) - -all: $(UNIX_EXECUTABLES) $(WIN_EXECUTABLES) - -compress-all: $(COMPRESSED_EXECUTABLES) - -# compressed artifacts, makes a huge difference (Go executable is ~9MB, -# after compressing ~2MB) -%.tar.bz2: % - tar -jcvf "$<.tar.bz2" "$<" -%.exe.zip: %.exe - zip "$@" "$<" - -# amd64 -bin/freebsd-amd64-$(EXECUTABLE): $(GLIDE) $(SOURCES) - GOARCH=amd64 GOOS=freebsd go build $(LDFLAGS) -o "$@" $(WEPKG) -bin/darwin-amd64-$(EXECUTABLE): $(GLIDE) $(SOURCES) - GOARCH=amd64 GOOS=darwin go build $(LDFLAGS) -o "$@" $(WEPKG) -bin/linux-amd64-$(EXECUTABLE): $(GLIDE) $(SOURCES) - GOARCH=amd64 GOOS=linux go build $(LDFLAGS) -o "$@" $(WEPKG) - -bin/windows-amd64-$(EXECUTABLE).exe: $(GLIDE) $(SOURCES) - GOARCH=amd64 GOOS=windows go build $(LDFLAGS) -o "$@" $(WEPKG) - - -$(GH_RELEASE): - go get github.com/aktau/github-release - go install github.com/aktau/github-release - -release: $(GH_RELEASE) $(EXECUTABLE) $(COMPRESSED_EXECUTABLES) - @echo "All targets $(COMPRESSED_EXECUTABLES)" - ./we -e .release.yml $(GH_RELEASE) release -t $(LAST_TAG) -n $(LAST_TAG) || true - $(foreach FILE,$(COMPRESSED_EXECUTABLES),$(UPLOAD_CMD);) - -$(BUMP): - virtualenv $(VENV) - $(VENV)/bin/pip install --upgrade pip - $(VENV)/bin/pip install bumpversion - -bump: $(BUMP) - $(VENV)/bin/bumpversion $(BUMPTYPE) - git push && git push --tags +.PHONY: goreleaser +goreleaser: + go install github.com/goreleaser/goreleaser@latest