Skip to content

Instantly share code, notes, and snippets.

@gemmadlou
Last active April 5, 2020 09:37
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 gemmadlou/da9b5ca3b5459f3c02ce5792772c4854 to your computer and use it in GitHub Desktop.
Save gemmadlou/da9b5ca3b5459f3c02ce5792772c4854 to your computer and use it in GitHub Desktop.
Auto docker image release
{
"plugins": [
"git-tag",
"conventional-commits",
[
"exec",
{
"afterVersion": "publish"
}
]
],
"owner": "gemmadlou",
"repo": "my-repo",
"name": "Gemma Black",
"email": "gblackuk@googlemail.com"
}
#!/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