forked from amlcurran/ShowcaseView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.gradle
44 lines (37 loc) · 1.34 KB
/
release.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
task showcaseViewRelease << {
if (!project.hasProperty("versionName")) {
throw new TaskExecutionException(tasks['commitRelease'], new NullPointerException("No version name supplied"))
}
}
showcaseViewRelease.dependsOn('editReadme')
showcaseViewRelease.dependsOn('library:uploadArchives')
showcaseViewRelease.finalizedBy('commitRelease')
task commitRelease(type: Exec) {
commandLine 'git', "commit", "README.md", "-m", "Update to version " + getVersionName()
}
task createGithubRelease(type: Exec) {
def versionName = getVersionName()
def jsonData = JsonOutput.toJson([
tag_name: "$versionName",
name : "$versionName",
draft : true])
commandLine "curl", "--data", jsonData, "-u", "amlcurran:" + System.getenv('GITHUB_TOKEN'), "https://api.github.com/repos/amlcurran/ShowcaseView/releases"
}
import groovy.json.JsonOutput
import org.apache.tools.ant.filters.ReplaceTokens
task editReadme(type: Copy) {
from('.') {
include 'README-template.md'
rename('README-template.md', 'README.md')
filter(ReplaceTokens, tokens: ['version': versionName])
}
into '.'
}
def getVersionName() {
if (project.hasProperty("versionName")) {
return project.property("versionName")
} else {
println("using default version no.")
return ""
}
}