Skip to content

Commit 0b0ced5

Browse files
committed
add release to makefile
1 parent e438977 commit 0b0ced5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Diff for: Makefile

+29
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,32 @@ jarvis: $(BUILD_FILES)
1010
test:
1111
go test ./...
1212
.PHONY: test
13+
14+
# We use a trick to capture the second and subsequent words from the command line:
15+
# make release v0.0.33 "some text"
16+
#
17+
# - $(word 2, $(MAKECMDGOALS)) is the second “goal”: v0.0.33
18+
# - $(wordlist 3, ..., $(MAKECMDGOALS)) takes everything after the second goal,
19+
20+
VERSION := $(word 2, $(MAKECMDGOALS))
21+
RELEASE_TEXT := $(wordlist 3, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))
22+
23+
.PHONY: release
24+
release:
25+
@if [ -z "$(VERSION)" ]; then \
26+
echo "ERROR: Missing version. Usage: make release v0.0.33 \"Release text\""; \
27+
exit 1; \
28+
fi
29+
@if [ -z "$(RELEASE_TEXT)" ]; then \
30+
echo "ERROR: Missing release text. Usage: make release v0.0.33 \"Release text\""; \
31+
exit 1; \
32+
fi
33+
@echo "Tagging version: $(VERSION) with message: $(RELEASE_TEXT)"
34+
git tag -a "$(VERSION)" -m "$(RELEASE_TEXT)"
35+
# If you want to push the tag right away, un-comment the next line:
36+
# git push origin "$(VERSION)"
37+
goreleaser1.17 release --clean --skip-publish
38+
39+
# This is the "phony target" trick: any unknown goal (like v0.0.33) goes here
40+
%:
41+
@:

0 commit comments

Comments
 (0)