Skip to content

Commit bdce5c2

Browse files
authored
Initial CI Build Refactor (#962)
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
1 parent f6fd93f commit bdce5c2

File tree

5 files changed

+99
-35
lines changed

5 files changed

+99
-35
lines changed

.travis.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
# Run `travis lint` when changing this file to avoid breaking the build.
2-
# Default JDK is really old: 1.8.0_31; Trusty's is less old: 1.8.0_51
3-
# https://docs.travis-ci.com/user/ci-environment/#Virtualization-environments
4-
dist: trusty
1+
dist: xenial
52
sudo: false
63
language: java
7-
jdk: oraclejdk8
4+
5+
cache:
6+
directories:
7+
- $HOME/.m2
8+
9+
jdk:
10+
- openjdk8
11+
- openjdk11
12+
813
before_install:
914
# Parameters used during release
1015
- git config user.name "$GH_USER"
@@ -13,35 +18,30 @@ before_install:
1318
- git config credential.helper "store --file=.git/credentials"
1419
- echo "https://$GH_TOKEN:@github.com" > .git/credentials
1520

16-
install:
17-
# Override default travis to use the maven wrapper
18-
- ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
19-
20-
script:
21-
- ./travis/publish.sh
22-
23-
cache:
24-
directories:
25-
- $HOME/.m2
26-
27-
matrix:
21+
jobs:
2822
include:
29-
- os: linux
30-
jdk: oraclejdk8
31-
addons:
32-
apt:
33-
packages:
34-
- oracle-java8-installer
35-
- os: linux
23+
- stage: snapshot
24+
name: "Deploy Snapshot to JCenter"
25+
if: branch = master AND type != pull_request
3626
jdk: openjdk8
37-
- os: linux
38-
jdk: openjdk11
39-
40-
# Don't build release tags. This avoids publish conflicts because the version commit exists both on master and the release tag.
41-
# See https://github.com/travis-ci/travis-ci/issues/1532
42-
branches:
43-
except:
44-
- /^[0-9]/
27+
install: true
28+
script:
29+
- ./mvnw -B -nsu -s ./travis/settings.xml -P release -pl -:feign-benchmark -DskipTests=true deploy
30+
- stage: release
31+
name: "Release to JCenter"
32+
if: tag =~ /^[0-9\.]$/
33+
jdk: openjdk8
34+
install: true
35+
script:
36+
- ./mvnw -B -nsu -s ./travis/settings.xml -P release -pl -:feign-benchmark -DskipTests=true deploy
37+
- stage: sync
38+
name: "Sync with Maven Central"
39+
if: tag =~ /^[0-9\.]$/
40+
jdk: openjdk8
41+
install: true
42+
script:
43+
# this step can take an inordinate amount of time, so the wait should push it to 30 minutes
44+
- travis_wait 30 ./mvnw -B -nsu -s ./travis/settings.xml -N io.zipkin.centralsync-maven-plugin:centralsync-maven-plugin:sync
4545

4646
env:
4747
global:

RELEASE.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ This repo uses [semantic versions](http://semver.org/). Please keep this in mind
1010

1111
1. **Push a git tag**
1212

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

1519
1. **Wait for Travis CI**
1620

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

2024
## Credentials
2125

pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
<maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
8989
<bom-generator.version>0.14.3</bom-generator.version>
9090
<bom.template.file.path>file://${project.basedir}/src/config/bom.xml</bom.template.file.path>
91+
<maven-scm-plugin.version>1.11.2</maven-scm-plugin.version>
92+
<maven-versions-plugin.version>2.7</maven-versions-plugin.version>
9193
</properties>
9294
<url>https://github.com/openfeign/feign</url>
9395
<inceptionYear>2012</inceptionYear>
@@ -129,6 +131,11 @@
129131
<email>velo br at gmail dot com</email>
130132
<url>about.me/velo</url>
131133
</developer>
134+
<developer>
135+
<id>kdavisk6</id>
136+
<name>Kevin Davis</name>
137+
<email>kdavisk6@gmail.com</email>
138+
</developer>
132139
</developers>
133140

134141
<distributionManagement>
@@ -596,6 +603,19 @@
596603
</dependency>
597604
</dependencies>
598605
</plugin>
606+
<plugin>
607+
<groupId>org.codehaus.mojo</groupId>
608+
<artifactId>versions-maven-plugin</artifactId>
609+
<version>${maven-versions-plugin.version}</version>
610+
</plugin>
611+
<plugin>
612+
<groupId>org.apache.maven.plugins</groupId>
613+
<artifactId>maven-scm-plugin</artifactId>
614+
<version>${maven-scm-plugin.version}</version>
615+
<configuration>
616+
<tag>${project.version}</tag>
617+
</configuration>
618+
</plugin>
599619
</plugins>
600620
</build>
601621

travis/release.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2012-2019 The Feign Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6+
# in compliance with the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software distributed under the License
11+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12+
# or implied. See the License for the specific language governing permissions and limitations under
13+
# the License.
14+
#
15+
16+
function increment() {
17+
local version=$1
18+
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}'`
19+
echo "${result}-SNAPSHOT"
20+
}
21+
22+
# extract the release version from the pom file
23+
version=`./mvnw -o help:evaluate -N -Dexpression=project.version | sed -n '/^[0-9]/p'`
24+
tag=`echo ${version} | cut -d'-' -f 1`
25+
26+
# determine the next snapshot version
27+
snapshot=$(increment ${tag})
28+
29+
echo "release version is: ${tag} and next snapshot is: ${snapshot}"
30+
31+
# Update the versions, removing the snapshots, then create a new tag for the release, this will
32+
# start the travis-ci release process.
33+
./mvnw -B versions:set scm:checkin -DremoveSnapshot -DgenerateBackupPoms=false -Dmessage="[travis skip] prepare release ${tag}" -DpushChanges=false
34+
35+
# tag the release
36+
echo "pushing tag ${tag}"
37+
./mvnw scm:tag -DpushChanges=false
38+
39+
# Update the versions to the next snapshot
40+
./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 commit comments

Comments
 (0)