Switch to Concourse CI.

This commit is contained in:
Greg Turnquist
2019-03-03 09:36:49 -06:00
parent dd57e0a515
commit 35c74de6cb
12 changed files with 219 additions and 26 deletions

View File

@@ -1,22 +0,0 @@
language: java
jdk:
- oraclejdk8
addons:
apt:
packages:
- oracle-java8-installer
env:
matrix:
- PROFILE=non-existant
- PROFILE=spring5-next
cache:
directories:
- $HOME/.m2
sudo: false
install: true
script: "./mvnw clean dependency:list test -Dsort"

5
ci/README.adoc Normal file
View File

@@ -0,0 +1,5 @@
== Concourse CI
Spring HATEOAS Examples is built using Concourse as it's CI tool of choice.
The pipeline is defined on https://github.com/spring-projects/spring-hateoas[Spring HATEOAS], it's parent project.

14
ci/build.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail
[[ -d $PWD/maven && ! -d $HOME/.m2 ]] && ln -s $PWD/maven $HOME/.m2
spring_hateoas-examples_artifactory=$(pwd)/spring-hateoas-examples-artifactory
rm -rf $HOME/.m2/repository/org/springframework/hateoas-examples 2> /dev/null || :
cd spring-hateoas-examples-github
./mvnw -Pdistribute -Dmaven.test.skip=true clean deploy \
-DaltDeploymentRepository=distribution::default::file://${spring_hateoas-examples_artifactory}

19
ci/build.yml Normal file
View File

@@ -0,0 +1,19 @@
---
platform: linux
image_resource:
type: docker-image
source:
repository: springci/spring-hateoas-examples-8-jdk-with-graphviz
inputs:
- name: spring-hateoas-examples-github
outputs:
- name: spring-hateoas-examples-artifactory
caches:
- path: maven
run:
path: spring-hateoas-examples-github/ci/build.sh

21
ci/create-release.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
set -euo pipefail
RELEASE=$1
SNAPSHOT=$2
# Bump up the version in pom.xml to the desired version and commit the change
./mvnw versions:set -DnewVersion=$RELEASE -DgenerateBackupPoms=false
git add .
git commit --message "Releasing Spring HATEOAS Examples v$RELEASE"
# Tag the release
git tag -s v$RELEASE -m "v$RELEASE"
# Bump up the version in pom.xml to the next snapshot
./mvnw versions:set -DnewVersion=$SNAPSHOT -DgenerateBackupPoms=false
git add .
git commit --message "Continue development on v$SNAPSHOT"

46
ci/promote-to-bintray.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
set -e -u
apt-get update
apt-get install -y jq
buildName=$( cat spring-hateoas-examples-artifactory/build-info.json | jq -r '.buildInfo.name' )
buildNumber=$( cat spring-hateoas-examples-artifactory/build-info.json | jq -r '.buildInfo.number' )
groupId=$( cat spring-hateoas-examples-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
version=$( cat spring-hateoas-examples-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
targetRepo="libs-release-local"
echo "Promoting ${buildName}/${buildNumber} to ${targetRepo}"
curl \
-s \
--connect-timeout 240 \
--max-time 2700 \
-u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
-H "Content-type:application/json" \
-d "{\"sourceRepos\": [\"libs-release-local\"], \"targetRepo\" : \"spring-distributions\", \"async\":\"true\"}" \
-f \
-X \
POST "https://repo.spring.io/api/build/distribute/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to distribute" >&2; exit 1; }
echo "Waiting for artifacts to be published"
ARTIFACTS_PUBLISHED=false
WAIT_TIME=10
COUNTER=0
while [ $ARTIFACTS_PUBLISHED == "false" ] && [ $COUNTER -lt 120 ]; do
result=$( curl -s https://api.bintray.com/packages/spring/jars/"${groupId}" )
versions=$( echo "$result" | jq -r '.versions' )
exists=$( echo "$versions" | grep "$version" -o || true )
if [ "$exists" = "$version" ]; then
ARTIFACTS_PUBLISHED=true
fi
COUNTER=$(( COUNTER + 1 ))
sleep $WAIT_TIME
done

19
ci/promote-to-bintray.yml Normal file
View File

@@ -0,0 +1,19 @@
---
platform: linux
image_resource:
type: docker-image
source:
repository: openjdk
tag: 8-jdk
inputs:
- name: spring-hateoas-examples-artifactory
- name: spring-hateoas-examples-github
run:
path: spring-hateoas-examples-github/ci/promote-to-bintray.sh
params:
ARTIFACTORY_USERNAME:
ARTIFACTORY_PASSWORD:

24
ci/sync-to-maven-central.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
set -e -u
apt-get update
apt-get install -y jq
buildName=$( cat spring-hateoas-examples-artifactory/build-info.json | jq -r '.buildInfo.name' )
buildNumber=$( cat spring-hateoas-examples-artifactory/build-info.json | jq -r '.buildInfo.number' )
groupId=$( cat spring-hateoas-examples-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
version=$( cat spring-hateoas-examples-artifactory/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
echo "Syncing ${buildName}/${buildNumber} to Maven Central"
curl \
-s \
--connect-timeout 240 \
--max-time 2700 \
-u ${BINTRAY_USERNAME}:${BINTRAY_API_KEY} \
-H "Content-Type: application/json" -d "{ \"username\": \"${SONATYPE_USER_TOKEN}\", \"password\": \"${SONATYPE_PASSWORD_TOKEN}\"}" \
-f \
-X \
POST "https://api.bintray.com/maven_central_sync/spring/jars/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; }
echo "Sync complete"

View File

@@ -0,0 +1,21 @@
---
platform: linux
image_resource:
type: docker-image
source:
repository: openjdk
tag: 8-jdk
inputs:
- name: spring-hateoas-examples-artifactory
- name: spring-hateoas-examples-github
run:
path: spring-hateoas-examples-github/ci/sync-to-maven-central.sh
params:
BINTRAY_USERNAME:
BINTRAY_API_KEY:
SONATYPE_USER_TOKEN:
SONATYPE_PASSWORD_TOKEN:

11
ci/test.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail
[[ -d $PWD/maven && ! -d $HOME/.m2 ]] && ln -s $PWD/maven $HOME/.m2
rm -rf $HOME/.m2/repository/org/springframework/hateoas 2> /dev/null || :
cd spring-hateoas-examples-github
./mvnw clean dependency:list test -P${PROFILE} -Dsort

17
ci/test.yml Normal file
View File

@@ -0,0 +1,17 @@
---
platform: linux
image_resource:
type: docker-image
source:
repository: openjdk
tag: 8-jdk
inputs:
- name: spring-hateoas-examples-github
caches:
- path: maven
run:
path: spring-hateoas-examples-github/ci/test.sh

26
pom.xml
View File

@@ -63,13 +63,31 @@
</properties>
<profiles>
<profile>
<id>spring5-next</id>
<id>spring51-next</id>
<properties>
<spring.version>5.0.2.BUILD-SNAPSHOT</spring.version>
<jackson.version>2.9.2</jackson.version>
<spring.version>5.1.6.BUILD-SNAPSHOT</spring.version>
</properties>
<repositories>
<repository>
<id>spring-libs-snapshot</id>
<url>http://repo.spring.io/libs-snapshot</url>
</repository>
</repositories>
</profile>
<profile>
<id>spring52-next</id>
<properties>
<spring.version>5.2.0.BUILD-SNAPSHOT</spring.version>
</properties>
<repositories>
<repository>
<id>spring-libs-snapshot</id>
<url>http://repo.spring.io/libs-snapshot</url>
</repository>
</repositories>
</profile>
</profiles>