From 7e50fdbbbf73511cb199025d18c2183893892a48 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 8 Aug 2020 13:21:23 -0400 Subject: [PATCH] Rewrite the Makefile to create release archives. --- .gitignore | 4 ++-- Makefile | 23 +++++++++++++++++++---- mailpopbox.go | 6 ------ version.go | 13 +++++++++++++ 4 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 version.go diff --git a/.gitignore b/.gitignore index 5000e08..d514169 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ config.json cover.html cover.out mailpopbox -mailpopbox-linux-amd64 -mailpopbox-mac-amd64 +mailpopbox-*-linux-amd64.zip +mailpopbox-*-mac-amd64.zip diff --git a/Makefile b/Makefile index 65608a7..bb32822 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,32 @@ .PHONY: -all: coverage mac linux +all: coverage linux mac DIRTY=$(shell [[ -z `git status --untracked-files=no --porcelain` ]] || echo "-dirty") GITHASH=$(shell git log --pretty='%H' -1) - LDFLAG=-ldflags "-X 'main.versionGit=$(GITHASH)$(DIRTY)'" +VERSION=$(shell sed -n -E -e 's/[[:space:]]*versionNumber = "(.*)"/\1/p' version.go) +PKG_BASE=mailpopbox-$(VERSION) + +DOCS_FILES=README.md docs/install.md + coverage: go test -coverprofile ./cover.out ./... go tool cover -html=cover.out -o cover.html mac: - GOOS=darwin GOARCH=amd64 go build -o mailpopbox-mac-amd64 $(LDFLAG) + GOOS=darwin GOARCH=amd64 go build $(LDFLAG) + mkdir $(PKG_BASE) + cp mailpopbox $(PKG_BASE) + cp $(DOCS_FILES) $(PKG_BASE) + zip -r $(PKG_BASE)-mac-amd64.zip $(PKG_BASE) + rm -rf $(PKG_BASE) linux: - GOOS=linux GOARCH=amd64 go build -o mailpopbox-linux-amd64 $(LDFLAG) + GOOS=linux GOARCH=amd64 go build $(LDFLAG) + mkdir $(PKG_BASE) + cp mailpopbox $(PKG_BASE) + cp deployment/mailpopbox.service $(PKG_BASE) + cp $(DOCS_FILES) $(PKG_BASE) + zip -r $(PKG_BASE)-linux-amd64.zip $(PKG_BASE) + rm -rf $(PKG_BASE) diff --git a/mailpopbox.go b/mailpopbox.go index af2c369..62bbf71 100644 --- a/mailpopbox.go +++ b/mailpopbox.go @@ -14,12 +14,6 @@ import ( "go.uber.org/zap" ) -var ( - versionGit = "development" - versionNumber = "2.0.0" - versionString = "mailpopbox " + versionNumber + " (" + versionGit + ")\n" -) - func main() { if len(os.Args) != 2 { fmt.Fprintf(os.Stderr, "Usage: %s config.json\n", os.Args[0]) diff --git a/version.go b/version.go new file mode 100644 index 0000000..808e277 --- /dev/null +++ b/version.go @@ -0,0 +1,13 @@ +// mailpopbox +// Copyright 2020 Blue Static +// This program is free software licensed under the GNU General Public License, +// version 3.0. The full text of the license can be found in LICENSE.txt. +// SPDX-License-Identifier: GPL-3.0-only + +package main + +var ( + versionGit = "development" + versionNumber = "2.0.0" + versionString = "mailpopbox " + versionNumber + " (" + versionGit + ")\n" +) -- 2.43.5