Last active
April 5, 2020 09:37
-
-
Save gemmadlou/da9b5ca3b5459f3c02ce5792772c4854 to your computer and use it in GitHub Desktop.
Auto docker image release
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
{ | |
"plugins": [ | |
"git-tag", | |
"conventional-commits", | |
[ | |
"exec", | |
{ | |
"afterVersion": "publish" | |
} | |
] | |
], | |
"owner": "gemmadlou", | |
"repo": "my-repo", | |
"name": "Gemma Black", | |
"email": "gblackuk@googlemail.com" | |
} |
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
#!/bin/bash | |
# Get directory | |
# https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself#answer-246128 | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
# Get latest tag | |
# https://gist.github.com/rponte/fdc0724dd984088606b0 | |
LATEST_TAG=`git tag | sort -V | tail -1` | |
# Get version without `v` at the beginning | |
PLAIN_VERSION=`echo $LATEST_TAG | cut -d "v" -f 2` | |
# Create container version | |
CONTAINER_TAG=myrepo:prefix-${PLAIN_VERSION} | |
# Go into project root | |
cd $DIR && cd .. | |
# Build docker container | |
docker build --tag gemmablack/${CONTAINER_TAG} . | |
# Publish new container | |
docker push gemmablack/$CONTAINER_TAG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment