Skip to content

Commit dbcf5d5

Browse files
authored
feat(library): add 'type' argument to Release trigger (#1783)
Closes #1781
1 parent 8661b26 commit dbcf5d5

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

github-workflows-kt/api/github-workflows-kt.api

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,12 +1554,14 @@ public final class io/github/typesafegithub/workflows/domain/triggers/RegistryPa
15541554
public final class io/github/typesafegithub/workflows/domain/triggers/Release : io/github/typesafegithub/workflows/domain/triggers/Trigger {
15551555
public static final field Companion Lio/github/typesafegithub/workflows/domain/triggers/Release$Companion;
15561556
public fun <init> ()V
1557-
public fun <init> (Ljava/util/Map;)V
1558-
public synthetic fun <init> (Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
1559-
public final fun component1 ()Ljava/util/Map;
1560-
public final fun copy (Ljava/util/Map;)Lio/github/typesafegithub/workflows/domain/triggers/Release;
1561-
public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/domain/triggers/Release;Ljava/util/Map;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/domain/triggers/Release;
1557+
public fun <init> (Ljava/util/List;Ljava/util/Map;)V
1558+
public synthetic fun <init> (Ljava/util/List;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
1559+
public final fun component1 ()Ljava/util/List;
1560+
public final fun component2 ()Ljava/util/Map;
1561+
public final fun copy (Ljava/util/List;Ljava/util/Map;)Lio/github/typesafegithub/workflows/domain/triggers/Release;
1562+
public static synthetic fun copy$default (Lio/github/typesafegithub/workflows/domain/triggers/Release;Ljava/util/List;Ljava/util/Map;ILjava/lang/Object;)Lio/github/typesafegithub/workflows/domain/triggers/Release;
15621563
public fun equals (Ljava/lang/Object;)Z
1564+
public final fun getTypes ()Ljava/util/List;
15631565
public fun get_customArguments ()Ljava/util/Map;
15641566
public fun hashCode ()I
15651567
public fun toString ()Ljava/lang/String;

github-workflows-kt/src/main/kotlin/io/github/typesafegithub/workflows/domain/triggers/Release.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ import kotlinx.serialization.Serializable
88
*/
99
@Serializable
1010
public data class Release(
11+
val types: List<String>? = null,
1112
override val _customArguments: Map<String, @Contextual Any> = mapOf(),
1213
) : Trigger()

github-workflows-kt/src/main/kotlin/io/github/typesafegithub/workflows/yaml/TriggersToYaml.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public fun Trigger.toMap(): Map<String, List<String>> =
5757
is PullRequest -> toMap()
5858
is PullRequestTarget -> toMap()
5959
is RepositoryDispatch -> toMap()
60+
is Release -> toMap()
6061
else -> emptyMap()
6162
}
6263

@@ -93,6 +94,11 @@ private fun RepositoryDispatch.toMap() =
9394
"types" to types,
9495
)
9596

97+
private fun Release.toMap() =
98+
mapOfNotNullValues(
99+
"types" to types,
100+
)
101+
96102
@Suppress("ComplexMethod")
97103
@InternalGithubActionsApi
98104
public fun Trigger.triggerName(): String =

github-workflows-kt/src/test/kotlin/io/github/typesafegithub/workflows/domain/triggers/OtherTriggersTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class OtherTriggersTest :
122122
PullRequestTarget(),
123123
Push(),
124124
RegistryPackage(types("published", "updated")),
125-
Release(types("published", "unpublished")),
125+
Release(types = listOf("published", "unpublished")),
126126
RepositoryDispatch(types = listOf("foo", "bar")),
127127
Schedule(emptyList()),
128128
Status(types("started")),

0 commit comments

Comments
 (0)