Skip to content

Instantly share code, notes, and snippets.

@pbatey
Created August 13, 2019 23:04
Show Gist options
  • Save pbatey/8bfc439a3526a0759d4248ac12f422a5 to your computer and use it in GitHub Desktop.
Save pbatey/8bfc439a3526a0759d4248ac12f422a5 to your computer and use it in GitHub Desktop.
Makefile that generates version.json from git
# 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