diff --git a/.travis.yml b/.travis.yml index f5c05b43..05980660 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,8 @@ notifications: email: false jdk: - openjdk8 +services: + - docker addons: sonarcloud: organization: project-xavier @@ -18,3 +20,12 @@ jobs: - mvn test -DtestLogRootLevel=warn -Pcoverage - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then sonar-scanner; fi' - bash <(curl -s https://codecov.io/bash) + - stage: Release + script: + - ./.travis/release.sh + deploy: + provider: releases + api_key: $GITHUB_OAUTH_TOKEN + skip_cleanup: true + on: + tags: true diff --git a/.travis/release.sh b/.travis/release.sh new file mode 100755 index 00000000..bd15ab53 --- /dev/null +++ b/.travis/release.sh @@ -0,0 +1,22 @@ +#!/bin/bash +if [ -n "$TRAVIS_TAG" ]; then + # We can choose eithe follow this block of commands to download the image without authentication in Red Hat Registry + # Or we can create a Registry Service Account and login here + docker pull registry.access.redhat.com/fuse7/fuse-java-openshift + docker tag registry.access.redhat.com/fuse7/fuse-java-openshift:latest fuse7/fuse-java-openshift:latest + docker tag registry.access.redhat.com/fuse7/fuse-java-openshift:latest fuse7/fuse-java-openshift:1.3 # fabric8 use this specific version + + # Build image + mvn fabric8:build -Dfabric8.mode=kubernetes + + # Tag Docker image + docker tag xavier/xavier-integration:"$TRAVIS_TAG" projectxavier/xavier-integration:latest + docker tag xavier/xavier-integration:"$TRAVIS_TAG" projectxavier/xavier-integration:"$TRAVIS_TAG" + + # Docker Hub login + docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; + + # Docker push + docker push projectxavier/xavier-integration:latest + docker push projectxavier/xavier-integration:"$TRAVIS_TAG" +fi diff --git a/release.sh b/release.sh new file mode 100755 index 00000000..f2e0b8e9 --- /dev/null +++ b/release.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +echo "====================================" +read -p "Enter Release: " releaseVersion +read -p "Enter Next Release (SNAPSHOT): " nextVersion +read -p "Enter Github Username: " username +read -s -p "Enter Github Password: " password + +# Update to release +mvn versions:set -DnewVersion="$releaseVersion" + +git add . +git commit -m "Release $releaseVersion" +git push "https://$username:$password@github.com/project-xavier/xavier-integration.git" + +# Create tag and push +git tag "$releaseVersion" +git push "https://$username:$password@github.com/project-xavier/xavier-integration.git" --tags + +# Create next snapshot +mvn versions:set -DnewVersion="$nextVersion-SNAPSHOT" + +git add . +git commit -m "Prepare next release $nextVersion-SNAPSHOT" +git push "https://$username:$password@github.com/project-xavier/xavier-integration.git"