Skip to content

Commit

Permalink
build(Travis): update Travis CI process
Browse files Browse the repository at this point in the history
will abandon GitHub Actions and GitHub Packaged in the future

.travis/
 - gpg.asc.enc (encrypted gpg public key)
 - maven-settings.xml

BREAKING CHANGE: deploy artifact based on Travis CI
  • Loading branch information
johnnymillergh committed Oct 22, 2020
1 parent abdb924 commit fde74b4
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ build/

### VS Code ###
.vscode/

### Custom Ignored ###
/.travis/**.asc
37 changes: 31 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,48 @@ language: java
# https://docs.travis-ci.com/user/reference/trusty/#jvm-clojure-groovy-java-scala-images
jdk: oraclejdk11

# https://docs.travis-ci.com/user/job-lifecycle#skipping-the-installation-phase
install: skip

before_script:
- chmod +x mvnw

# Each job in Travis CI has several steps:
# https://docs.travis-ci.com/user/job-lifecycle/
# The 'language: java' directive sets up sane defaults to test common java applications.
# We customize the script for compiling Maven application. For more about customizing the build:
# https://docs.travis-ci.com/user/customizing-the-build
script:
- ./mvnw install -Dmaven.javadoc.skip=true -B -V
- "./mvnw clean install -Dmaven.javadoc.skip=true -B -V"

before_install:
- chmod +x mvnw
before_deploy:
- openssl aes-256-cbc -K $encrypted_4f0d00631887_key -iv $encrypted_4f0d00631887_iv
-in .travis/gpg.asc.enc -out .travis/gpg.asc -d

# This is to enable Codecov's coverage. If the build is successful, the code is submitted for code coverage analysis.
#after_success:
# - bash <(curl -s https://codecov.io/bash)
deploy:
- skip_cleanup: true
provider: script
script: ./deploy.sh
on:
branch: master
- skip_cleanup: true
provider: script
script: ./deploy.sh
on:
tags: true

# https://docs.travis-ci.com/user/notifications#default-notification-settings
notifications:
email:
on_success: change
on_failure: always

# https://docs.travis-ci.com/user/environment-variables/
# https://docs.travis-ci.com/user/encryption-keys#usage
# https://docs.travis-ci.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3sbMM390ecpSNetSEfmx7H8iv+aIt73Z4G/QLkgQDUY94S3MdpS4XBKMUEHFbWUwojZe1+0btNe+hu40JIMltkxFQ3CQMcEop/ql1YNAVF1j90tsXyyqcGotJg8Gnu8ADda4qDcDVPwxdgLkU3zcI031rgmNog6PkJfxe+rzkucXdvfAC5iom9tcXr+EGhM1Yn6mYUFjnuhoSrX4VvWbnn4dgW16sBCgdi0CH8RTH7mWEMuiBF6Rm4lrlnya2oKp4HYuwtqdxFpMiZehFzQ6U9eKky4KrBHsWSQgdT1w9Avrv0yuf3sj98a/TiMOqcSuH3EP3LI0APDTIQxtf0Ji+wB/fyw3td+ZTiDqUIjAe8o5DG0/4zZkO2/Ke3XORz2rljKfL26Jl8ai3+5uqAyubT8pxza29i2puWwVWdLxHcA0iIFbDYzVQRVSsozvz/jzktSa71H+Tb0MOES4hznBxBpktlc8mQTO8FQUVX+1Q/gH8gT6eo2TryJeMh5x70UvELBopmKJNs2eubbopJWRHtTHFPBO+LvJrqpCc1rcJY1vghcHb0+onAp87XjpgyBRWQAgIeUALZSkljxcU82sNl4FF/ILlEIqeFsCu4="
Binary file added .travis/gpg.asc.enc
Binary file not shown.
26 changes: 26 additions & 0 deletions .travis/maven-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<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
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>ossrh</id>
<username>${env.OSSRH_USERNAME}</username>
<password>${env.OSSRH_PASSWORD}</password>
</server>
</servers>

<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.keyname>${env.GPG_KEY_NAME}</gpg.keyname>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
45 changes: 45 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# expects variables to be set:
# - OSSRH_USERNAME
# - OSSRH_PASSWORD
# - GPG_KEY_NAME
# - GPG_PASSPHRASE
# expects file to exist:
# - .travis/gpg.asc

set -e

# Check the variables are set
if [ -z "$OSSRH_USERNAME" ]; then
echo "missing environment value: OSSRH_USERNAME" >&2
exit 1
fi

if [ -z "$OSSRH_PASSWORD" ]; then
echo "missing environment value: OSSRH_PASSWORD" >&2
exit 1
fi

if [ -z "$GPG_KEY_NAME" ]; then
echo "missing environment value: GPG_KEY_NAME" >&2
exit 1
fi

if [ -z "$GPG_PASSPHRASE" ]; then
echo "missing environment value: GPG_PASSPHRASE" >&2
exit 1
fi

# Prepare the local keyring (requires travis to have decrypted the file
# beforehand)
gpg --fast-import .travis/gpg.asc

if [ ! -z "$TRAVIS_TAG" ]; then
echo "on a tag -> set pom.xml <version> to $TRAVIS_TAG"
mvn --settings "${TRAVIS_BUILD_DIR}/.travis/mvn-settings.xml" org.codehaus.mojo:versions-maven-plugin:2.7:set -DnewVersion=$TRAVIS_TAG 1>/dev/null 2>/dev/null
else
echo "not on a tag -> keep snapshot version in pom.xml"
fi

# Run the maven deploy steps
mvn deploy -P publish -DskipTests=true --settings "${TRAVIS_BUILD_DIR}/.travis/mvn-settings.xml"
19 changes: 9 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,18 @@
</scm>

<distributionManagement>
<repository>
<!-- The id must be the same as global sonatype_releases id -->
<id>sonatype_releases</id>
<name>Nexus Release Repository</name>
<!-- 这里就是在创建issue成功后,对方回复的release发布地址-->
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<!-- The id must be the same as global sonatype_snapshots id -->
<id>sonatype_snapshots</id>
<id>ossrh</id>
<name>Nexus Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<!-- The id must be the same as global sonatype_releases id -->
<id>ossrh</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>

<!-- Build Settings -->
Expand Down Expand Up @@ -153,9 +152,9 @@
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype_releases</serverId>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
Expand Down

0 comments on commit fde74b4

Please sign in to comment.