diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f977812..a5be969 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -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") diff --git a/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ChangelogTask.kt b/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ChangelogTask.kt new file mode 100644 index 0000000..3f31e56 --- /dev/null +++ b/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ChangelogTask.kt @@ -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 = ProcessBuilder() + .command(this.split(" ")) + .redirectOutput(ProcessBuilder.Redirect.PIPE) + .start() + .inputReader() + .readLines() +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ReleaseHelperPlugin.kt b/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ReleaseHelperPlugin.kt index d275b79..82e1a3b 100644 --- a/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ReleaseHelperPlugin.kt +++ b/buildSrc/src/main/kotlin/com/wbrawner/releasehelper/ReleaseHelperPlugin.kt @@ -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 { 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("changelog") target.tasks.register("majorRelease") { dependsOn("changelog", "getLatestTag")