Skip to content

Instantly share code, notes, and snippets.

Last active August 12, 2020 01:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
make recipe to tag docker images with git tags
### example for setting up a make workflow that can tag images based on the git tag
### the trailing ; are important: runs the commands in the same "shell" and the $$tag variable flows through
@echo "Latest 3 tags: "; \
git ls-remote --sort='v:refname' --tags ./. | tail -n 3; \
read -p "Enter New Tag:" tag; \
echo "Releasing new tag: $$tag"; \
git tag $$tag; \
git push origin $$tag -f; \
docker build . -f Dockerfile \
-t foo:latest \
-t foo:$$tag;
@tag=$$(git ls-remote --sort='v:refname' --tags ./. | awk -F/ '{print $$3}' | tail -n 1); \
echo "Pushing tag: $$tag to docker"; \
docker push foo:latest; \
docker push foo:$$tag;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment