diff --git a/.travis.yml b/.travis.yml index 38467c32b4..2ff8db514f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,17 +3,11 @@ language: java dist: xenial jdk: - - openjdk8 +- openjdk8 notifications: email: true -env: - global: - - MVN_ARGS="--settings build/.travis.settings.xml" - - BINTRAY_ORG=ibm-cloud-sdks - - BINTRAY_REPO=vpc-java-sdk - branches: except: - gh-pages @@ -22,63 +16,65 @@ cache: directories: - "$HOME/.m2" +env: + global: + - MVN_ARGS="--settings build/.travis.settings.xml" + +stages: + - name: Build-Test + - name: Semantic-Release + if: branch = main AND type = push AND fork = false + - name: Publish-Release + if: tag IS present before_install: -- sudo apt-get update -- sudo apt-get install python -- nvm install 12 -- npm install -g npm@6.x -- >- - [ -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ] - && openssl aes-256-cbc -K $encrypted_9d748cee9f61_key -iv $encrypted_9d748cee9f61_iv -in vpc.env.enc -out vpc.env -d - || true -install: -- curl -s https://codecov.io/bash > $HOME/codecov-bash.sh && chmod +x $HOME/codecov-bash.sh + - sudo apt-get update + - env | grep TRAVIS -before_script: -- echo "TRAVIS_TAG = '${TRAVIS_TAG}'" -- >- - [ -n "${TRAVIS_TAG}" ] - && mvn versions:set -DnewVersion=${TRAVIS_TAG} -DgenerateBackupPoms=false - || true -script: -- mvn clean verify -DskipITs $MVN_ARGS +jobs: + include: + - stage: Build-Test + jdk: openjdk8 + install: + - curl -s https://codecov.io/bash > $HOME/codecov-bash.sh && chmod +x $HOME/codecov-bash.sh + script: + - build/setMavenVersion.sh + - mvn verify -fae -DskipITs $MVN_ARGS + after_success: + - build/publishCodeCoverage.sh -before_deploy: -- pip install --user bump2version -- npm install @semantic-release/changelog -- npm install @semantic-release/exec -- npm install @semantic-release/git -- npm install @semantic-release/github + - stage: Semantic-Release + install: + - sudo apt-get install python + - nvm install 12 + - npm install -g npm@6.x + - pip install --user bump2version + - npm install @semantic-release/changelog + - npm install @semantic-release/exec + - npm install @semantic-release/git + - npm install @semantic-release/github + script: + - npx semantic-release + after_success: + - echo "Semantic release has successfully created a new tagged-release" -deploy: - # On master, run semrel to create a new tagged-release. - - provider: script - script: npx semantic-release - skip_cleanup: true - on: - branch: master - # Publish jars on bintray for a tagged release. - - provider: script - script: - - >- - mvn deploy $MVN_ARGS -DskipTests - && build/bintraySync.sh $BINTRAY_USER $BINTRAY_APIKEY $BINTRAY_ORG $BINTRAY_REPO $TRAVIS_TAG - skip_cleanup: true - on: - tags: true + - stage: Publish-Release jdk: openjdk8 - # Publish javadocs to gh-pages only for a tagged-release. - - provider: script - script: "./build/publish-javadoc.sh" - skip_cleanup: true - on: - tags: true - jdk: openjdk8 - # Upload code coverage reports to codecov.io for master or tagged release - - provider: script - script: $HOME/codecov-bash.sh -s modules/coverage-reports/target/site/jacoco-aggregate -t $CODECOV_TOKEN - skip_cleanup: true - on: - condition: $TRAVIS_BRANCH == master || -n "$TRAVIS_TAG" - jdk: openjdk8 \ No newline at end of file + name: Publish-Javadoc + install: true + script: + - build/setMavenVersion.sh + - mvn clean javadoc:aggregate $MVN_ARGS + - build/publishJavadoc.sh + after_success: + - echo "Javadocs successfully published to gh-pages!" + + - jdk: openjdk8 + name: Publish-To-Maven-Central + install: true + script: + - build/setupSigning.sh + - build/setMavenVersion.sh + - mvn deploy $MVN_ARGS -DskipTests -P central + after_success: + - echo "Maven artifacts successfully published to Maven Central!" \ No newline at end of file diff --git a/build/.travis.settings.xml b/build/.travis.settings.xml index b85c4f2c08..bb4f539a0d 100644 --- a/build/.travis.settings.xml +++ b/build/.travis.settings.xml @@ -1,10 +1,11 @@ - - - - bintray - ${env.BINTRAY_USER} - ${env.BINTRAY_APIKEY} - - + + + + ossrh + ${env.OSSRH_USERNAME} + ${env.OSSRH_PASSWORD} + + diff --git a/build/bintraySync.sh b/build/bintraySync.sh deleted file mode 100755 index c220734c23..0000000000 --- a/build/bintraySync.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -if [ $# -lt 5 ] -then - echo " - Syntax: - $0 > - Example: - $0 btuser1 btapikey1 bintray-org1 bintray-repo1 0.0.1 -" - - exit 1 -fi - -user=$1 -apikey=$2 -subject=$3 -reponame=$4 -pkgversion=$5 - -# List of maven artifacts to be sync'd from bintray to maven central" -package_names=" -com.ibm.cloud:is -com.ibm.cloud:vpc -com.ibm.cloud:is-common" - -this_dir=`dirname "$0"` - -for pkg in ${package_names} -do - $this_dir/sync2MC.sh $user $apikey $subject $reponame $pkg $pkgversion -done - diff --git a/build/generate-index-html.sh b/build/generateJavadocIndex.sh similarity index 68% rename from build/generate-index-html.sh rename to build/generateJavadocIndex.sh index 0033649d2d..68beb6af97 100755 --- a/build/generate-index-html.sh +++ b/build/generateJavadocIndex.sh @@ -26,13 +26,5 @@ echo ' ls docs | grep --invert-match index.html | sed 's/^.*/
  • &<\/a><\/li>/' echo ' - ' diff --git a/build/publishCodeCoverage.sh b/build/publishCodeCoverage.sh new file mode 100755 index 0000000000..d20a5a7008 --- /dev/null +++ b/build/publishCodeCoverage.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# This script will publish code coverage info for a build of the main branch +# or a tagged release. + +if [[ -n "${TRAVIS_TAG}" || "${TRAVIS_BRANCH}" == "main" && "${TRAVIS_PULL_REQUEST}" == "false" ]]; then + printf ">>>>> Publishing code coverage info for branch: %s\n" ${TRAVIS_BRANCH} + $HOME/codecov-bash.sh -s modules/coverage-reports/target/site/jacoco-aggregate -t $CODECOV_TOKEN +else + printf ">>>>> Bypassing code coverage publish step for feature branch/PR build.\n" +fi + diff --git a/build/publish-javadoc.sh b/build/publishJavadoc.sh similarity index 72% rename from build/publish-javadoc.sh rename to build/publishJavadoc.sh index dc67400da0..229d4f24df 100755 --- a/build/publish-javadoc.sh +++ b/build/publishJavadoc.sh @@ -1,18 +1,23 @@ #!/bin/bash +# This script will publish the aggregated javadocs found in the project's "target" directory. +# The javadocs are committed and pushed to the git repository's gh-pages branch. +# Be sure to customize this file to reflect your SDK project's settings (git url, + # Avoid publishing javadocs for a PR build if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then - printf "\n>>>>> Publishing javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} + printf "\n>>>>> Publishing javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} - printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'" - git clone --branch=gh-pages https://${GH_TOKEN}@github.com/IBM/vpc-java-sdk.git gh-pages + printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n" + rm -fr ./gh-pages + git clone --branch=gh-pages https://${GH_TOKEN}@XXXGH_URL_NOSCHEMEXXX.git gh-pages printf "\n>>>>> Finished cloning...\n" - + pushd gh-pages - + # Create a new directory for this branch/tag and copy the aggregated javadocs there. printf "\n>>>>> Copying aggregated javadocs to new tagged-release directory: %s\n" ${TRAVIS_BRANCH} rm -rf docs/${TRAVIS_BRANCH} @@ -20,7 +25,7 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then cp -rf ../target/site/apidocs/* docs/${TRAVIS_BRANCH} printf "\n>>>>> Generating gh-pages index.html...\n" - ../build/generate-index-html.sh > index.html + ../build/generateJavadocIndex.sh > index.html # Update the 'latest' symlink to point to this branch if it's a tagged release. if [ -n "$TRAVIS_TAG" ]; then @@ -39,10 +44,10 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then popd - printf "\n>>>>> Published javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} + printf "\n>>>>> Published javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} else - printf "\n>>>>> Javadoc publishing bypassed for non-release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} + printf "\n>>>>> Javadoc publishing bypassed for non-release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER} fi diff --git a/build/setMavenVersion.sh b/build/setMavenVersion.sh new file mode 100755 index 0000000000..16194e4f0b --- /dev/null +++ b/build/setMavenVersion.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# This script will check $TRAVIS_TAG to see if we need to run maven to +# set the artifact version #'s. + +if [[ -n "${TRAVIS_TAG}" ]]; then + printf "\n>>>>> Setting artifact version #'s to: %s\n" ${TRAVIS_TAG} + mvn versions:set -DnewVersion=${TRAVIS_TAG} -DgenerateBackupPoms=false +else + printf "\n>>>>> Bypassing artifact version setting for non-tagged build\n" +fi + \ No newline at end of file diff --git a/build/setupSigning.sh b/build/setupSigning.sh new file mode 100755 index 0000000000..5534899446 --- /dev/null +++ b/build/setupSigning.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -x + +# This script is responsible for decrypting your encrypted signing key file +# (build/signing.key.enc), and importing it into the gpg keystore. +# This is done so that your maven build will be able to properly sign your jars +# prior to publishing them on maven central. + +echo "Importing signing key..." + +# Modify the command below to use the correct environment variables +# that were added to your Travis build settings when you encrypted your signing.key file. +openssl aes-256-cbc -K $encrypted_4b7d603e7466_key -iv $encrypted_4b7d603e7466_iv -in build/signing.key.enc -out build/signing.key -d + +gpg --version +gpg --fast-import build/signing.key +rm build/signing.key + +echo "Signing key import finished!" diff --git a/build/signing.key.enc b/build/signing.key.enc new file mode 100644 index 0000000000..80d981c8ce Binary files /dev/null and b/build/signing.key.enc differ diff --git a/modules/coverage-reports/pom.xml b/modules/coverage-reports/pom.xml index 8acbca4a09..1b7e783174 100644 --- a/modules/coverage-reports/pom.xml +++ b/modules/coverage-reports/pom.xml @@ -36,16 +36,15 @@ + + + true + true + + - - com.carrotgarden.maven - bintray-maven-plugin - - true - - org.jacoco jacoco-maven-plugin diff --git a/pom.xml b/pom.xml index bb2056d7ce..3f51f362c6 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,8 @@ 3.13.1 3.0.0-M3 0.8.5 - 1.5.20191113165555 + 1.6.8 + 1.6 3.0.0-M1 3.1.0 3.2.2 @@ -44,11 +45,6 @@ 2.0.5 3.2.4 1.7.28 - - - ibm-cloud-sdks - vpc-java-sdk - https://github.com/IBM/vpc-java-sdk @@ -57,9 +53,10 @@ modules/vpc - modules/examples modules/coverage-reports + modules/examples + @@ -99,10 +96,6 @@ https://na.artifactory.swg-devops.com:443/artifactory/wcp-ibmcloud-sdks-team-maven-local/ - - jcenter - https://jcenter.bintray.com/ - - - com.carrotgarden.maven - bintray-maven-plugin - [1.0.0,) - - deploy - - - - - - - - - + org.sonatype.plugins + nexus-staging-maven-plugin + ${nexus-staging-plugin-version} + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin-version} org.apache.maven.plugins @@ -506,5 +479,66 @@ https://www.ibm.com/ - + + + + + central + + + + + + + + + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + true + + ossrh + https://oss.sonatype.org/ + true + true + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + --batch + --yes + --no-tty + + + + + + + + ${env.GPG_KEYNAME} + ${env.GPG_PASSPHRASE} + + + diff --git a/vpc.env.enc b/vpc.env.enc deleted file mode 100644 index e01e5f1ec4..0000000000 --- a/vpc.env.enc +++ /dev/null @@ -1,2 +0,0 @@ -/A[L :tZ -7I#f*Z=;j0;H:v=oeaQ`% A~V1_ԣ \ No newline at end of file