Skip to content

Instantly share code, notes, and snippets.

@rothwerx
Created June 15, 2022 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rothwerx/7bdc7946402f6746468f412e678a72a7 to your computer and use it in GitHub Desktop.
Save rothwerx/7bdc7946402f6746468f412e678a72a7 to your computer and use it in GitHub Desktop.
Makefile: auto-incrementing
IMAGE_NAME := whatever/whatever
.PHONY: docker-build version-increment bc-check
docker-build: version-increment
DOCKER_BUILDKIT=1 docker buildx build -t $(IMAGE_NAME):v$(shell cat version.txt) .
version-increment: bc-check
bc <<< "1 + $(shell cat version.txt)" > version.txt
bc-check:
@command -v bc >/dev/null 2>&1 || { echo >&2 "I require bc but it's not installed. Aborting."; exit 1; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment