Skip to content

Commit 267563d

Browse files
authored
feat(server): serve artifacts for specific versions (#1388)
Part of #1318. It doesn't yet support enumerating specific versions for e.g. dependency updating bots.
1 parent 9693c96 commit 267563d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

.github/workflows/test-script-consuming-jit-bindings.main.do-not-compile.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
// Nested action.
1111
@file:DependsOn("gradle:actions__setup-gradle:v3")
1212

13+
// Using specific version.
14+
@file:DependsOn("actions:cache:v3.3.3")
15+
16+
import io.github.typesafegithub.workflows.actions.actions.Cache
1317
import io.github.typesafegithub.workflows.actions.actions.Checkout
1418
import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle
1519

1620
println(Checkout())
1721
println(ActionsSetupGradle())
22+
println(Cache(path = listOf("some-path"), key = "some-key"))

action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ public fun ActionCoords.generateBinding(
7272
inputTypings: Pair<Map<String, Typing>, TypingActualSource?>? = null,
7373
clientType: ClientType = ClientType.BUNDLED_WITH_LIB,
7474
): ActionBinding? {
75-
require(this.version.removePrefix("v").toIntOrNull() != null) {
76-
"Only major versions are supported, and '${this.version}' was given!"
75+
if (clientType == ClientType.BUNDLED_WITH_LIB) {
76+
require(this.version.removePrefix("v").toIntOrNull() != null) {
77+
"Only major versions are supported, and '${this.version}' was given!"
78+
}
7779
}
7880
val metadataResolved = metadata ?: this.fetchMetadata(metadataRevision) ?: return null
7981
val metadataProcessed = metadataResolved.removeDeprecatedInputsIfNameClash()

action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProviding.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal fun ActionCoords.provideTypes(
2626
): Pair<Map<String, Typing>, TypingActualSource?> =
2727
(
2828
this.fetchTypingMetadata(metadataRevision, fetchUri)
29-
?: this.fetchFromTypingsFromCatalog(fetchUri)
29+
?: this.toMajorVersion().fetchFromTypingsFromCatalog(fetchUri)
3030
)
3131
?.let { Pair(it.first.toTypesMap(), it.second) }
3232
?: Pair(emptyMap(), null)
@@ -125,6 +125,8 @@ internal fun ActionTypes.toTypesMap(): Map<String, Typing> {
125125
}
126126
}
127127

128+
private fun ActionCoords.toMajorVersion(): ActionCoords = this.copy(version = this.version.substringBefore("."))
129+
128130
private fun ActionType.toTyping(fieldName: String): Typing =
129131
when (this.type) {
130132
ActionTypeEnum.String -> StringTyping

0 commit comments

Comments
 (0)