Skip to content

Commit 8268092

Browse files
committed
feat(build): travis updates for sonatype deployment
1 parent 2454ef0 commit 8268092

12 files changed

Lines changed: 200 additions & 252 deletions

.travis.yml

Lines changed: 58 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
---
2-
os: linux
32
language: java
43
dist: xenial
5-
jdk:
6-
- openjdk8
74

8-
# Only run on main (still tests PRs)
9-
branches:
10-
only:
11-
- main
5+
jdk:
6+
- openjdk8
127

138
notifications:
149
email: true
1510

16-
# After creating your SDK project from this template repository,
17-
# set BINTRAY_REPO to the name of your project's bintray repository.
18-
# See https://github.com/IBM/ibm-cloud-sdk-common/blob/master/JavaDeploy.md for details.
19-
env:
20-
global:
21-
- MVN_ARGS="--settings build/.travis.settings.xml"
22-
- BINTRAY_ORG=ibm-cloud-sdks
23-
- BINTRAY_REPO=code-engine-java-sdk
24-
2511
branches:
2612
except:
2713
- gh-pages
@@ -30,68 +16,64 @@ cache:
3016
directories:
3117
- "$HOME/.m2"
3218

19+
env:
20+
global:
21+
- MVN_ARGS="--settings build/.travis.settings.xml"
3322

34-
before_install:
35-
- sudo apt-get update
36-
- sudo apt-get install python
37-
- nvm install 12
38-
- npm install -g npm@6.x
39-
# Uncomment this section and update as needed to decrypt each configuration file.
40-
# - >-
41-
# [ -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]
42-
# && openssl aes-256-cbc -K $my_key -iv $my_iv -in myservice.env.enc -out myservice.env -d
43-
# || true
44-
45-
install:
46-
- curl -s https://codecov.io/bash > $HOME/codecov-bash.sh && chmod +x $HOME/codecov-bash.sh
47-
48-
before_script:
49-
- echo "TRAVIS_TAG = '${TRAVIS_TAG}'"
50-
- >-
51-
[ -n "${TRAVIS_TAG}" ]
52-
&& mvn versions:set -DnewVersion=${TRAVIS_TAG} -DgenerateBackupPoms=false
53-
|| true
23+
stages:
24+
- name: Build-Test
25+
- name: Semantic-Release
26+
if: branch = main AND type = push AND fork = false
27+
- name: Publish-Release
28+
if: tag IS present
5429

55-
script:
56-
- mvn clean verify $MVN_ARGS
57-
- mvn package
58-
- ./test-integration.sh
30+
before_install:
31+
- sudo apt-get update
32+
- env | grep TRAVIS
5933

