-
-
Notifications
You must be signed in to change notification settings - Fork 888
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
83 lines (75 loc) · 2.49 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
83 lines (75 loc) · 2.49 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import buildlogic.CiUtils
import buildlogic.versioning.getAppVersionString
import io.github.z4kn4fein.semver.toVersion
import io.github.z4kn4fein.semver.toVersionOrNull
import ir.amirab.git_version.core.semanticVersionRegex
import org.jetbrains.changelog.Changelog
plugins {
ir.amirab.`git-version-plugin`
/**
* retrieve latest versions of dependencies
*/
com.github.`ben-manes`.versions
id(Plugins.changeLog)
}
val defaultSemVersion = "1.0.0"
val fallBackVersion = "$defaultSemVersion-untagged"
gitVersion {
on {
branch(".+") {
"$defaultSemVersion-${it.refInfo.shortenName}-snapshot"
}
tag("v?${semanticVersionRegex}") {
it.matchResult.groups.get("version")!!.value
}
commit {
"$defaultSemVersion-sha.${it.refInfo.commitHash.take(5)}"
}
}
}
version = (gitVersion.getVersion() ?: fallBackVersion).toVersion()
logger.lifecycle("version: $version")
tasks.dependencyUpdates {
revision = "release"
outputFormatter = "html"
rejectVersionIf {
val candidateVersion = candidate.version.toVersionOrNull() ?: return@rejectVersionIf true
!candidateVersion.isStable
}
}
// ======= begin of GitHub action stuff
val ciDir = CiUtils.getCiDir(project)
changelog {
path.set(rootProject.layout.projectDirectory.dir("CHANGELOG.md").asFile.path)
version.set(getAppVersionString())
}
val createChangeNoteForCi = tasks.register("createChangeNoteForCi") {
inputs.property("appVersion", getAppVersionString())
inputs.file(changelog.path)
outputs.file(ciDir.changeNotesFile)
doLast {
val output = ciDir.changeNotesFile.get().asFile
val bodyText = with(changelog) {
getOrNull(getAppVersionString())?.let { item ->
renderItem(item, Changelog.OutputType.MARKDOWN)
}
}.orEmpty()
logger.lifecycle("changeNotes written in $output")
output.writeText(bodyText)
}
}
val createReleaseFolderForCi = tasks.register("createReleaseFolderForCi") {
val createBinariesForCi = CiUtils.getCreateBinaryFolderForCiTaskName()
dependsOn("desktop:app:$createBinariesForCi")
val skipAndroidBuild = System.getenv("SKIP_ANDROID_BUILD")
?.toBoolean()
?: false
if (!skipAndroidBuild) {
dependsOn("android:app:$createBinariesForCi")
}
val shouldGenerateChangelog = true
if (shouldGenerateChangelog) {
dependsOn(createChangeNoteForCi)
}
}
// ======= end of GitHub action stuff