Created
August 13, 2019 23:04
-
-
Save pbatey/8bfc439a3526a0759d4248ac12f422a5 to your computer and use it in GitHub Desktop.
Makefile that generates version.json from git
This file contains 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
# get version info from git (look for tag like 'v1.0') | |
GIT_VERSION = $(shell git describe --match "v[0-9]*") | |
GIT_BUILD = $(shell git describe --match "v[0-9]*" --long --dirty) | |
GIT_COMMIT = $(shell git rev-parse --short HEAD) | |
GIT_COMMIT_LONG = $(shell git rev-parse HEAD) | |
define VERSION_BODY | |
# this file generated by build process | |
{ | |
"version": "${GIT_VERSION}", | |
"build": "${GIT_BUILD}", | |
"commit": "${GIT_COMMIT}", | |
"commit_long": "${GIT_COMMIT_LONG}" | |
} | |
endef | |
export VERSION_BODY | |
version.json: | |
echo "$$VERSION_BODY" > $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment