Skip to content

Commit 989fe1d

Browse files
committed
Makefile: add releases target
This target makes zipfile-based releases for the common platforms.
1 parent 368ed15 commit 989fe1d

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/.gopath
22
/bin
3+
/releases

Makefile

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ bin/git-sizer:
2626
# Cross-compile for a bunch of common platforms. Note that this
2727
# doesn't work with USE_ISATTY:
2828
.PHONY: common-platforms
29-
common-platforms: \
30-
bin/git-sizer-linux-amd64 \
31-
bin/git-sizer-linux-386 \
32-
bin/git-sizer-darwin-amd64 \
33-
bin/git-sizer-darwin-386 \
34-
bin/git-sizer-windows-amd64.exe \
35-
bin/git-sizer-windows-386.exe
29+
common-platforms:
30+
31+
# Create releases for a bunch of common platforms. Note that this
32+
# doesn't work with USE_ISATTY, and VERSION must be set on the command
33+
# line; e.g.,
34+
#
35+
# make releases VERSION=1.2.3
36+
.PHONY: releases
37+
releases:
3638

3739
# Define rules for a bunch of common platforms that are supported by go; see
3840
# https://golang.org/doc/install/source#environment
@@ -44,6 +46,20 @@ define PLATFORM_template =
4446
bin/git-sizer-$(1)-$(2)$(3):
4547
mkdir -p bin
4648
cd $$(GOPATH)/src/$$(PACKAGE) && GOOS=$(1) GOARCH=$(2) $$(GO) build $$(GOFLAGS) -o $$(ROOTDIR)/$$@ $$(PACKAGE)
49+
common-platforms: bin/git-sizer-$(1)-$(2)$(3)
50+
51+
# Note that releases don't include code from vendor (they're only used
52+
# for testing), so no license info is needed from those projects.
53+
.PHONY: releases/git-sizer-$$(VERSION)-$(1)-$(2).zip
54+
releases/git-sizer-$$(VERSION)-$(1)-$(2).zip: bin/git-sizer-$(1)-$(2)$(3)
55+
if test -z "$$(VERSION)"; then echo "Please set VERSION to make releases"; exit 1; fi
56+
mkdir -p releases/tmp-$$(VERSION)-$(1)-$(2)
57+
cp README.md LICENSE.md releases/tmp-$$(VERSION)-$(1)-$(2)
58+
cp bin/git-sizer-$(1)-$(2)$(3) releases/tmp-$$(VERSION)-$(1)-$(2)/git-sizer$(3)
59+
rm -f $$@
60+
zip -j $$@ releases/tmp-$$(VERSION)-$(1)-$(2)/*
61+
rm -rf releases/tmp-$$(VERSION)-$(1)-$(2)
62+
releases: releases/git-sizer-$$(VERSION)-$(1)-$(2).zip
4763
endef
4864

4965
$(eval $(call PLATFORM_template,linux,amd64))

0 commit comments

Comments
 (0)