60-
# To enable semantic-release, uncomment these sections.
61-
before_deploy:
62-
- pip install --user bump2version
63-
- npm install @semantic-release/changelog
64-
- npm install @semantic-release/exec
65-
- npm install @semantic-release/git
66-
- npm install @semantic-release/github
67-
#
68-
deploy:
69-
# On master, run semrel to create a new tagged-release.
70-
- provider: script
71-
script: npx semantic-release
72-
skip_cleanup: true
73-
on:
74-
branch: main
75-
# Publish jars on bintray for a tagged release.
76-
- provider: script
77-
script: >-
78-
mvn deploy $MVN_ARGS -DskipTests
79-
&& build/bintraySync.sh $BINTRAY_USER $BINTRAY_APIKEY $BINTRAY_ORG $BINTRAY_REPO $TRAVIS_TAG
80-
skip_cleanup: true
81-
on:
82-
tags: true
34+
jobs:
35+
include:
36+
- stage: Build-Test
8337
jdk: openjdk8
84-
# Publish javadocs to gh-pages only for a tagged-release.
85-
- provider: script
86-
script: "./build/publish-javadoc.sh"
87-
skip_cleanup: true
88-
on:
89-
tags: true
38+
install:
39+
- curl -s https://codecov.io/bash > $HOME/codecov-bash.sh && chmod +x $HOME/codecov-bash.sh
40+
script:
41+
- build/setMavenVersion.sh
42+
- mvn verify -fae -DskipITs $MVN_ARGS
43+
- mvn package
44+
- ./test-integration.sh
45+
after_success:
46+
- build/publishCodeCoverage.sh
47+
- stage: Semantic-Release
48+
install:
49+
- sudo apt-get install python
50+
- nvm install 12
51+
- npm install -g npm@6.x
52+
- pip install --user bump2version
53+
- npm install @semantic-release/changelog
54+
- npm install @semantic-release/exec
55+
- npm install @semantic-release/git
56+
- npm install @semantic-release/github
57+
script:
58+
- npx semantic-release
59+
after_success:
60+
- echo "Semantic release has successfully created a new tagged-release"
61+
- stage: Publish-Release
9062
jdk: openjdk8
91-
# # Upload code coverage reports to codecov.io for master or tagged release
92-
# - provider: script
93-
# script: $HOME/codecov-bash.sh -s modules/coverage-reports/target/site/jacoco-aggregate -t $CODECOV_TOKEN
94-
# skip_cleanup: true
95-
# on:
96-
# condition: $TRAVIS_BRANCH == master || -n "$TRAVIS_TAG"
97-
# jdk: openjdk8
63+
name: Publish-Javadoc
64+
install: true
65+
script:
66+
- build/setMavenVersion.sh
67+
- mvn clean javadoc:aggregate $MVN_ARGS
68+
- build/publishJavadoc.sh
69+
after_success:
70+
- echo "Javadocs successfully published to gh-pages!"
71+
- jdk: openjdk8
72+
name: Publish-To-Maven-Central
73+
install: true
74+
script:
75+
- build/setupSigning.sh
76+
- build/setMavenVersion.sh
77+
- mvn deploy $MVN_ARGS -DskipTests -P central
78+
after_success:
79+
- echo "Maven artifacts successfully published to Maven Central!"

build/.travis.settings.xml

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
3-
<servers>
4-
<server>
5-
<id>bintray</id>
6-
<username>${env.BINTRAY_USER}</username>
7-
<password>${env.BINTRAY_APIKEY}</password>
8-
</server>
9-
</servers>
10-
<profiles>
11-
<profile>
12-
<id>ossrh</id>
13-
<activation>
14-
<activeByDefault>true</activeByDefault>
15-
</activation>
16-
<properties>
17-
<gpg.executable>${env.GPG_EXECUTABLE}</gpg.executable>
18-
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
19-
</properties>
20-
</profile>
21-
</profiles>
22-
</settings>
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
4+
<servers>
5+
<server>
6+
<id>ossrh</id>
7+
<username>${env.OSSRH_USERNAME}</username>
8+
<password>${env.OSSRH_PASSWORD}</password>
9+
</server>
10+
</servers>
11+
</settings>

build/bintraySync.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,23 @@ echo '<!DOCTYPE html>
88
<meta charset="utf-8">
99
<meta http-equiv="X-UA-Compatible" content="IE=edge">
1010
<meta name="viewport" content="width=device-width, initial-scale=1">
11-
<title>IBM Cloud My Services</title>
11+
<title>IBM Cloud Code Engine</title>
1212
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" crossorigin="anonymous">
1313
</head>
1414
<body>
1515
<div class="container">
1616
<div class="page-header">
17-
<h1>IBM Cloud My Services Java SDK Documentation</h1>
17+
<h1>IBM Cloud Code Engine Java SDK Documentation</h1>
1818
</div>
1919
20-
<p><a href="https://cloud.ibm.com/apidocs?category=<service-category>">My Services Info</a>
21-
| <a href="<github-repo-url">GitHub</a>
20+
<p><a href="https://cloud.ibm.com/apidocs/codeengine">API Documentation</a>
21+
| <a href="https://github.com/IBM/code-engine-java-sdk">GitHub</a>
2222
</p>
2323
2424
<p>Javadoc by branch/release:</p>
2525
<ul><li><a href="docs/latest">Latest</a></li>'
2626
ls docs | grep --invert-match index.html | sed 's/^.*/<li><a href="docs\/&">&<\/a><\/li>/'
2727
echo ' </ul>
2828
</div>
29-
<script>
30-
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
31-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
32-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
33-
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
34-
ga("create", "UA-59827755-4", "auto");
35-
ga("send", "pageview");
36-
</script>
3729
</body>
3830
</html>'

