From e4262e3c1658232f093693537525bb89e926720d Mon Sep 17 00:00:00 2001 From: Andrei Date: Tue, 9 Aug 2016 15:15:06 -0300 Subject: [PATCH] #13 - Allow send files after the tag/release be created. --- README.md | 15 +++++++++++++++ .../SemanticReleaseChangeLogService.groovy | 10 ++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 377a034..64f5666 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,21 @@ semanticRelease { } ``` +### Enable upload release files to GitHub + +The **ghToken** is mandatory. + +```groovy +semanticRelease { + changeLog { + releaseAsset = { ReleaseAssets assets, String currentTag -> + assets.upload(file("build/libs/value-${currentTag}.jar").bytes, "application/zip", "run-${currentTag}.jar") + } + } +} +``` + + ### Setup travis-ci First, you need to [configure the environment variable GH_TOKEN in travis](http://docs.travis-ci.com/user/environment-variables/). Then you need a `.travis.yml` diff --git a/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleaseChangeLogService.groovy b/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleaseChangeLogService.groovy index 085484c..a76f45f 100644 --- a/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleaseChangeLogService.groovy +++ b/src/main/groovy/de/gliderpilot/gradle/semanticrelease/SemanticReleaseChangeLogService.groovy @@ -152,14 +152,14 @@ class SemanticReleaseChangeLogService { def type = { Commit commit -> def pattern = /(.*?)(?:\(.+\))?:.*/ def matcher = commit.shortMessage =~ pattern - matcher ? matcher.group(1) : null + matcher ? matcher.group(1).trim() : null } @PackageScope def component = { Commit commit -> def pattern = /.*?\((.+)\):.*/ def matcher = commit.shortMessage =~ pattern - matcher ? matcher.group(1) : null + matcher ? matcher.group(1).trim() : null } @PackageScope @@ -207,6 +207,11 @@ class SemanticReleaseChangeLogService { repositoryUrl("compare/${previousTag}...${currentTag}") } + @PackageScope + def releaseAsset = { ReleaseAssets assets, String currentTag -> + // waiting the custom implementation + } + @PackageScope @Memoized List commits(Version previousVersion) { @@ -237,6 +242,7 @@ class SemanticReleaseChangeLogService { Release release = repo.releases().create(tag) new Release.Smart(release).body(changeLog(commits(Version.valueOf(version.previousVersion)), version).toString()) + releaseAsset(release.assets(), "$version.version") } private boolean tagExists(Repo repo, String tag) {