Skip to content

Commit

Permalink
Circle-ci - Publish docker-image after release
Browse files Browse the repository at this point in the history
  • Loading branch information
gjeanmart committed Nov 20, 2018
1 parent 232c495 commit e39897a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ jobs:
name: Release Snapshot
command: mvn -s ./.circleci/.circleci.settings.xml -DskipTests deploy

release-docker-image:
machine: true
steps:
- checkout
- run:
name: maven install
command: mvn clean install -DskipTests
- run:
name: Release docker image
command: ./.scripts/build-docker-image.sh

release:
docker:
- image: circleci/openjdk:8u171-jdk
Expand Down Expand Up @@ -86,6 +97,12 @@ workflows:
filters:
branches:
only: master
- release-docker-image:
requires:
- build-and-test
filters:
branches:
only: master
- update-dev-branch:
requires:
- release
Expand Down
15 changes: 15 additions & 0 deletions scripts/build-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
GIT_COMMIT_DESC=$(git log --format=oneline -n 1 $CIRCLE_SHA1)
echo Git commit message: $GIT_COMMIT_DESC
echo Git PR Number: $CIRCLE_PR_NUMBER
if [[ "$GIT_COMMIT_DESC" != *"maven-release-plugin"* && "$CIRCLE_PR_NUMBER" == "" ]]; then
RELEASE_VERSION=$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec | sed 's/-SNAPSHOT//g')
echo building docker with version: ${RELEASE_VERSION}
set -e

docker login -u ${DOCKER_HUB_USER_ID} -p ${DOCKER_HUB_PWD}
docker build -t gjeanmart/ipfs-store:${RELEASE_VERSION} -f ipfs-store-service/Dockerfile ipfs-store-service/.
docker build -t gjeanmart/ipfs-store:latest -f ipfs-store-service/Dockerfile ipfs-store-service/.
docker push gjeanmart/ipfs-store:${RELEASE_VERSION}
docker push gjeanmart/ipfs-store:latest
fi

0 comments on commit e39897a

Please sign in to comment.