Skip to content

Instantly share code, notes, and snippets.

@marcosricardoss
Last active March 12, 2021 13:11
Show Gist options
  • Save marcosricardoss/b2dd365db40c47ee9e5e6a61d8431d8f to your computer and use it in GitHub Desktop.
Save marcosricardoss/b2dd365db40c47ee9e5e6a61d8431d8f to your computer and use it in GitHub Desktop.
Publishing a docker image according git tags
#!/usr/bin/env bash
# docker hub username
USERNAME=marcosricardoss
# image name
IMAGE=helloworld
docker build -t $USERNAME/$IMAGE:latest .
# make it executable with chmod a+x ./build.sh
#!/usr/bin/env bash
# docker login
docker login
# docker hub username
USERNAME=marcosricardoss
# image names
IMAGE=helloworld
# getting the last git tag
version=`git tag --sort=taggerdate | grep "" | tail -1`
# creating a tag of the latest current image with the last git tag found
docker tag $USERNAME/$IMAGE:latest $USERNAME/$IMAGE:$version
# push
docker push $USERNAME/$IMAGE:latest
docker push $USERNAME/$IMAGE:$version
# make it executable with chmod a+x ./release.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment