Transcript
Page 1: Releasing with gradle (gradle summit 2014)
Page 2: Releasing with gradle (gradle summit 2014)

Releasing with

Gradlesnippets, puzzles, (best) practices

René GröschkePrincipal Engineer, GradlewareGradle Exchange 2014

Page 3: Releasing with gradle (gradle summit 2014)

Motivation

#gradlesummit 3/27

Page 4: Releasing with gradle (gradle summit 2014)

When doing a Release

#gradlesummit

update your project versiondeal with your vcs (tagging, branching)publish/deploy the released distributioninteract with your issue trackerdouble check your dependenciesrollback if build failed...

·

·

·

·

·

·

·

4/27

Page 5: Releasing with gradle (gradle summit 2014)

releasing manually?

#gradlesummit 5/27

!

Page 6: Releasing with gradle (gradle summit 2014)

#gradlesummit 6/27

Page 7: Releasing with gradle (gradle summit 2014)

demo app

#gradlesummit 7/27

Page 8: Releasing with gradle (gradle summit 2014)

project versioning

declaring a project version

#gradlesummit

// not optimal version = "1.1-SNAPSHOT"

// better version = file("version.txt").text ...

BUILD.GRADLE

8/27

Page 9: Releasing with gradle (gradle summit 2014)

project versioning (2)

put some semantics in your project version!

#gradlesummit

version = MyVersion.load(file("version.properties"))

class MyVersion { int major, minor, bugfix, build

String toString(){ "${major}.${minor}.${bugfix}.${build}" } ... }

BUILD.GRADLE

9/27

Page 10: Releasing with gradle (gradle summit 2014)

puzzle #1a (major|minor|bugfix) release

#gradlesummit 10/27

Page 11: Releasing with gradle (gradle summit 2014)

source versioning

interacting with your vcs (option 1)

#gradlesummit

buildscript { repositories { jcenter() } dependencies { classpath 'org.ajoberstar:gradle-git:0.8.0' } }

import org.ajoberstar.grgit.* ext.repo = Grgit.open(file('.'))

task tagRelease << { repo.tag.add {

name = version

message = "Release of ${version}"

}

}

BUILD.GRADLE

11/27

Page 12: Releasing with gradle (gradle summit 2014)

source versioning (2)

interacting with your vcs (option 2)

#gradlesummit

task tagGitWorkspace(type:Exec){ commandLine 'git', 'tag', project.version.toString() }

BUILD.GRADLE

12/27

Page 13: Releasing with gradle (gradle summit 2014)

source versioning (3)

sidenote: reading branch/commit via file io

#gradlesummit

def branch = file(".git/HEAD").text - "ref: refs/heads/" def commitId = file(".git/refs/heads/$branch").text

BUILD.GRADLE

13/27

Page 14: Releasing with gradle (gradle summit 2014)

puzzle #2a clean working copy

#gradlesummit 14/27

Page 15: Releasing with gradle (gradle summit 2014)

connect your issue tracker

worth the effort

#gradlesummit

keep version stati in syncdocument tackled issuescheck project status...

·

·

·

·

15/27

Page 16: Releasing with gradle (gradle summit 2014)

#gradlesummit 16/27

Page 17: Releasing with gradle (gradle summit 2014)

connect your issue tracker (2)

getting started

#gradlesummit

explore the api of your tool of choice!jira, youtrack, trello, githubREST is your friendREST is easy with gradle & groovy...

·

·

·

·

·

17/27

Page 18: Releasing with gradle (gradle summit 2014)

#gradlesummit

"but we have a custom tool!?"

GET RID OF IT!

18/27

Page 19: Releasing with gradle (gradle summit 2014)

puzzle #3connect your issue tracker

#gradlesummit 19/27

Page 20: Releasing with gradle (gradle summit 2014)

publishing

depends on your product

#gradlesummit

maven repository, bintray, maven-central out of the boxs3, ftp, ssh via custom gradle tasksfeed proprietary tools (e.g. liverebel)...

·

·

·

·

20/27

Page 21: Releasing with gradle (gradle summit 2014)

when something went wrong...

option 1

#gradlesummit 21/27

Page 22: Releasing with gradle (gradle summit 2014)

when something went wrong...

option 2: react on your build result

#gradlesummit

... gradle.addBuildListener(new BuildAdapter(){ void buildFinished(def result){ result.failure ? gitReset() : gitPush() } }) ...

BUILD.GRADLE

22/27

Page 23: Releasing with gradle (gradle summit 2014)

links and pointers

#gradlesummit

gradle.orggradleware.comsemantic version libraryGradle-Git Plugin (more than just a git plugin)Gradle SVN Kit pluginliverebelmy demo app

·

·

·

·

·

·

·

23/27

Page 24: Releasing with gradle (gradle summit 2014)

Q&A

#gradlesummit 24/27

Page 25: Releasing with gradle (gradle summit 2014)

Thanks for listening!

twitter @breskeby

www www.gradleware.com

github github.com/breskeby

Page 26: Releasing with gradle (gradle summit 2014)

references

#gradlesummit

http://devopsreactions.tumblr.com/post/70883605526/final-straight-on-a-projecthttp://www.youtube.com/watch?v=UyLUCnTdu7ohttp://devopsreactions.tumblr.com/post/49078186169/go-live-day

·

·

·

26/27

Page 27: Releasing with gradle (gradle summit 2014)

Top Related