Repository: typesafegithub/github-workflows-kt (kotlin)

Issue:
Mark experimental APIs with OptIn annotation
https://kotlinlang.org/docs/opt-in-requirements.html#opt-in-to-using-api

Currently, only client-side action bindings generation should be marked this way.

Pull request:
Fixes #1207.

Patch:
diff --git a/action-binding-generator/api/action-binding-generator.api b/action-binding-generator/api/action-binding-generator.api
index f473d8ca7b..57f3f0959d 100644
--- a/action-binding-generator/api/action-binding-generator.api
+++ b/action-binding-generator/api/action-binding-generator.api
@@ -192,3 +192,6 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/Typ
 	public static fun values ()[Lio/github/typesafegithub/workflows/actionbindinggenerator/TypingActualSource;
 }
 
+public abstract interface annotation class io/github/typesafegithub/workflows/actionbindinggenerator/annotations/ExperimentalClientSideBindings : java/lang/annotation/Annotation {
+}
+
diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerateActionBindingsCliHelper.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerateActionBindingsCliHelper.kt
index d5f75996aa..da19971016 100644
--- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerateActionBindingsCliHelper.kt
+++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerateActionBindingsCliHelper.kt
@@ -1,5 +1,6 @@
 package io.github.typesafegithub.workflows.actionbindinggenerator
 
+import io.github.typesafegithub.workflows.actionbindinggenerator.annotations.ExperimentalClientSideBindings
 import io.github.typesafegithub.workflows.shared.internal.findGitRoot
 import java.nio.file.Path
 import kotlin.io.path.div
@@ -13,6 +14,7 @@ import kotlin.io.path.div
  * @param sourceFile Path to the script where this function is called from. Typically a result of an expression like
  * [__FILE__.toPath()].
  */
+@ExperimentalClientSideBindings
 public fun generateActionBindings(
     args: Array<String>,
     sourceFile: Path,
diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Generation.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Generation.kt
index f9d130b7ac..a237809165 100644
--- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Generation.kt
+++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/Generation.kt
@@ -143,6 +143,11 @@ private fun generateActionClass(
 ): TypeSpec {
     return TypeSpec.classBuilder(className)
         .addModifiers(KModifier.DATA)
+        .apply {
+            if (generateForScript) {
+                addExperimentalAnnotation()
+            }
+        }
         .addKdoc(actionKdoc(metadata, coords))
         .addMaybeDeprecated(coords)
         .inheritsFromRegularAction(coords, metadata, className, generateForScript = generateForScript)
@@ -156,6 +161,13 @@ private fun generateActionClass(
         .build()
 }
 
+private fun TypeSpec.Builder.addExperimentalAnnotation() {
+    addAnnotation(
+        AnnotationSpec.builder(ClassName("io.github.typesafegithub.workflows.annotations", "ExperimentalClientSideBindings"))
+            .build(),
+    )
+}
+
 private fun TypeSpec.Builder.addCustomTypes(
     typings: Map<String, Typing>,
     coords: ActionCoords,
diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/annotations/ExperimentalClientSideBindings.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/annotations/ExperimentalClientSideBindings.kt
new file mode 100644
index 0000000000..2ef13f59a6
--- /dev/null
+++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/annotations/ExperimentalClientSideBindings.kt
@@ -0,0 +1,4 @@
+package io.github.typesafegithub.workflows.actionbindinggenerator.annotations
+
+@RequiresOptIn
+public annotation class ExperimentalClientSideBindings
diff --git a/github-workflows-kt/api/github-workflows-kt.api b/github-workflows-kt/api/github-workflows-kt.api
index 858b9ccd19..72a89d4b34 100644
--- a/github-workflows-kt/api/github-workflows-kt.api
+++ b/github-workflows-kt/api/github-workflows-kt.api
@@ -1,3 +1,6 @@
+public abstract interface annotation class io/github/typesafegithub/workflows/annotations/ExperimentalClientSideBindings : java/lang/annotation/Annotation {
+}
+
 public abstract class io/github/typesafegithub/workflows/domain/AbstractResult {
 	public final fun eq (Lio/github/typesafegithub/workflows/domain/AbstractResult$Status;)Ljava/lang/String;
 	public final fun neq (Lio/github/typesafegithub/workflows/domain/AbstractResult$Status;)Ljava/lang/String;
diff --git a/github-workflows-kt/src/main/kotlin/io/github/typesafegithub/workflows/annotations/ExperimentalClientSideBindings.kt b/github-workflows-kt/src/main/kotlin/io/github/typesafegithub/workflows/annotations/ExperimentalClientSideBindings.kt
new file mode 100644
index 0000000000..0d62fba26c
--- /dev/null
+++ b/github-workflows-kt/src/main/kotlin/io/github/typesafegithub/workflows/annotations/ExperimentalClientSideBindings.kt
@@ -0,0 +1,4 @@
+package io.github.typesafegithub.workflows.annotations
+
+@RequiresOptIn
+public annotation class ExperimentalClientSideBindings


Test patch:
diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerateActionBindingsCliHelperTest.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerateActionBindingsCliHelperTest.kt
index 66c2fecb23..ea975dd4a2 100644
--- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerateActionBindingsCliHelperTest.kt
+++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerateActionBindingsCliHelperTest.kt
@@ -1,9 +1,11 @@
 package io.github.typesafegithub.workflows.actionbindinggenerator
 
+import io.github.typesafegithub.workflows.actionbindinggenerator.annotations.ExperimentalClientSideBindings
 import io.kotest.core.spec.style.FunSpec
 import io.kotest.engine.spec.tempdir
 import io.kotest.matchers.shouldBe
 
+@OptIn(ExperimentalClientSideBindings::class)
 class GenerateActionBindingsCliHelperTest : FunSpec({
     test("${::generateActionBindings.name} - smoke test") {
         // given
diff --git a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerationTest.kt b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerationTest.kt
index 5b04326824..1a584038d6 100644
--- a/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerationTest.kt
+++ b/action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/GenerationTest.kt
@@ -436,6 +436,7 @@ class GenerationTest : FunSpec({
                 "DEPRECATION",
             )
 
+            import io.github.typesafegithub.workflows.annotations.ExperimentalClientSideBindings
             import io.github.typesafegithub.workflows.domain.actions.Action
             import io.github.typesafegithub.workflows.domain.actions.RegularAction
             import java.util.LinkedHashMap
@@ -455,6 +456,7 @@ class GenerationTest : FunSpec({
              *
              * [Action on GitHub](https://github.com/john-smith/action-for-script)
              */
+            @ExperimentalClientSideBindings
             public data class ActionForScript private constructor(
                 /**
                  * Short description