build/publishCodeCoverage.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# This script will publish code coverage info for a build of the main branch
4+
# or a tagged release.
5+
6+
if [[ -n "${TRAVIS_TAG}" || "${TRAVIS_BRANCH}" == "main" && "${TRAVIS_PULL_REQUEST}" == "false" ]]; then
7+
printf ">>>>> Publishing code coverage info for branch: %s\n" ${TRAVIS_BRANCH}
8+
$HOME/codecov-bash.sh -s modules/coverage-reports/target/site/jacoco-aggregate -t $CODECOV_TOKEN
9+
else
10+
printf ">>>>> Bypassing code coverage publish step for feature branch/PR build.\n"
11+
fi
12+
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
#!/bin/bash
22

3+
# This script will publish the aggregated javadocs found in the project's "target" directory.
4+
# The javadocs are committed and pushed to the git repository's gh-pages branch.
5+
# Be sure to customize this file to reflect your SDK project's settings (git url,
6+
37
# Avoid publishing javadocs for a PR build
48
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then
59

610
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}
711

8-
printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'"
9-
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/IBM/platform-services-java-sdk.git gh-pages
12+
printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n"
13+
rm -fr ./gh-pages
14+
git clone --branch=gh-pages https://${GH_TOKEN}@XXXGH_URL_NOSCHEMEXXX.git gh-pages
1015

1116
printf "\n>>>>> Finished cloning...\n"
1217

@@ -20,7 +25,7 @@ if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" ]; then
2025
cp -rf ../target/site/apidocs/* docs/${TRAVIS_BRANCH}
2126

2227
printf "\n>>>>> Generating gh-pages index.html...\n"
23-
../build/generate-index-html.sh > index.html
28+
../build/generateJavadocIndex.sh > index.html
2429

2530
# Update the 'latest' symlink to point to this branch if it's a tagged release.
2631
if [ -n "$TRAVIS_TAG" ]; then

build/setMavenVersion.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# This script will check $TRAVIS_TAG to see if we need to run maven to
4+
# set the artifact version #'s.
5+
6+
if [[ -n "${TRAVIS_TAG}" ]]; then
7+
printf "\n>>>>> Setting artifact version #'s to: %s\n" ${TRAVIS_TAG}
8+
mvn versions:set -DnewVersion=${TRAVIS_TAG} -DgenerateBackupPoms=false
9+
else
10+
printf "\n>>>>> Bypassing artifact version setting for non-tagged build\n"
11+
fi
12+

build/setupSigning.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
set -x
3+
4+
# This script is responsible for decrypting your encrypted signing key file
5+
# (build/signing.key.enc), and importing it into the gpg keystore.
6+
# This is done so that your maven build will be able to properly sign your jars
7+
# prior to publishing them on maven central.
8+
9+
echo "Importing signing key..."
10+
11+
openssl aes-256-cbc -K $encrypted_4b7d603e7466_key -iv $encrypted_4b7d603e7466_iv -in build/signing.key.enc -out build/signing.key -d
12+
13+
gpg --version
14+
gpg --fast-import build/signing.key
15+
rm build/signing.key
16+
17+
echo "Signing key import finished!"

build/signing.key.enc

5.11 KB
Binary file not shown.

build/sync2MC.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)