mirror of
https://github.com/Warky-Devs/go-mdtopdf-helper.git
synced 2026-11-25 13:48:47 +00:00
This commit is contained in:
1 parent
5bf9c3673d
commit
b2d6ebd382
1 file changed
+28
-1
@@ -4,7 +4,7 @@ BIN_DIR := bin
|
|||||||
CMD := ./cmd/go-mdtopdf-helper
|
CMD := ./cmd/go-mdtopdf-helper
|
||||||
TOMD_CMD := ./cmd/go-tomd
|
TOMD_CMD := ./cmd/go-tomd
|
||||||
|
|
||||||
.PHONY: all build run run-tomd test lint format clean
|
.PHONY: all build run run-tomd test lint format clean release-version
|
||||||
|
|
||||||
all: format lint test build
|
all: format lint test build
|
||||||
|
|
||||||
@@ -29,3 +29,30 @@ format:
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BIN_DIR)
|
rm -rf $(BIN_DIR)
|
||||||
|
|
||||||
|
# Bump the latest vMAJOR.MINOR.PATCH tag and push the new tag, which triggers the release workflow.
|
||||||
|
# make release-version patch bump (v1.0.0 -> v1.0.1)
|
||||||
|
# make release-version BUMP=minor minor bump (v1.0.1 -> v1.1.0)
|
||||||
|
# make release-version BUMP=major major bump (v1.1.0 -> v2.0.0)
|
||||||
|
# make release-version DRY_RUN=1 show the next version without tagging or pushing
|
||||||
|
BUMP ?= patch
|
||||||
|
release-version:
|
||||||
|
@set -e; \
|
||||||
|
case "$(BUMP)" in patch|minor|major) ;; *) echo "BUMP must be patch, minor or major (got '$(BUMP)')" >&2; exit 1;; esac; \
|
||||||
|
git fetch --tags --quiet; \
|
||||||
|
latest=$$(git tag --list 'v*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$' | head -n1 || true); \
|
||||||
|
latest=$${latest:-v0.0.0}; \
|
||||||
|
ver=$${latest#v}; major=$${ver%%.*}; rest=$${ver#*.}; minor=$${rest%%.*}; patch=$${rest#*.}; \
|
||||||
|
case "$(BUMP)" in \
|
||||||
|
major) major=$$((major + 1)); minor=0; patch=0;; \
|
||||||
|
minor) minor=$$((minor + 1)); patch=0;; \
|
||||||
|
patch) patch=$$((patch + 1));; \
|
||||||
|
esac; \
|
||||||
|
next="v$$major.$$minor.$$patch"; \
|
||||||
|
echo "Latest tag: $$latest -> next: $$next"; \
|
||||||
|
if [ -n "$(DRY_RUN)" ]; then echo "Dry run: nothing tagged or pushed"; exit 0; fi; \
|
||||||
|
if [ -n "$$(git status --porcelain)" ]; then echo "Working tree is not clean; commit or stash first" >&2; exit 1; fi; \
|
||||||
|
if [ -n "$$(git rev-list '@{u}..HEAD' 2>/dev/null)" ]; then echo "HEAD has unpushed commits; push them first" >&2; exit 1; fi; \
|
||||||
|
git tag -a "$$next" -m "Release $$next"; \
|
||||||
|
git push origin "$$next"; \
|
||||||
|
echo "Pushed $$next"
|
||||||
Reference in new issue
Block a user