Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate correct changelog header & filename & link #133

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ tasks.named<JavaExec>("run").configure {
.map { it.absolutePath }
.joinToString(";")

val rewriteBomVersion =
configurations.detachedConfiguration(dependencies.create("org.openrewrite:rewrite-bom:latest.release"))
.resolvedConfiguration
.firstLevelModuleDependencies
.first()
.moduleVersion

val rewriteRecipeBomVersion =
configurations.detachedConfiguration(dependencies.create("org.openrewrite.recipe:rewrite-recipe-bom:latest.release"))
.resolvedConfiguration
Expand All @@ -171,6 +178,7 @@ tasks.named<JavaExec>("run").configure {
targetDir.toString(),
recipeModules,
recipeClasspath,
rewriteBomVersion,
rewriteRecipeBomVersion,
gradlePluginVersion,
mavenPluginVersion,
Expand Down
33 changes: 24 additions & 9 deletions src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,40 @@ class RecipeMarkdownGenerator : Runnable {
@Parameters(
index = "3",
defaultValue = "latest.release",
description = ["The version of the rewrite-bom to display on the changelog page"]
)
lateinit var rewriteBomVersion: String

@Parameters(
index = "4",
defaultValue = "latest.release",
description = ["The version of the rewrite-recipe-bom to display on all module versions page"]
)
lateinit var rewriteRecipeBomVersion: String

@Parameters(
index = "4",
index = "5",
defaultValue = "latest.release",
description = ["The version of the Rewrite Gradle Plugin to display in relevant samples"]
)
lateinit var gradlePluginVersion: String

@Parameters(
index = "5",
index = "6",
defaultValue = "",
description = ["The version of the Rewrite Maven Plugin to display in relevant samples"]
)
lateinit var mavenPluginVersion: String

@Parameters(
index = "6",
index = "7",
defaultValue = "release",
description = ["The type of deploy being done (either release or snapshot)"]
)
lateinit var deployType: String

@Parameters(
index = "7",
index = "8",
defaultValue = "renameMe",
description = ["The name of the diff file to be generated when making a diff log"]
)
Expand Down Expand Up @@ -320,6 +327,10 @@ class RecipeMarkdownGenerator : Runnable {
for (category in categories) {
write(category.summarySnippet(0))
}
write("""
* [Changelog](changelog/changelog.md)
* [$rewriteBomVersion Release (${getDateFormattedYYYYMMDD()})](/changelog/${rewriteBomVersion.replace('.','-')}-Release.md)
""".trimIndent())
}

// Write recipes-with-data-tables.md
Expand Down Expand Up @@ -465,12 +476,10 @@ class RecipeMarkdownGenerator : Runnable {
deployType: String
) {
// Get the date to label the changelog
val current = LocalDateTime.now()
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val formatted = current.format(formatter)
val formatted = getDateFormattedYYYYMMDD()

val changelog: File = if (deployType == "release") {
File("src/main/resources/CHANGELOG-$formatted.md")
File("src/main/resources/${rewriteBomVersion.replace('.','-')}-Release.md")
} else {
File("src/main/resources/snapshot-CHANGELOG-$formatted.md")
}
Expand All @@ -485,7 +494,7 @@ class RecipeMarkdownGenerator : Runnable {
changelog.appendText("\nWant to learn how to use snapshot versions in your project? Check out our [snapshot version guide](/reference/snapshot-instructions.md).")
changelog.appendText("\n{% endhint %}\n\n")
} else {
changelog.appendText("# X.XX.X release ($formatted)")
changelog.appendText("# $rewriteBomVersion release ($formatted)")

changelog.appendText("\n\n{% hint style=\"info\" %}")
changelog.appendText("\nThis changelog only shows what recipes have been added, removed, or changed. OpenRewrite may do releases that do not include these types of changes. To see these changes, please go to the [releases page](https://github.com/openrewrite/rewrite/releases).")
Expand Down Expand Up @@ -562,6 +571,12 @@ class RecipeMarkdownGenerator : Runnable {
}
}

private fun getDateFormattedYYYYMMDD(): String? {
val current = LocalDateTime.now()
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
return current.format(formatter)
}

private fun buildDiffLog(
newRecipes: TreeSet<MarkdownRecipeDescriptor>,
) {
Expand Down