Compare commits

...

2 commits

Author SHA1 Message Date
09d073c5f3 Bump version for release
Some checks are pending
Build & Test / Validate (push) Waiting to run
Build & Test / Run Unit Tests (push) Blocked by required conditions
Build & Test / Run UI Tests (push) Blocked by required conditions
2024-08-23 03:04:23 +00:00
51e5652475 Move changelog task to standalone file 2024-08-23 03:04:23 +00:00
3 changed files with 44 additions and 36 deletions

View file

@ -47,8 +47,8 @@ android {
applicationId = "com.wbrawner.simplemarkdown"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.maxSdk.get().toInt()
versionCode = 41
versionName = "0.8.16"
versionCode = 42
versionName = "1.0.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments["clearPackageData"] = "true"
buildConfigField("boolean", "ENABLE_CUSTOM_CSS", "true")

View file

@ -0,0 +1,39 @@
package com.wbrawner.releasehelper
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.model.ObjectFactory
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import javax.inject.Inject
private const val CHANGELOG_PATH = "src/play/play/release-notes/en-US/default.txt"
abstract class ChangelogTask @Inject constructor(objectFactory: ObjectFactory) : DefaultTask() {
@get:OutputFile
val changelogFile: RegularFileProperty = objectFactory.fileProperty()
init {
changelogFile.set(project.layout.projectDirectory.file(CHANGELOG_PATH))
}
@TaskAction
fun execute() {
val latestTag = "git describe --tags --abbrev=0".execute()
val changelog = "git log --format=\"%B\" ${latestTag.first().trim()}..".execute()
logger.info("Latest tag: $latestTag")
logger.info("Changelog: ${changelog.joinToString("\n")}")
changelogFile.get().asFile.writer().use { writer ->
writer.write(
changelog.joinToString("\n") { it.trim('"') }
)
}
}
private fun String.execute(): List<String> = ProcessBuilder()
.command(this.split(" "))
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.start()
.inputReader()
.readLines()
}

View file

@ -2,46 +2,15 @@ package com.wbrawner.releasehelper
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.Exec
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.provideDelegate
import java.io.ByteArrayOutputStream
import org.gradle.kotlin.dsl.register
import java.io.File
class ReleaseHelperPlugin : Plugin<Project> {
override fun apply(target: Project) {
target.tasks.register("getLatestTag", Exec::class.java) {
val latestTag = ByteArrayOutputStream()
standardOutput = latestTag
commandLine("git describe --tags --abbrev=0".split(" "))
doLast {
target.project.extra["latestTag"] = latestTag.toString().trim()
logger.info("Latest tag: ${target.project.extra["latestTag"]}")
}
}
target.tasks.register("changelog") {
val changelogFile = File(target.projectDir, "src/play/play/release-notes/en-US/default.txt")
inputs.property("tag", target.provider {
target.project.extra["latestTag"]
})
outputs.file(changelogFile)
dependsOn("getLatestTag")
doLast {
val latestTag: String by target.project.extra
val changelog = ByteArrayOutputStream()
target.exec {
standardOutput = changelog
commandLine = "git log --format=\"%B\" ${latestTag.trim()}..".split(" ")
}
changelogFile.writeText(
changelog.toString()
.split("\n")
.mapNotNull { it.trim('"').ifBlank { null } }
.joinToString("\n") { "- $it" }
)
}
}
target.tasks.register<ChangelogTask>("changelog")
target.tasks.register("majorRelease") {
dependsOn("changelog", "getLatestTag")