-
Notifications
You must be signed in to change notification settings - Fork 3
Home
micro-common-release
is a set of release related Gradle build scripts which simplify the process of releasing the new version of a project. The key idea was to allow releasing project automatically from CI server (Travis is officially supported), but when needed the mechanism can be also used to release the new version manually from the workstation.
There is also a short presentation about micro-common-release
.
micro-common-release
covers 4 steps in the release process.
That step include:
- bumping the project version number
- making a release commit
- creating a version tag on created commit
The implementation internally uses Axion release plugin for Gradle.
The built artifacts are uploaded to the artifacts repository. Currently only Bintray is supported.
The release commit and tag are pushed to GitHub repository.
Uploaded artifacts are published (accepted) in Bintray and become available for others in Bintray and jcenter (if previously linked).
To trigger the release process just put somewhere into the commit message magic command [#DO_RELEASE]
. It doesn't have to be in the first line, e.g.
git commit -m "Trigger release" -m "[#DO_RELEASE]" --allow-empty
For testing purposes there was created releasing-sandbox project which can be freely modified and published to test new ideas which require CI server to run. Pay attention that all projects by default use the latest available version of micro-common-release
, so it is safer to test risky changes with SNAPSHOT versions.
- Add buildscript dependency to
com.ofg:micro-common-release
. - Add buildscript dependency to Gradle configuration files available in the package.
- Apply
version.gradle
and configure Axion plugin (scmVersion
configuration closure). - Apply
publish.gradle
andrelease.gradle
. - (Optional) Override default bintray task configuration (e.g. repo name).
- (Optional) Override default publishUploadedArtifacts configuration.
- Update Travis configuration (
.travis.yml
).
Note. By default 4financeBot
is used to commit (and push) changes. It's group Bots
has to have write access to given repository.
Sensitive variables (such as GH_TOKEN or BINTRAY_API_KEY) have to be encrypted before putting into .travis.yml
. Travis provides open source command line tool to achieve that. See Travis documentation (the last paragraph) for more details.
Note. Variables are encrypted in the project context. Therefore, they will not work when copied from the another project.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.ofg:micro-common-release:+"
}
dependencies {
ant.unjar src: configurations.classpath.find { it.name.startsWith("micro-common-release") }, dest: 'build/release'
}
}
apply from: "${rootProject.buildDir}/release/gradle/version.gradle"
scmVersion {
tag { prefix='custom-tag-prefix-if-wanted' }
}
project.group = 'com.ofg'
project.version = scmVersion.version
apply plugin: 'groovy' //or 'java'
apply from: "${rootProject.buildDir}/release/gradle/publish.gradle"
apply from: "${rootProject.buildDir}/release/gradle/release.gradle"
bintray {
pkg { repo = 'fancy-new-one' }
}
install:
- true
script:
- set -e
- ./gradlew check --info --stacktrace --continue -Pcoverage -Pcompatibility
- source build/release/gradle/setGitVariables.sh
- ./gradlew release -Prelease.disableRemoteCheck -Prelease.localOnly --info --stacktrace
- ./gradlew finalizeRelease publishUploadedArtifacts -PbintrayUser=${BINTRAY_USER} -PbintrayKey=${BINTRAY_API_KEY} --info --stacktrace
after_success:
- ./gradlew jacocoTestReport coveralls -Pcoverage
language: groovy
jdk:
- oraclejdk8
matrix:
include:
# Release not skipped only in Java 7 build
- jdk: oraclejdk7
env: SKIP_RELEASE=false
env:
global:
- TERM=dumb
- SKIP_RELEASE=true
- secure: <<encrypted GH_TOKEN>>
- secure: <<encrypted BINTRAY_USER>>
- secure: <<encrypted BINTRAY_API_KEY>>
To perform manual release -PlocalRelease
flag has to be used. It disables using CI specific variables and configuration. The process can be performed in a few separate steps.
Sample commands:
./gradlew release -Prelease.localOnly -PlocalRelease
./gradlew finalizeRelease -PlocalRelease
./gradlew publishUploadedArtifacts -PlocalRelease
Note. In case of problems with password protected SSH key in step 2 it could be done manually with:
./gradlew bintrayUpload -PlocalRelease
git push --follow-tags
- Currently only Travis is supported. Although it should be easy to add support for other CI servers.
Some parts of build scripts are based on release mechanism created by Szczepan Faber for Mockito.