-
Notifications
You must be signed in to change notification settings - Fork 7
/
release.gradle
61 lines (49 loc) · 1.66 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
buildscript {
repositories {
jcenter()
}
dependencies {
// http://github-api.kohsuke.org/
classpath "org.kohsuke:github-api:1.79"
}
}
String shell(String command) {
def proc = ["sh", "-c", "cd ${project.rootDir} ; ${command}"].execute()
if (proc.waitFor() != 0) {
throw new RuntimeException("Failed to run: ${command}\n${proc.err.text}")
} else {
def err = proc.err.text
if (err) {
System.err.println(err)
}
}
return proc.in.text;
}
def ext = project.rootProject.ext
task('release', dependsOn: stage) {
doLast {
assert ext.version
assert ext.githubOwner
assert ext.githubRepo
assert ext.artifactFile.exists()
assert ext.artifactContentType
println("release for ${ext.version}")
final github = org.kohsuke.github.GitHub.connect()
final repo = github.getRepository("${ext.githubOwner}/${ext.githubRepo}")
final message = """
Version v${version} of ${ext.githubOwner}/${ext.githubRepo}.
""".trim()
final release = repo.createRelease("v${ext.version}")
.name("v${ext.version}")
.body(message)
.commitish("master")
.create();
release.uploadAsset(ext.artifactFile, ext.artifactContentType)
final dockerTag = "ghcr.io/${ext.githubOwner}/${ext.githubRepo}:${version}"
shell("docker --version")
shell("docker login ghcr.io")
shell("docker build -t ${dockerTag} --build-arg PLANTUML_SERVICE_VERSION=${version} .")
shell("docker push ${dockerTag}")
println release.getHtmlUrl()
}
}