-
Notifications
You must be signed in to change notification settings - Fork 41
/
build.gradle.kts
185 lines (155 loc) · 6.67 KB
/
build.gradle.kts
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import java.io.ByteArrayOutputStream
plugins {
alias(libs.plugins.composeDesktop) apply false
alias(libs.plugins.compose.compiler) apply false
`jewel-linting`
}
dependencies {
sarif(projects.decoratedWindow)
sarif(projects.foundation)
sarif(projects.ideLafBridge)
sarif(projects.intUi.intUiDecoratedWindow)
sarif(projects.intUi.intUiStandalone)
sarif(projects.markdown.core)
sarif(projects.markdown.extension.autolink)
sarif(projects.markdown.extension.gfmAlerts)
sarif(projects.markdown.ideLafBridgeStyling)
sarif(projects.markdown.intUiStandaloneStyling)
sarif(projects.samples.idePlugin)
sarif(projects.samples.standalone)
sarif(projects.ui)
}
// TODO remove this once the Skiko fix makes it into CMP 1.7.1
allprojects {
configurations.all {
resolutionStrategy {
eachDependency {
if (requested.group == "org.jetbrains.skiko") {
useVersion("0.8.17")
because("Contains important memory usage fix")
}
}
}
}
}
tasks {
// val mergeSarifReports by
// registering(MergeSarifTask::class) {
// source(configurations.outgoingSarif)
// include { it.file.extension == "sarif" }
// }
//
// register("check") { dependsOn(mergeSarifReports) }
register("tagRelease") {
description = "Tags main branch and releases branches with provided tag name"
group = "release"
doFirst {
val rawReleaseVersion =
((project.property("jewel.release.version") as String?)?.takeIf { it.isNotBlank() }
?: throw GradleException("Please provide a jewel.release.version in gradle.properties"))
val releaseName = "v$rawReleaseVersion"
val stdOut = ByteArrayOutputStream()
// Check we're on the main branch
logger.info("Checking current branch is main...")
exec {
commandLine = listOf("git", "rev-parse", "--abbrev-ref", "HEAD")
standardOutput = stdOut
}
.assertNormalExitValue()
val currentBranch = stdOut.use { it.toString() }.trim()
if (currentBranch != "main") {
throw GradleException("This task must only be run on the main branch")
}
// Check tag doesn't already exist
logger.info("Checking current branch is main...")
stdOut.reset()
exec {
commandLine = listOf("git", "tag")
standardOutput = stdOut
}
.assertNormalExitValue()
if (stdOut.toString().trim().lines().any { it == releaseName }) {
throw GradleException("The tag $releaseName already exists!")
}
// Check there are no uncommitted changes
logger.info("Checking all changes have been committed...")
stdOut.reset()
exec {
commandLine = listOf("git", "status", "--porcelain")
standardOutput = stdOut
}
.assertNormalExitValue()
if (stdOut.toString().isNotBlank()) {
throw GradleException("Please commit all changes before tagging a release")
}
// Get the current HEAD hash
logger.info("Getting HEAD hash...")
stdOut.reset()
exec {
commandLine = listOf("git", "rev-parse", "HEAD")
standardOutput = stdOut
}
.assertNormalExitValue()
val currentHead = stdOut.use { it.toString() }.trim()
// Enumerate the release branches
logger.info("Enumerating release branches...")
stdOut.reset()
exec {
commandLine = listOf("git", "branch")
standardOutput = stdOut
}
.assertNormalExitValue()
val releaseBranches =
stdOut
.use { it.toString() }
.lines()
.filter { it.trim().startsWith("releases/") }
.map { it.trim().removePrefix("releases/") }
if (releaseBranches.isEmpty()) {
throw GradleException("No local release branches found, make sure they exist locally")
}
logger.lifecycle("Release branches: ${releaseBranches.joinToString { "releases/$it" }}")
// Check all release branches have gotten the latest from main
logger.info("Validating release branches...")
for (branch in releaseBranches) {
stdOut.reset()
exec {
commandLine = listOf("git", "merge-base", "main", "releases/$branch")
standardOutput = stdOut
}
.assertNormalExitValue()
val mergeBase = stdOut.use { it.toString() }.trim()
if (mergeBase != currentHead) {
throw GradleException("Branch releases/$branch is not up-to-date with main!")
}
}
// Tag main branch
logger.lifecycle("Tagging head of main branch as $releaseName...")
exec { commandLine = listOf("git", "tag", releaseName) }.assertNormalExitValue()
// Tag release branches
for (branch in releaseBranches) {
val branchTagName = "$releaseName-$branch"
logger.lifecycle("Tagging head of branch releases/$branch as $branchTagName...")
stdOut.reset()
logger.info("Getting branch head commit...")
exec {
commandLine = listOf("git", "rev-parse", "releases/$branch")
standardOutput = stdOut
}
.assertNormalExitValue()
val branchHead = stdOut.use { it.toString() }.trim()
logger.info("HEAD of releases/$branch is $branchHead")
logger.info("Tagging commit ${branchHead.take(7)} as $branchTagName")
stdOut.reset()
exec {
commandLine = listOf("git", "tag", branchTagName, branchHead)
standardOutput = stdOut
}
.assertNormalExitValue()
}
logger.info("All done!")
}
}
register<Delete>("cleanTestPublishArtifacts") { delete(rootProject.layout.buildDirectory.dir("maven-test")) }
register<Delete>("clean") { delete(rootProject.layout.buildDirectory) }
}