mirror of
https://github.com/mjsarfatti/beddu.git
synced 2025-06-26 17:08:01 +02:00
Semantic versioning in Make
This commit is contained in:
parent
35e895ca20
commit
698756ecb2
1 changed files with 21 additions and 2 deletions
23
Makefile
23
Makefile
|
@ -14,7 +14,7 @@ get_dir_files = $(wildcard $(1)*.sh)
|
|||
# Build ALL_SRC_FILES by including files from each subdirectory in order
|
||||
ALL_SRC_FILES = $(foreach dir,$(SUBDIRS),$(call get_dir_files,$(dir)))
|
||||
|
||||
.PHONY: all clean demo build release
|
||||
.PHONY: all clean demo build _release bump-patch bump-minor bump-major
|
||||
|
||||
all: $(OUTPUT)
|
||||
|
||||
|
@ -25,7 +25,7 @@ build:
|
|||
demo: build
|
||||
@./$(DEMO_DIR)/demo.sh
|
||||
|
||||
release:
|
||||
_release:
|
||||
@if [ -z "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
|
||||
echo "Error: Please specify a version number (e.g. make release v0.0.5)"; \
|
||||
exit 1; \
|
||||
|
@ -42,6 +42,25 @@ release:
|
|||
git tag -a "$(VERSION)" -m "Release $(VERSION)"
|
||||
@echo "\nRelease complete: \033[32m$(VERSION)\033[0m"
|
||||
|
||||
# Get the last version tag and increment the appropriate part
|
||||
release-patch:
|
||||
@LAST_VERSION=$$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"); \
|
||||
NEW_VERSION=$$(echo $$LAST_VERSION | awk -F. '{print $$1"."$$2"."$$3+1}'); \
|
||||
echo "Bumping patch version from $$LAST_VERSION to $$NEW_VERSION"; \
|
||||
$(MAKE) _release $$NEW_VERSION
|
||||
|
||||
release-minor:
|
||||
@LAST_VERSION=$$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"); \
|
||||
NEW_VERSION=$$(echo $$LAST_VERSION | awk -F. '{print $$1"."$$2+1".0"}'); \
|
||||
echo "Bumping minor version from $$LAST_VERSION to $$NEW_VERSION"; \
|
||||
$(MAKE) _release $$NEW_VERSION
|
||||
|
||||
release-major:
|
||||
@LAST_VERSION=$$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"); \
|
||||
NEW_VERSION=$$(echo $$LAST_VERSION | awk -F. '{print "v"$$2+1".0.0"}'); \
|
||||
echo "Bumping major version from $$LAST_VERSION to $$NEW_VERSION"; \
|
||||
$(MAKE) _release $$NEW_VERSION
|
||||
|
||||
%:
|
||||
@:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue