Skip to content

Commit

Permalink
Update grgit to 5.0.0 and use the new service plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Feb 16, 2023
1 parent 1f75544 commit 9d8be63
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 21 deletions.
5 changes: 3 additions & 2 deletions gradle/build-logic/build-logic.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ dependencyAnalysis {
includeDependency("net.wooga.github:net.wooga.github.gradle.plugin")
includeDependency("gradle.plugin.net.wooga.gradle:atlas-github")
}
bundle("org.ajoberstar.grgit.gradle.plugin") {
includeDependency("org.ajoberstar.grgit:org.ajoberstar.grgit.gradle.plugin")
bundle("org.ajoberstar.grgit.service.gradle.plugin") {
includeDependency("org.ajoberstar.grgit.service:org.ajoberstar.grgit.service.gradle.plugin")
includeDependency("org.ajoberstar.grgit:grgit-gradle")
includeDependency("org.ajoberstar.grgit:grgit-core")
}
bundle("org.jetbrains.kotlin.js.gradle.plugin") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import kotlin.LazyThreadSafetyMode.NONE
plugins {
// needed for accessing majorVersion
id("net.kautler.dependencies")
id("org.ajoberstar.grgit")
id("org.ajoberstar.grgit.service")
id("net.wooga.github")
}

Expand All @@ -72,7 +72,10 @@ release {
}

val githubRepositoryName by lazy(NONE) {
grgit
grgitService
.service
.get()
.grgit
.remote
.list()
.find { it.name == "origin" }
Expand Down Expand Up @@ -105,14 +108,23 @@ internal val github by lazy(NONE) {
}

val releaseBody by lazy(NONE) {
val releaseBody = grgit.log {
includes.add(release.git.requireBranch)
github.getRepository(githubRepositoryName).latestRelease?.apply { excludes.add(tagName) }
}.filter { commit ->
!commit.shortMessage.startsWith("[Gradle Release Plugin] ")
}.asReversed().joinToString("\n") { commit ->
"- ${commit.shortMessage} [${commit.id}]"
}
val releaseBody = grgitService
.service
.get()
.grgit
.log {
includes.add(release.git.requireBranch)
github.getRepository(githubRepositoryName).latestRelease?.apply {
excludes.add(tagName)
}
}
.filter { commit ->
!commit.shortMessage.startsWith("[Gradle Release Plugin] ")
}
.asReversed()
.joinToString("\n") { commit ->
"- ${commit.shortMessage} [${commit.id}]"
}

if (isHeadless()) {
return@lazy releaseBody
Expand Down Expand Up @@ -166,12 +178,18 @@ val releaseVersion get() = !"$version".endsWith("-SNAPSHOT")

val removeDistributionsFromGit by tasks.registering {
mustRunAfter(tasks.checkoutMergeFromReleaseBranch)
// work-around for https://github.com/ajoberstar/grgit/pull/382
//usesService(grgitService.service)

doLast("Remove distributions from Git") {
grgit.remove {
cached = true
patterns = setOf("build/distributions")
}
grgitService
.service
.get()
.grgit
.remove {
cached = true
patterns = setOf("build/distributions")
}
}
}
tasks.updateVersion {
Expand Down Expand Up @@ -210,6 +228,8 @@ tasks.withType<GithubPublish>().configureEach {
}

tasks.githubPublish {
// work-around for https://github.com/ajoberstar/grgit/pull/382
//usesService(grgitService.service)
body { releaseBody }
draft(true)
}
Expand All @@ -220,6 +240,8 @@ val undraftGithubRelease by tasks.registering(GithubPublish::class) {

val finishMilestone by tasks.registering {
enabled = releaseVersion
// work-around for https://github.com/ajoberstar/grgit/pull/382
//usesService(grgitService.service)

doLast("finish milestone") {
github.getRepository(githubRepositoryName)!!.apply {
Expand All @@ -237,15 +259,21 @@ val finishMilestone by tasks.registering {

val addDistributionsToGit by tasks.registering {
dependsOn(tasks.named("assemble"))
// work-around for https://github.com/ajoberstar/grgit/pull/382
//usesService(grgitService.service)

doLast("Add distributions to Git") {
val gitIgnore = file(".gitignore")
val gitIgnoreBak = file(".gitignore.bak")
gitIgnore.renameTo(gitIgnoreBak)
try {
grgit.add {
patterns = setOf("build/distributions")
}
grgitService
.service
.get()
.grgit
.add {
patterns = setOf("build/distributions")
}
} finally {
gitIgnoreBak.renameTo(gitIgnore)
}
Expand Down Expand Up @@ -285,6 +313,9 @@ tasks.updateVersion {
}

val checkBranchProtectionCompatibility by tasks.registering {
// work-around for https://github.com/ajoberstar/grgit/pull/382
//usesService(grgitService.service)

doLast {
check(
!github
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
build-github-api = "1.313"
build-gradle-plugin-dependency-analysis = "1.19.0"
build-gradle-plugin-github = "1.4.0"
build-gradle-plugin-grgit = "4.1.1"
build-gradle-plugin-grgit = "5.0.0"
build-gradle-plugin-refresh-versions = "0.51.0"
build-gradle-plugin-release = "2.8.1"
build-gradle-plugin-versions = "0.45.0"
Expand Down Expand Up @@ -62,7 +62,7 @@ convention-publishing = { id = "net.kautler.publishing", version = "?" }
convention-readme = { id = "net.kautler.readme", version = "?" }
dependency-analysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "build-gradle-plugin-dependency-analysis" }
github = { id = "net.wooga.github", version.ref = "build-gradle-plugin-github" }
grgit = { id = "org.ajoberstar.grgit", version.ref = "build-gradle-plugin-grgit" }
grgit = { id = "org.ajoberstar.grgit.service", version.ref = "build-gradle-plugin-grgit" }
kotlin-js = { id = "org.jetbrains.kotlin.js", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "build-kotlin" }
refresh-versions = { id = "de.fayard.refreshVersions", version.ref = "build-gradle-plugin-refresh-versions" }
Expand Down

0 comments on commit 9d8be63

Please sign in to comment.