-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
64 lines (53 loc) · 1.7 KB
/
makefile
File metadata and controls
64 lines (53 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Makefile for Go Library Release
PROJECT_NAME ?= $(shell basename "$(PWD)")
VERSION_FILE = VERSION
CHANGELOG_FILE = CHANGELOG.md
BUMP_SCRIPT = bump_version.sh
# Default target: Show help
.PHONY: help
help:
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@echo " help Show this help message"
@echo " init Initialize version file if it doesn't exist (v0.1.0)"
@echo " version Show current version"
@echo " bump-major Bump major version (e.g., v1.0.0)"
@echo " bump-minor Bump minor version (e.g., v0.2.0)"
@echo " bump-patch Bump patch version (e.g., v0.1.1)"
@echo " tag Create a new Git tag with the current version and update CHANGELOG"
@echo " push Push tags and commits to the remote repository"
@echo " update-repo Pull latest changes from the remote repository"
.PHONY: init
init:
ifeq ($(wildcard $(VERSION_FILE)),)
echo "v0.1.0" > $(VERSION_FILE)
@echo "Initialized $(VERSION_FILE) with v0.1.0"
endif
.PHONY: version
version:
@cat $(VERSION_FILE)
.PHONY: bump-major
bump-major:
$(BUMP_SCRIPT) major
.PHONY: bump-minor
bump-minor:
$(BUMP_SCRIPT) minor
.PHONY: bump-patch
bump-patch:
$(BUMP_SCRIPT) patch
.PHONY: tag
tag: version
current_version := $(shell cat $(VERSION_FILE))
git tag -a "$(current_version)" -m "Release $(current_version)"
git log --pretty=format:"- %ad: %s" --date=short $(shell git describe --tags --abbrev=0 HEAD^)..HEAD >> $(CHANGELOG_FILE)
@echo "Tagged version $(current_version) and updated $(CHANGELOG_FILE)"
.PHONY: push
push:
git push origin --tags
git push origin HEAD
.PHONY: update-repo
update-repo:
git pull origin $(shell git rev-parse --abbrev-ref HEAD)
# Default action is to show help
default: help