Compare commits
2 commits
01978548c6
...
09d073c5f3
Author | SHA1 | Date | |
---|---|---|---|
09d073c5f3 | |||
51e5652475 |
3 changed files with 44 additions and 36 deletions
|
@ -47,8 +47,8 @@ android {
|
||||||
applicationId = "com.wbrawner.simplemarkdown"
|
applicationId = "com.wbrawner.simplemarkdown"
|
||||||
minSdk = libs.versions.minSdk.get().toInt()
|
minSdk = libs.versions.minSdk.get().toInt()
|
||||||
targetSdk = libs.versions.maxSdk.get().toInt()
|
targetSdk = libs.versions.maxSdk.get().toInt()
|
||||||
versionCode = 41
|
versionCode = 42
|
||||||
versionName = "0.8.16"
|
versionName = "1.0.0"
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
testInstrumentationRunnerArguments["clearPackageData"] = "true"
|
testInstrumentationRunnerArguments["clearPackageData"] = "true"
|
||||||
buildConfigField("boolean", "ENABLE_CUSTOM_CSS", "true")
|
buildConfigField("boolean", "ENABLE_CUSTOM_CSS", "true")
|
||||||
|
|
|
@ -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()
|
||||||
|
}
|
|
@ -2,46 +2,15 @@ package com.wbrawner.releasehelper
|
||||||
|
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.tasks.Exec
|
|
||||||
import org.gradle.kotlin.dsl.extra
|
import org.gradle.kotlin.dsl.extra
|
||||||
import org.gradle.kotlin.dsl.provideDelegate
|
import org.gradle.kotlin.dsl.provideDelegate
|
||||||
import java.io.ByteArrayOutputStream
|
import org.gradle.kotlin.dsl.register
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
class ReleaseHelperPlugin : Plugin<Project> {
|
class ReleaseHelperPlugin : Plugin<Project> {
|
||||||
override fun apply(target: Project) {
|
override fun apply(target: Project) {
|
||||||
target.tasks.register("getLatestTag", Exec::class.java) {
|
target.tasks.register<ChangelogTask>("changelog")
|
||||||
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("majorRelease") {
|
target.tasks.register("majorRelease") {
|
||||||
dependsOn("changelog", "getLatestTag")
|
dependsOn("changelog", "getLatestTag")
|
||||||
|
|
Loading…
Reference in a new issue