Files
.pouch/skills/builder/scripts/version.mk
T
2026-08-25 15:26:29 +08:00

40 lines
1.4 KiB
Makefile

# Include from a project Makefile. Sets VERSION (canonical, no leading v)
# and IMAGE_TAG (Docker rendering) via builder version.sh.
#
# Command-line / environment VERSION= is passed as --version (official X.Y.Z
# only when HEAD exact-matches that tag). Unset or empty VERSION is derived.
#
# include $(HOME)/.skills/skills/builder/scripts/version.mk
_builder_scripts_dir := $(dir $(lastword $(MAKEFILE_LIST)))
ifeq ($(BUILDER_VERSION_SH),)
BUILDER_VERSION_SH := $(wildcard $(_builder_scripts_dir)version.sh)
endif
ifeq ($(BUILDER_VERSION_SH),)
ifneq ($(BUILDER_SKILL_DIR),)
BUILDER_VERSION_SH := $(wildcard $(BUILDER_SKILL_DIR)/scripts/version.sh)
endif
endif
ifeq ($(BUILDER_VERSION_SH),)
BUILDER_VERSION_SH := $(wildcard $(HOME)/.skills/skills/builder/scripts/version.sh)
endif
ifeq ($(BUILDER_VERSION_SH),)
$(error version.sh not found; set BUILDER_SKILL_DIR or clone skills to ~/.skills)
endif
ifeq ($(filter command line environment,$(origin VERSION)),)
VERSION := $(shell "$(BUILDER_VERSION_SH)")
else ifeq ($(strip $(VERSION)),)
VERSION := $(shell "$(BUILDER_VERSION_SH)")
else
VERSION := $(shell "$(BUILDER_VERSION_SH)" --version "$(VERSION)")
endif
ifeq ($(strip $(VERSION)),)
$(error version.sh produced an empty version)
endif
ifeq ($(origin IMAGE_TAG),undefined)
IMAGE_TAG := $(shell "$(BUILDER_VERSION_SH)" --docker --version "$(VERSION)")
endif