mktools/tasks/version.mk

37 lines
1.8 KiB
Makefile
Raw Permalink Normal View History

2023-08-24 20:41:11 +02:00
MKT_PROJECT_VERSION_TIMEZONE ?= Europe/Paris
MKT_PROJECT_VERSION_BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
MKT_PROJECT_VERSION_CLEANED_BRANCH_NAME ?= $(shell echo $(MKT_PROJECT_VERSION_BRANCH_NAME) | tr '[:upper:]' '[:lower:]' | sed -e 's/[-_ ]//g')
2023-08-24 20:41:11 +02:00
ifeq ($(MKT_PROJECT_VERSION_CLEANED_BRANCH_NAME),master)
MKT_PROJECT_VERSION_CHANNEL = stable
2023-08-24 20:41:11 +02:00
else ifeq ($(MKT_PROJECT_VERSION_CLEANED_BRANCH_NAME),staging)
MKT_PROJECT_VERSION_CHANNEL = testing
else
2023-08-24 20:41:11 +02:00
MKT_PROJECT_VERSION_CHANNEL = $(MKT_PROJECT_VERSION_CLEANED_BRANCH_NAME)
endif
2023-08-23 19:54:18 +02:00
ifeq ($(MKT_PROJECT_VERSION_CHANNEL),develop)
MKT_PROJECT_SHORT_VERSION_CHANNEL ?= dev
else ifneq ($(filter $(MKT_PROJECT_VERSION_CHANNEL),testing staging),)
2023-08-23 19:54:18 +02:00
MKT_PROJECT_SHORT_VERSION_CHANNEL ?= tst
else ifneq ($(filter $(MKT_PROJECT_VERSION_CHANNEL),stable master),)
2023-08-23 19:54:18 +02:00
MKT_PROJECT_SHORT_VERSION_CHANNEL ?= stb
else
MKT_PROJECT_SHORT_VERSION_CHANNEL ?= $(shell echo "$(MKT_PROJECT_VERSION_CHANNEL)" | sed -e 's/[aeiouy]//g' | cut -c1-3)
endif
MKT_PROJECT_VERSION_COMMIT_TIMESTAMP ?= $(shell git show -s --format=%ct)
2023-08-24 20:41:11 +02:00
MKT_PROJECT_VERSION_DATE ?= $(shell TZ=$(MKT_PROJECT_VERSION_TIMEZONE) date -d '@$(MKT_PROJECT_VERSION_COMMIT_TIMESTAMP)' +%Y.%-m.%-d)
MKT_PROJECT_VERSION_TIMESTAMP ?= $(shell TZ=$(MKT_PROJECT_VERSION_TIMEZONE) date -d '@$(MKT_PROJECT_VERSION_COMMIT_TIMESTAMP)' +%-H%M)
2023-08-23 19:54:18 +02:00
MKT_PROJECT_VERSION ?= $(MKT_PROJECT_VERSION_DATE)-$(MKT_PROJECT_VERSION_CHANNEL).$(MKT_PROJECT_VERSION_TIMESTAMP).$(shell git rev-parse --short HEAD)
MKT_PROJECT_SHORT_VERSION ?= $(MKT_PROJECT_VERSION_DATE)-$(MKT_PROJECT_SHORT_VERSION_CHANNEL).$(MKT_PROJECT_VERSION_TIMESTAMP)
.PHONY: mkt-project-version
mkt-project-version:
@echo $(MKT_PROJECT_VERSION)
.PHONY: mkt-project-short-version
mkt-project-short-version:
@echo $(MKT_PROJECT_SHORT_VERSION)