Last active
May 9, 2026 20:09
-
-
Save jakzal/aa884c124eac90aa1570efc5f9fc1eb6 to your computer and use it in GitHub Desktop.
Generate a project version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Versioning rules: | |
| # - tagged commit -> <semver> -> 1.2.3 | |
| # - commit after tag -> <semver>.<commit-count-since-tag>-<shortsha> -> 1.2.3.133-f6101c9 | |
| # - no tags yet -> 0.0.0.<commit-count>-<shortsha> -> 0.0.0.133-f6101c9 | |
| VERSION ?= $(shell git describe --tags --always --long 2>/dev/null | sed -E 's/-0-g.*//;s/-(.*)-g/.\1-/;s/^[0-9a-f]+$$/0.0.0.'$(shell git rev-list --count HEAD)'-&/') | |
| version: ## Generates the current project version | |
| @echo $(VERSION) | |
| .PHONY: version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment