diff --git a/action-binding-generator/api/action-binding-generator.api b/action-binding-generator/api/action-binding-generator.api index 7bfbcb9a8b..9dc904e866 100644 --- a/action-binding-generator/api/action-binding-generator.api +++ b/action-binding-generator/api/action-binding-generator.api @@ -69,6 +69,7 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/dom } public final class io/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion : java/lang/Enum { + public static final field COMMIT_LENIENT Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion; public static final field FULL Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion; public static final field MAJOR Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion; public static final field MINOR Lio/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion; diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt index fa56886c15..4a3518509a 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt @@ -1,5 +1,6 @@ package io.github.typesafegithub.workflows.actionbindinggenerator.domain +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.COMMIT_LENIENT import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.FULL public data class ActionCoords( @@ -36,6 +37,8 @@ public val ActionCoords.prettyPrint: String get() = "$prettyPrintWithoutVersion@ public val ActionCoords.prettyPrintWithoutVersion: String get() = "$owner/$fullName${ significantVersion.takeUnless { it == FULL }?.let { " with $it version" } ?: "" +}${ + if ((significantVersion == COMMIT_LENIENT) && (comment != null)) " and comment '$comment'" else "" }" /** diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion.kt index 60662dd7d4..379ac02690 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/SignificantVersion.kt @@ -16,6 +16,11 @@ public enum class SignificantVersion { */ MINOR, + /** + * Write the commit ID as the version to the generated YAML. + */ + COMMIT_LENIENT, + /** * Write the full version to the generated YAML. */ diff --git a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt index cd940f86f0..4bd81df904 100644 --- a/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt +++ b/action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/generation/Generation.kt @@ -18,6 +18,7 @@ import com.squareup.kotlinpoet.buildCodeBlock import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionTypings import io.github.typesafegithub.workflows.actionbindinggenerator.domain.MetadataRevision +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.COMMIT_LENIENT import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.FULL import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.MAJOR import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.MINOR @@ -465,7 +466,7 @@ private fun TypeSpec.Builder.inheritsFromRegularAction( when (coords.significantVersion) { MAJOR -> coords.version.majorVersion MINOR -> coords.version.minorVersion - FULL -> coords.version + COMMIT_LENIENT, FULL -> coords.version }, ).also { if (coords.comment != null) { diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt index 6250381373..824d422841 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutes.kt @@ -2,7 +2,6 @@ package io.github.typesafegithub.workflows.jitbindingserver import com.sksamuel.aedile.core.LoadingCache import io.github.oshai.kotlinlogging.KotlinLogging.logger -import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords import io.github.typesafegithub.workflows.actionbindinggenerator.domain.TypingActualSource import io.github.typesafegithub.workflows.actionbindinggenerator.domain.prettyPrint import io.github.typesafegithub.workflows.mavenbinding.BindingsServerRequest @@ -105,19 +104,11 @@ private fun Route.getArtifact( } internal fun prefetchBindingArtifacts( - coords: Collection, + coords: Collection, bindingsCache: LoadingCache, ) { prefetchScope.launch { - bindingsCache.getAll( - coords.map { - BindingsServerRequest( - rawName = it.name, - rawVersion = it.version, - actionCoords = it, - ) - }, - ) + bindingsCache.getAll(coords) } } diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt index 6bcc59522e..77ea514214 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/Main.kt @@ -5,7 +5,6 @@ import com.sksamuel.aedile.core.LoadingCache import com.sksamuel.aedile.core.asLoadingCache import com.sksamuel.aedile.core.refreshAfterWrite import io.github.oshai.kotlinlogging.KotlinLogging.logger -import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords import io.github.typesafegithub.workflows.mavenbinding.BindingsServerRequest import io.github.typesafegithub.workflows.mavenbinding.VersionArtifacts import io.github.typesafegithub.workflows.mavenbinding.buildPackageArtifacts @@ -72,7 +71,7 @@ fun Application.appModule( buildPackageArtifacts: suspend ( BindingsServerRequest, String, - (Collection) -> Unit, + (Collection) -> Unit, MeterRegistry, ) -> Map, getGithubAuthToken: () -> String, @@ -119,7 +118,7 @@ private fun buildMetadataCache( buildPackageArtifacts: suspend ( BindingsServerRequest, String, - (Collection) -> Unit, + (Collection) -> Unit, MeterRegistry, ) -> Map, getGithubAuthToken: () -> String, @@ -128,7 +127,7 @@ private fun buildMetadataCache( .newBuilder() .refreshAfterWrite(1.hours) .recordStats() - .asLoadingCache { + .asLoadingCache { buildPackageArtifacts( it, getGithubAuthToken(), diff --git a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt index b8212eccc8..a16cdf3045 100644 --- a/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt +++ b/jit-binding-server/src/main/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsing.kt @@ -2,6 +2,7 @@ package io.github.typesafegithub.workflows.jitbindingserver import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.COMMIT_LENIENT import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.FULL import io.github.typesafegithub.workflows.mavenbinding.BindingsServerRequest import io.ktor.http.Parameters @@ -23,11 +24,6 @@ fun Parameters.parseRequest(extractVersion: Boolean): BindingsServerRequest? { .entries .find { "$it" == significantVersionString } } ?: FULL - val pinToCommit = - nameAndPathAndSignificantVersionParts - .drop(1) - .takeIf { it.isNotEmpty() } - ?.single() == "commit_lenient" val nameAndPathParts = nameAndPath.split("__") val name = nameAndPathParts.first() val path = @@ -38,7 +34,7 @@ fun Parameters.parseRequest(extractVersion: Boolean): BindingsServerRequest? { val version = if (extractVersion) { val versionPart = this["version"]!! - if (pinToCommit) { + if (significantVersion == COMMIT_LENIENT) { val versionParts = versionPart.split("__") if (versionParts.size < 2) { return null @@ -50,7 +46,8 @@ fun Parameters.parseRequest(extractVersion: Boolean): BindingsServerRequest? { } else { "irrelevant" } - val comment = if (pinToCommit && extractVersion) this["version"]!!.split("__")[0] else null + val comment = + if ((significantVersion == COMMIT_LENIENT) && extractVersion) this["version"]!!.split("__")[0] else null val versionForTypings = if (extractVersion) this["version"]!!.split("__")[0] else "irrelevant" return BindingsServerRequest( diff --git a/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutesTest.kt b/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutesTest.kt index 2379429e07..847408d02d 100644 --- a/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutesTest.kt +++ b/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutesTest.kt @@ -1,6 +1,5 @@ package io.github.typesafegithub.workflows.jitbindingserver -import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords import io.github.typesafegithub.workflows.actionbindinggenerator.domain.TypingActualSource import io.github.typesafegithub.workflows.mavenbinding.BindingsServerRequest import io.github.typesafegithub.workflows.mavenbinding.TextArtifact diff --git a/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/MetadataRoutesTest.kt b/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/MetadataRoutesTest.kt index 628c1ac56f..66b81b4c2e 100644 --- a/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/MetadataRoutesTest.kt +++ b/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/MetadataRoutesTest.kt @@ -107,7 +107,7 @@ class MetadataRoutesTest : ( BindingsServerRequest, String, - (Collection) -> Unit, + (Collection) -> Unit, MeterRegistry?, ) -> Map, >() diff --git a/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsingTest.kt b/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsingTest.kt index c1f3da3e42..4e968f118d 100644 --- a/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsingTest.kt +++ b/jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/RequestParsingTest.kt @@ -1,6 +1,7 @@ package io.github.typesafegithub.workflows.jitbindingserver import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.COMMIT_LENIENT import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.FULL import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.MAJOR import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.MINOR @@ -123,7 +124,7 @@ class RequestParsingTest : owner = "o", name = "act", version = "323898970401d85df44b3324a610af9a862d54b3", - significantVersion = FULL, + significantVersion = COMMIT_LENIENT, comment = "v1.2.3", versionForTypings = "v1.2.3", path = null, diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuilding.kt index bb3a54fa54..ccc4ab6f09 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuilding.kt @@ -4,6 +4,7 @@ import arrow.core.Either import arrow.core.getOrElse import io.github.oshai.kotlinlogging.KotlinLogging.logger import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords +import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.COMMIT_LENIENT import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.FULL import io.github.typesafegithub.workflows.shared.internal.fetchAvailableVersions import io.github.typesafegithub.workflows.shared.internal.model.Version @@ -12,7 +13,7 @@ import java.time.format.DateTimeFormatter private val logger = logger { } -internal suspend fun ActionCoords.buildMavenMetadataFile( +internal suspend fun BindingsServerRequest.buildMavenMetadataFile( githubAuthToken: String, meterRegistry: MeterRegistry? = null, fetchAvailableVersions: suspend ( @@ -21,15 +22,28 @@ internal suspend fun ActionCoords.buildMavenMetadataFile( githubAuthToken: String?, meterRegistry: MeterRegistry?, ) -> Either> = ::fetchAvailableVersions, - prefetchBindingArtifacts: (Collection) -> Unit = {}, + prefetchBindingArtifacts: (Collection) -> Unit = {}, ): String? { val availableVersions = - fetchAvailableVersions(owner, name, githubAuthToken, meterRegistry) + fetchAvailableVersions(actionCoords.owner, actionCoords.name, githubAuthToken, meterRegistry) .getOrElse { logger.error { it } emptyList() - }.filter { it.isMajorVersion() || (significantVersion < FULL) } - prefetchBindingArtifacts(availableVersions.map { copy(version = "$it") }) + }.filter { it.isMajorVersion() || (actionCoords.significantVersion < FULL) } + val commitLenient = actionCoords.significantVersion == COMMIT_LENIENT + prefetchBindingArtifacts( + availableVersions.map { + copy( + rawVersion = "$it${if (commitLenient) "__${it.sha}" else ""}", + actionCoords = + actionCoords.copy( + version = if (commitLenient) it.sha!! else "$it", + comment = if (commitLenient) "$it" else null, + versionForTypings = "$it", + ), + ) + }, + ) val newest = availableVersions.maxOrNull() ?: return null val lastUpdated = DateTimeFormatter @@ -38,14 +52,14 @@ internal suspend fun ActionCoords.buildMavenMetadataFile( return """ - $owner - $name + ${actionCoords.owner} + $rawName - $newest - $newest + $newest${if (commitLenient) "__${newest.sha}" else ""} + $newest${if (commitLenient) "__${newest.sha}" else ""} ${availableVersions.joinToString(separator = "\n") { - " $it" + " $it${if (commitLenient) "__${it.sha}" else ""}" }} $lastUpdated diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuilding.kt index 2641d37bbc..f9b98d6625 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/ModuleBuilding.kt @@ -16,8 +16,8 @@ internal fun BindingsServerRequest.buildModuleFile( "formatVersion": "1.1", "component": { "group": "${actionCoords.owner}", - "module": "${actionCoords.name}", - "version": "${actionCoords.version}", + "module": "$rawName", + "version": "$rawVersion", "attributes": { "org.gradle.status": "release" } @@ -42,7 +42,7 @@ internal fun BindingsServerRequest.buildModuleFile( "files": [ { "name": "$rawName-$rawVersion.jar", - "url": "$rawName-$rawName.jar", + "url": "$rawName-$rawVersion.jar", "size": $mainJarSize, "sha512": "$mainJarSha512Checksum", "sha256": "$mainJarSha256Checksum", diff --git a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PackageArtifactsBuilding.kt b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PackageArtifactsBuilding.kt index 2eb4de1a34..cf1827b2bc 100644 --- a/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PackageArtifactsBuilding.kt +++ b/maven-binding-builder/src/main/kotlin/io/github/typesafegithub/workflows/mavenbinding/PackageArtifactsBuilding.kt @@ -6,11 +6,11 @@ import io.micrometer.core.instrument.MeterRegistry suspend fun buildPackageArtifacts( bindingsServerRequest: BindingsServerRequest, githubAuthToken: String, - prefetchBindingArtifacts: (Collection) -> Unit, + prefetchBindingArtifacts: (Collection) -> Unit, meterRegistry: MeterRegistry, ): Map { val mavenMetadata = - bindingsServerRequest.actionCoords.buildMavenMetadataFile( + bindingsServerRequest.buildMavenMetadataFile( githubAuthToken = githubAuthToken, prefetchBindingArtifacts = prefetchBindingArtifacts, meterRegistry = meterRegistry, diff --git a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt index ada7c1ce6f..d0ab5bd85d 100644 --- a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt +++ b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt @@ -14,11 +14,16 @@ import java.time.ZonedDateTime class MavenMetadataBuildingTest : FunSpec({ - val actionCoords = - ActionCoords( - owner = "owner", - name = "name", - version = "irrelevant", + val bindingsServerRequest = + BindingsServerRequest( + rawName = "name", + rawVersion = null, + actionCoords = + ActionCoords( + owner = "owner", + name = "name", + version = "irrelevant", + ), ) test("various kinds of versions available") { @@ -42,7 +47,7 @@ class MavenMetadataBuildingTest : } val xml = - actionCoords.buildMavenMetadataFile( + bindingsServerRequest.buildMavenMetadataFile( githubAuthToken = "SOME_TOKEN", fetchAvailableVersions = fetchAvailableVersions, ) @@ -84,7 +89,7 @@ class MavenMetadataBuildingTest : } val xml = - actionCoords.buildMavenMetadataFile( + bindingsServerRequest.buildMavenMetadataFile( githubAuthToken = "SOME_TOKEN", fetchAvailableVersions = fetchAvailableVersions, ) @@ -104,7 +109,7 @@ class MavenMetadataBuildingTest : } val xml = - actionCoords.buildMavenMetadataFile( + bindingsServerRequest.buildMavenMetadataFile( githubAuthToken = "SOME_TOKEN", fetchAvailableVersions = fetchAvailableVersions, ) @@ -122,41 +127,80 @@ class MavenMetadataBuildingTest : MeterRegistry?, ) -> Either> = { owner, name, _, _ -> listOf( - Version(version = "v3-beta", dateProvider = { ZonedDateTime.parse("2024-07-01T00:00:00Z") }), - Version(version = "v2", dateProvider = { ZonedDateTime.parse("2024-05-01T00:00:00Z") }), - Version(version = "v1", dateProvider = { ZonedDateTime.parse("2024-03-07T00:00:00Z") }), - Version(version = "v1.1", dateProvider = { ZonedDateTime.parse("2024-03-07T00:00:00Z") }), - Version(version = "v1.1.0", dateProvider = { ZonedDateTime.parse("2024-03-07T00:00:00Z") }), - Version(version = "v1.0.1", dateProvider = { ZonedDateTime.parse("2024-03-05T00:00:00Z") }), - Version(version = "v1.0", dateProvider = { ZonedDateTime.parse("2024-03-01T00:00:00Z") }), - Version(version = "v1.0.0", dateProvider = { ZonedDateTime.parse("2024-03-01T00:00:00Z") }), + Version( + version = "v3-beta", + sha = "1", + dateProvider = { ZonedDateTime.parse("2024-07-01T00:00:00Z") }, + ), + Version( + version = "v2", + sha = "2", + dateProvider = { ZonedDateTime.parse("2024-05-01T00:00:00Z") }, + ), + Version( + version = "v1", + sha = "3", + dateProvider = { ZonedDateTime.parse("2024-03-07T00:00:00Z") }, + ), + Version( + version = "v1.1", + sha = "4", + dateProvider = { ZonedDateTime.parse("2024-03-07T00:00:00Z") }, + ), + Version( + version = "v1.1.0", + sha = "5", + dateProvider = { ZonedDateTime.parse("2024-03-07T00:00:00Z") }, + ), + Version( + version = "v1.0.1", + sha = "6", + dateProvider = { ZonedDateTime.parse("2024-03-05T00:00:00Z") }, + ), + Version( + version = "v1.0", + sha = "7", + dateProvider = { ZonedDateTime.parse("2024-03-01T00:00:00Z") }, + ), + Version( + version = "v1.0.0", + sha = "8", + dateProvider = { ZonedDateTime.parse("2024-03-01T00:00:00Z") }, + ), ).right() } val xml = - actionCoords.copy(significantVersion = significantVersion).buildMavenMetadataFile( - githubAuthToken = "SOME_TOKEN", - fetchAvailableVersions = fetchAvailableVersions, - ) + bindingsServerRequest + .copy( + rawName = "name___$significantVersion", + actionCoords = + bindingsServerRequest.actionCoords.copy( + significantVersion = significantVersion, + ), + ).buildMavenMetadataFile( + githubAuthToken = "SOME_TOKEN", + fetchAvailableVersions = fetchAvailableVersions, + ) xml shouldBe """ owner - name + name___$significantVersion - v2 - v2 + v2${if (significantVersion == SignificantVersion.COMMIT_LENIENT) "__2" else ""} + v2${if (significantVersion == SignificantVersion.COMMIT_LENIENT) "__2" else ""} - v3-beta - v2 - v1 - v1.1 - v1.1.0 - v1.0.1 - v1.0 - v1.0.0 + v3-beta${if (significantVersion == SignificantVersion.COMMIT_LENIENT) "__1" else ""} + v2${if (significantVersion == SignificantVersion.COMMIT_LENIENT) "__2" else ""} + v1${if (significantVersion == SignificantVersion.COMMIT_LENIENT) "__3" else ""} + v1.1${if (significantVersion == SignificantVersion.COMMIT_LENIENT) "__4" else ""} + v1.1.0${if (significantVersion == SignificantVersion.COMMIT_LENIENT) "__5" else ""} + v1.0.1${if (significantVersion == SignificantVersion.COMMIT_LENIENT) "__6" else ""} + v1.0${if (significantVersion == SignificantVersion.COMMIT_LENIENT) "__7" else ""} + v1.0.0${if (significantVersion == SignificantVersion.COMMIT_LENIENT) "__8" else ""} 20240501000000 diff --git a/shared-internal/src/main/kotlin/io/github/typesafegithub/workflows/shared/internal/GithubApi.kt b/shared-internal/src/main/kotlin/io/github/typesafegithub/workflows/shared/internal/GithubApi.kt index 54a3eadc7a..1a5db674c3 100644 --- a/shared-internal/src/main/kotlin/io/github/typesafegithub/workflows/shared/internal/GithubApi.kt +++ b/shared-internal/src/main/kotlin/io/github/typesafegithub/workflows/shared/internal/GithubApi.kt @@ -49,7 +49,7 @@ private fun List.versions( either { this@versions.map { githubRef -> val version = githubRef.ref.substringAfterLast("/") - Version(version) { + Version(version, githubRef.`object`.sha) { val response = buildHttpClient(meterRegistry = meterRegistry).use { httpClient -> httpClient @@ -111,6 +111,7 @@ private data class GithubRef( @Serializable private data class Object( val type: String, + val sha: String, val url: String, ) diff --git a/shared-internal/src/main/kotlin/io/github/typesafegithub/workflows/shared/internal/model/Version.kt b/shared-internal/src/main/kotlin/io/github/typesafegithub/workflows/shared/internal/model/Version.kt index e2f5cd5821..337b79bbb7 100644 --- a/shared-internal/src/main/kotlin/io/github/typesafegithub/workflows/shared/internal/model/Version.kt +++ b/shared-internal/src/main/kotlin/io/github/typesafegithub/workflows/shared/internal/model/Version.kt @@ -4,6 +4,7 @@ import java.time.ZonedDateTime data class Version( val version: String, + val sha: String? = null, private val dateProvider: suspend () -> ZonedDateTime? = { null }, ) : Comparable { private val versionParts: List = version.removePrefix("v").removePrefix("V").split('.')