Skip to content

Commit

Permalink
Closes #46 - Extend CI configuration in order to automatically releas…
Browse files Browse the repository at this point in the history
…e build artifacts (#53)
  • Loading branch information
mariusoe authored Jan 14, 2019
1 parent 4adb15d commit 4f5afba
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 11 deletions.
33 changes: 31 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,27 @@ jobs:
# upload coverage report
- bash <(curl -s https://codecov.io/bash)

- name: "Documentation Deployment"
- name: "Create and Release Artifacts"
jdk: oraclejdk8
install: ./gradlew :inspectit-oce-documentation:asciidoctor
sudo: true
rvm:
- 2.4
before_install:
- if [ -z "${TRAVIS_TAG}" ]; then RELEASE_VERSION="SNAPSHOT-${TRAVIS_BUILD_NUMBER}"; else RELEASE_VERSION="${TRAVIS_TAG}";fi
- echo "Setting version to $RELEASE_VERSION"
install: ./gradlew -PbuildVersion=$RELEASE_VERSION assemble packageDocumentation
script: skip
before_deploy:
- mkdir -p ~/bin && curl -sSL -o ~/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 && chmod +x ~/bin/jq
- export PATH=$PATH:~/bin
- jq --version
- gem install bundler
- gem install rspec
- gem install github_changelog_generator
- chmod +x ./resources/github-release-script.sh
- if [ -z "${TRAVIS_TAG}" ]; then echo "Not release build."; else ./resources/github-release-script.sh;fi
deploy:
#############################
# MASTER BUILDS
- provider: s3
access_key_id: $AWS_ACCESS_KEY_ID
Expand All @@ -66,7 +82,9 @@ jobs:
on:
tags: false
branch: master
#############################
# RELEASE BUILDS
# > Documentation
- provider: s3
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
Expand All @@ -89,6 +107,17 @@ jobs:
on:
tags: true
branch: master
# > Github Release
- provider: releases
api_key: "${GITHUB_TOKEN}"
name: "Version $RELEASE_VERSION"
file:
- "inspectit-oce-agent/build/inspectit-oce-agent-$RELEASE_VERSION.jar"
- "inspectit-oce-documentation/build/distributions/inspectit-oce-documentation-$RELEASE_VERSION.zip"
skip_cleanup: true
on:
tags: true
branch: master


stages:
Expand Down
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ allprojects {
}
}
apply plugin: 'jacoco'

if (!project.hasProperty('buildVersion') || project.getProperty('buildVersion').empty) {
ext.buildVersion = 'SNAPSHOT'
}

version = "$buildVersion"
}

subprojects {
Expand All @@ -25,7 +31,7 @@ subprojects {

dependencies {
buildTools(
'jarcheck:jarcheck:1.5'
'jarcheck:jarcheck:1.5'
)
compileOnly 'org.projectlombok:lombok:1.18.4'
annotationProcessor 'org.projectlombok:lombok:1.18.4'
Expand Down Expand Up @@ -67,7 +73,7 @@ subprojects {

task codeCoverageReport(type: JacocoReport) {
group = 'Verification'
description ='Generates a combined report from all subprojects'
description = 'Generates a combined report from all subprojects'

executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")

Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
releaseVersion=0.1.M1
openCensusVersion=0.18.0
prometheusClientVersion=0.6.0
2 changes: 0 additions & 2 deletions inspectit-oce-agent/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version = "${releaseVersion}"

dependencies {
compileOnly(
project(':inspectit-oce-bootstrap'),
Expand Down
2 changes: 1 addition & 1 deletion inspectit-oce-bootstrap/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dependencies {
}

jar {
archivesBaseName = "${project.name}"
archiveName = "${project.name}.jar"

//include all "implementation" dependencies in fat jar
from {
Expand Down
2 changes: 1 addition & 1 deletion inspectit-oce-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ task buildOpencensusFatJar(type: Jar) {
}

jar {
archivesBaseName = "${project.name}"
archiveName = "${project.name}.jar"

//include the open-census dependencies as a fat jar
dependsOn buildOpencensusFatJar
Expand Down
2 changes: 0 additions & 2 deletions inspectit-oce-documentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ buildscript {

apply plugin: 'org.asciidoctor.convert'

version = "${releaseVersion}"

asciidoctor {
// TODO fail the task on asciidoctor warnings when updating to v2.+
attributes 'inspectit-oce-version': project.version,
Expand Down
49 changes: 49 additions & 0 deletions resources/github-release-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Based on the shell script of Github user Jaskaranbir (https://gist.github.com/Jaskaranbir/d5b065173b3a6f164e47a542472168c1)

# ===> Set these variables first
branch="master"
repo_slug="$TRAVIS_REPO_SLUG"
token="$GITHUB_TOKEN"
version="$TRAVIS_TAG"

LAST_REVISION=$(git rev-list --tags --skip=1 --max-count=1)
LAST_RELEASE_TAG=$(git describe --abbrev=0 --tags ${LAST_REVISION})

# Generate CHANGELOG.md
github_changelog_generator \
-u $(cut -d "/" -f1 <<< $repo_slug) \
-p $(cut -d "/" -f2 <<< $repo_slug) \
--token $token \
--since-tag ${LAST_RELEASE_TAG} \
--no-author \
--no-unreleased \
--header-label "## Changelog"

sed -i -e '3,5d' CHANGELOG.md
sed -i '$ d' CHANGELOG.md

echo "You can also find the corresponding documentation online under the following link: [Documentation $version](http://docs.inspectit.rocks/releases/$version)" > release_body.md
echo "" >> release_body.md
cat CHANGELOG.md >> release_body.md

body="$(cat release_body.md)"

# Overwrite CHANGELOG.md with JSON data for GitHub API
jq -n \
--arg body "$body" \
--arg name "Version $version" \
--arg tag_name "$version" \
--arg target_commitish "$branch" \
'{
body: $body,
name: $name,
tag_name: $tag_name,
target_commitish: $target_commitish,
draft: false,
prerelease: false
}' > CHANGELOG.md

echo "Create release $version for repo: $repo_slug, branch: $branch"
curl -H "Authorization: token $token" --data @CHANGELOG.md "https://api.github.com/repos/$repo_slug/releases"

0 comments on commit 4f5afba

Please sign in to comment.