Repository: typesafegithub/github-workflows-kt
Pull request #1039 (2023-10-21 09:31:57)

[#941] fix(abg): adjust generated binding for script
It turned out that it's not necessary to add the dependency on the library or the shebang since the file isn't executed on its own, it's included by other scripts instead.


Patch:
diff --git a/automation/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Generation.kt b/automation/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Generation.kt
index 8e9632a6d..19665e0ca 100644
--- a/automation/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Generation.kt
+++ b/automation/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Generation.kt
@@ -104,26 +104,18 @@ private fun generateActionBindingSourceCode(
             if (generateForScript) "" else "io.github.typesafegithub.workflows.actions.${coords.owner.toKotlinPackageName()}",
             className,
         )
-            .apply {
-                if (!generateForScript) {
-                    addFileComment(
-                        """
-                        This file was generated using action-binding-generator. Don't change it by hand, otherwise your
-                        changes will be overwritten with the next binding code regeneration.
-                        See https://github.com/typesafegithub/github-workflows-kt for more info.
-                        """.trimIndent(),
-                    )
-                }
-            }
+            .addFileComment(
+                """
+                This file was generated using action-binding-generator. Don't change it by hand, otherwise your
+                changes will be overwritten with the next binding code regeneration.
+                See https://github.com/typesafegithub/github-workflows-kt for more info.
+                """.trimIndent(),
+            )
             .addType(generateActionClass(metadata, coords, inputTypings, className, generateForScript = generateForScript))
             .addSuppressAnnotation(metadata, coords)
             .indent("    ")
             .build()
     return buildString {
-        if (generateForScript) {
-            appendLine("#!/usr/bin/env kotlin")
-            appendLine("@file:DependsOn(\"io.github.typesafegithub:github-workflows-kt:$LIBRARY_VERSION\")")
-        }
         fileSpec.writeTo(this)
     }
 }


Test patch:
diff --git a/automation/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerationTest.kt b/automation/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerationTest.kt
index 979a950d2..7f7248a42 100644
--- a/automation/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerationTest.kt
+++ b/automation/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerationTest.kt
@@ -450,8 +450,9 @@ class GenerationTest : FunSpec({
         //language=kotlin
         binding.kotlinCode shouldBe
             """
-            #!/usr/bin/env kotlin
-            @file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.3.2-SNAPSHOT")
+            // This file was generated using action-binding-generator. Don't change it by hand, otherwise your
+            // changes will be overwritten with the next binding code regeneration.
+            // See https://github.com/typesafegithub/github-workflows-kt for more info.
             @file:Suppress(
                 "DataClassPrivateConstructor",
                 "UNUSED_PARAMETER",