Skip to content

Commit

Permalink
Initial CI Build Refactor (#962)
Browse files Browse the repository at this point in the history
Simplified the `travis` configuration back to it's minimal form to create
a new starting point.

* Adding Explicit Deploy stage
* Updating documentation and adding tagging to the release script
* Adding tag configuration to pom
* Configured Travis to Skip the commits created when preparing the release
* Adding Git Credentials
* Added Sync Stage during releases
  • Loading branch information
kdavisk6 authored May 11, 2019
1 parent f6fd93f commit bdce5c2
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 35 deletions.
64 changes: 32 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Run `travis lint` when changing this file to avoid breaking the build.
# Default JDK is really old: 1.8.0_31; Trusty's is less old: 1.8.0_51
# https://docs.travis-ci.com/user/ci-environment/#Virtualization-environments
dist: trusty
dist: xenial
sudo: false
language: java
jdk: oraclejdk8

cache:
directories:
- $HOME/.m2

jdk:
- openjdk8
- openjdk11

before_install:
# Parameters used during release
- git config user.name "$GH_USER"
Expand All @@ -13,35 +18,30 @@ before_install:
- git config credential.helper "store --file=.git/credentials"
- echo "https://$GH_TOKEN:@github.com" > .git/credentials

install:
# Override default travis to use the maven wrapper
- ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V

script:
- ./travis/publish.sh

cache:
directories:
- $HOME/.m2

matrix:
jobs:
include:
- os: linux
jdk: oraclejdk8
addons:
apt:
packages:
- oracle-java8-installer
- os: linux
- stage: snapshot
name: "Deploy Snapshot to JCenter"
if: branch = master AND type != pull_request
jdk: openjdk8
- os: linux
jdk: openjdk11

# Don't build release tags. This avoids publish conflicts because the version commit exists both on master and the release tag.
# See https://github.com/travis-ci/travis-ci/issues/1532
branches:
except:
- /^[0-9]/
install: true
script:
- ./mvnw -B -nsu -s ./travis/settings.xml -P release -pl -:feign-benchmark -DskipTests=true deploy
- stage: release
name: "Release to JCenter"
if: tag =~ /^[0-9\.]$/
jdk: openjdk8
install: true
script:
- ./mvnw -B -nsu -s ./travis/settings.xml -P release -pl -:feign-benchmark -DskipTests=true deploy
- stage: sync
name: "Sync with Maven Central"
if: tag =~ /^[0-9\.]$/
jdk: openjdk8
install: true
script:
# this step can take an inordinate amount of time, so the wait should push it to 30 minutes
- travis_wait 30 ./mvnw -B -nsu -s ./travis/settings.xml -N io.zipkin.centralsync-maven-plugin:centralsync-maven-plugin:sync

env:
global:
Expand Down
10 changes: 7 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ This repo uses [semantic versions](http://semver.org/). Please keep this in mind

1. **Push a git tag**

The tag should be of the format `release-N.M.L`, for example `release-8.18.0`.
Prepare the next release by running the [release script](travis/release.sh) from a clean checkout of the master branch.
This script will:
* Update all versions to the next release.
* Tag the release.
* Update all versions to the next development version.

1. **Wait for Travis CI**

This part is controlled by [`travis/publish.sh`](travis/publish.sh). It creates a couple commits, bumps the version,
publishes artifacts, syncs to Maven Central.
This part is controlled by the [travis configuration](.travis.yml), specifically the `release` stage. Which
creates the release artifacts and deploys them to maven central.

## Credentials

Expand Down
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
<maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
<bom-generator.version>0.14.3</bom-generator.version>
<bom.template.file.path>file://${project.basedir}/src/config/bom.xml</bom.template.file.path>
<maven-scm-plugin.version>1.11.2</maven-scm-plugin.version>
<maven-versions-plugin.version>2.7</maven-versions-plugin.version>
</properties>
<url>https://github.com/openfeign/feign</url>
<inceptionYear>2012</inceptionYear>
Expand Down Expand Up @@ -129,6 +131,11 @@
<email>velo br at gmail dot com</email>
<url>about.me/velo</url>
</developer>
<developer>
<id>kdavisk6</id>
<name>Kevin Davis</name>
<email>kdavisk6@gmail.com</email>
</developer>
</developers>

<distributionManagement>
Expand Down Expand Up @@ -596,6 +603,19 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>${maven-versions-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>${maven-scm-plugin.version}</version>
<configuration>
<tag>${project.version}</tag>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
40 changes: 40 additions & 0 deletions travis/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
# Copyright 2012-2019 The Feign Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
#

function increment() {
local version=$1
result=`echo ${version} | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}'`
echo "${result}-SNAPSHOT"
}

# extract the release version from the pom file
version=`./mvnw -o help:evaluate -N -Dexpression=project.version | sed -n '/^[0-9]/p'`
tag=`echo ${version} | cut -d'-' -f 1`

# determine the next snapshot version
snapshot=$(increment ${tag})

echo "release version is: ${tag} and next snapshot is: ${snapshot}"

# Update the versions, removing the snapshots, then create a new tag for the release, this will
# start the travis-ci release process.
./mvnw -B versions:set scm:checkin -DremoveSnapshot -DgenerateBackupPoms=false -Dmessage="[travis skip] prepare release ${tag}" -DpushChanges=false

# tag the release
echo "pushing tag ${tag}"
./mvnw scm:tag -DpushChanges=false

# Update the versions to the next snapshot
./mvnw -B versions:set scm:checkin -DnewVersion="${snapshot}" -DgenerateBackupPoms=false -Dmessage="[travis skip] updating versions to next development iteration ${snapshot}" -DpushChanges=false
File renamed without changes.

0 comments on commit bdce5c2

Please sign in to comment.