@@ -63,18 +63,45 @@ public fun ActionCoords.generateBinding(
63
63
64
64
val inputTypingsResolved = inputTypings ? : this .provideTypes(metadataRevision)
65
65
66
- val className = this .buildActionClassName()
67
- val actionBindingSourceCode =
68
- generateActionBindingSourceCode(metadataProcessed, this , inputTypingsResolved.first, className)
66
+ val classNameUntyped = this .buildActionClassName() + " _Untyped"
67
+ val actionBindingSourceCodeUntyped =
68
+ generateActionBindingSourceCode(metadataProcessed, this , emptyMap(), classNameUntyped, untyped = true )
69
+
70
+ val classNameAndSourceCodeTyped =
71
+ if (inputTypingsResolved.second != null ) {
72
+ val className = this .buildActionClassName()
73
+ val actionBindingSourceCode =
74
+ generateActionBindingSourceCode(
75
+ metadataProcessed,
76
+ this ,
77
+ inputTypingsResolved.first,
78
+ className,
79
+ untyped = false ,
80
+ )
81
+ Pair (className, actionBindingSourceCode)
82
+ } else {
83
+ null
84
+ }
85
+
69
86
val packageName = owner.toKotlinPackageName()
70
- return listOf (
87
+
88
+ return listOfNotNull(
71
89
ActionBinding (
72
- kotlinCode = actionBindingSourceCode ,
73
- filePath = " kotlin/io/github/typesafegithub/workflows/actions/$packageName /$className .kt" ,
74
- className = className ,
90
+ kotlinCode = actionBindingSourceCodeUntyped ,
91
+ filePath = " kotlin/io/github/typesafegithub/workflows/actions/$packageName /$classNameUntyped .kt" ,
92
+ className = classNameUntyped ,
75
93
packageName = packageName,
76
- typingActualSource = inputTypingsResolved.second ,
94
+ typingActualSource = null ,
77
95
),
96
+ classNameAndSourceCodeTyped?.let { (className, actionBindingSourceCode) ->
97
+ ActionBinding (
98
+ kotlinCode = actionBindingSourceCode,
99
+ filePath = " kotlin/io/github/typesafegithub/workflows/actions/$packageName /$className .kt" ,
100
+ className = className,
101
+ packageName = packageName,
102
+ typingActualSource = inputTypingsResolved.second,
103
+ )
104
+ },
78
105
)
79
106
}
80
107
@@ -96,6 +123,7 @@ private fun generateActionBindingSourceCode(
96
123
coords : ActionCoords ,
97
124
inputTypings : Map <String , Typing >,
98
125
className : String ,
126
+ untyped : Boolean ,
99
127
): String {
100
128
val fileSpec =
101
129
FileSpec
@@ -108,7 +136,7 @@ private fun generateActionBindingSourceCode(
108
136
changes will be overwritten with the next binding code regeneration.
109
137
See https://github.com/typesafegithub/github-workflows-kt for more info.
110
138
""" .trimIndent(),
111
- ).addType(generateActionClass(metadata, coords, inputTypings, className))
139
+ ).addType(generateActionClass(metadata, coords, inputTypings, className, untyped ))
112
140
.addSuppressAnnotation(metadata)
113
141
.indent(" " )
114
142
.build()
@@ -139,11 +167,12 @@ private fun generateActionClass(
139
167
coords : ActionCoords ,
140
168
inputTypings : Map <String , Typing >,
141
169
className : String ,
170
+ untyped : Boolean ,
142
171
): TypeSpec =
143
172
TypeSpec
144
173
.classBuilder(className)
145
174
.addModifiers(KModifier .DATA )
146
- .addKdoc(actionKdoc(metadata, coords))
175
+ .addKdoc(actionKdoc(metadata, coords, untyped ))
147
176
.inheritsFromRegularAction(coords, metadata, className)
148
177
.primaryConstructor(metadata.primaryConstructor(inputTypings, coords, className))
149
178
.properties(metadata, coords, inputTypings, className)
@@ -384,14 +413,44 @@ private fun ParameterSpec.Builder.defaultValueIfNullable(input: Input): Paramete
384
413
private fun actionKdoc (
385
414
metadata : Metadata ,
386
415
coords : ActionCoords ,
387
- ) = """
416
+ untyped : Boolean ,
417
+ ) = (
418
+ if (untyped) {
419
+ """
420
+ |```text
421
+ |!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
422
+ |!!! WARNING !!!
423
+ |!!! !!!
424
+ |!!! This action binding has no typings provided. All inputs will !!!
425
+ |!!! have a default type of String. !!!
426
+ |!!! To be able to use this action in a type-safe way, ask the !!!
427
+ |!!! action's owner to provide the typings using !!!
428
+ |!!! !!!
429
+ |!!! https://github.com/typesafegithub/github-actions-typing !!!
430
+ |!!! !!!
431
+ |!!! or if it's impossible, contribute typings to a community-driven !!!
432
+ |!!! !!!
433
+ |!!! https://github.com/typesafegithub/github-actions-typing-catalog !!!
434
+ |!!! !!!
435
+ |!!! This '_Untyped' binding will be available even once the typings !!!
436
+ |!!! are added. !!!
437
+ |!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
438
+ |```
439
+ |
440
+ |
441
+ """ .trimMargin()
442
+ } else {
443
+ " "
444
+ }
445
+ ) +
446
+ """
388
447
|Action: ${metadata.name.escapedForComments}
389
448
|
390
449
|${metadata.description.escapedForComments.removeTrailingWhitespacesForEachLine()}
391
450
|
392
451
|[Action on GitHub](https://github.com/${coords.owner} /${coords.name.substringBefore(
393
- ' /' ,
394
- )}${if (" /" in coords.name) " /tree/${coords.version} /${coords.name.substringAfter(' /' )} " else " " } )
452
+ ' /' ,
453
+ )}${if (" /" in coords.name) " /tree/${coords.version} /${coords.name.substringAfter(' /' )} " else " " } )
395
454
""" .trimMargin()
396
455
397
456
private fun Map <String , Typing >.getInputTyping (key : String ) = this [key] ? : StringTyping
0 commit comments