Last active
August 12, 2020 01:49
-
-
Save urjitbhatia/f5bedaac3373da3f390f05eea0abdd04 to your computer and use it in GitHub Desktop.
make recipe to tag docker images with git tags
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
### 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 | |
docker-build: | |
@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; | |
docker-push: | |
@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