Skip to content

Commit

Permalink
feat(actions): add actions/setup-java@v4
Browse files Browse the repository at this point in the history
  • Loading branch information
krzema12 committed Dec 5, 2023
1 parent a2489c7 commit ccebb81
Show file tree
Hide file tree
Showing 7 changed files with 288 additions and 8 deletions.
Empty file.
1 change: 1 addition & 0 deletions actions/actions/setup-java/v4/commit-hash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
387ac29b308b003ca37ba93a6cab5eb57c8f5f93
4 changes: 2 additions & 2 deletions docs/supported-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Click on a version to see the binding's code.
* [labeler](https://github.com/actions/labeler) - v4: [`LabelerV4`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/LabelerV4.kt)
* [setup-dotnet](https://github.com/actions/setup-dotnet) - v2: [`SetupDotnetV2`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupDotnetV2.kt), v3: [`SetupDotnetV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupDotnetV3.kt)
* [setup-go](https://github.com/actions/setup-go) - v3: [`SetupGoV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupGoV3.kt), v4: [`SetupGoV4`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupGoV4.kt)
* [setup-java](https://github.com/actions/setup-java) - v2: [`SetupJavaV2`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupJavaV2.kt), v3: [`SetupJavaV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupJavaV3.kt)
* [setup-java](https://github.com/actions/setup-java) - v2: [`SetupJavaV2`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupJavaV2.kt), v3: [`SetupJavaV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupJavaV3.kt), v4: [`SetupJavaV4`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupJavaV4.kt)
* [setup-node](https://github.com/actions/setup-node) - v2: [`SetupNodeV2`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupNodeV2.kt), v3: [`SetupNodeV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupNodeV3.kt), v4: [`SetupNodeV4`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupNodeV4.kt)
* [setup-python](https://github.com/actions/setup-python) - v2: [`SetupPythonV2`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupPythonV2.kt), v3: [`SetupPythonV3`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupPythonV3.kt), v4: [`SetupPythonV4`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/SetupPythonV4.kt)
* [stale](https://github.com/actions/stale) - v5: [`StaleV5`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/StaleV5.kt), v6: [`StaleV6`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/StaleV6.kt), v7: [`StaleV7`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/StaleV7.kt), v8: [`StaleV8`](https://github.com/typesafegithub/github-workflows-kt/blob/v[[ version ]]/library/src/gen/kotlin/io/github/typesafegithub/workflows/actions/actions/StaleV8.kt)
Expand Down Expand Up @@ -142,6 +142,6 @@ Click on a version to see the binding's code.
Number of bindings available:

* counting by actions: 85
* counting each version separately: 134
* counting each version separately: 135

Actions [providing typings](https://github.com/typesafegithub/github-actions-typing/) (marked with ✅ on the above list): 18
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import kotlin.collections.toTypedArray
* [Action on GitHub](https://github.com/actions/setup-java)
*/
@Deprecated(
message = "This action has a newer major version: SetupJavaV3",
replaceWith = ReplaceWith("SetupJavaV3"),
message = "This action has a newer major version: SetupJavaV4",
replaceWith = ReplaceWith("SetupJavaV4"),
)
public data class SetupJavaV2 private constructor(
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@file:Suppress(
"DataClassPrivateConstructor",
"UNUSED_PARAMETER",
"DEPRECATION",
)

package io.github.typesafegithub.workflows.actions.actions
Expand All @@ -12,6 +13,7 @@ import io.github.typesafegithub.workflows.domain.actions.Action
import io.github.typesafegithub.workflows.domain.actions.RegularAction
import java.util.LinkedHashMap
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
Expand All @@ -26,6 +28,10 @@ import kotlin.collections.toTypedArray
*
* [Action on GitHub](https://github.com/actions/setup-java)
*/
@Deprecated(
message = "This action has a newer major version: SetupJavaV4",
replaceWith = ReplaceWith("SetupJavaV4"),
)
public data class SetupJavaV3 private constructor(
/**
* The Java version to set up. Takes a whole or semver Java version. See examples of supported
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
// This file was generated using action-binding-generator. Don't change it by hand, otherwise your
// changes will be overwritten with the next binding code regeneration.
// See https://github.com/typesafegithub/github-workflows-kt for more info.
@file:Suppress(
"DataClassPrivateConstructor",
"UNUSED_PARAMETER",
)

package io.github.typesafegithub.workflows.actions.actions

import io.github.typesafegithub.workflows.domain.actions.Action
import io.github.typesafegithub.workflows.domain.actions.RegularAction
import java.util.LinkedHashMap
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map
import kotlin.collections.toList
import kotlin.collections.toTypedArray

/**
* Action: Setup Java JDK
*
* Set up a specific version of the Java JDK and add the command-line tools to the PATH
*
* [Action on GitHub](https://github.com/actions/setup-java)
*/
public data class SetupJavaV4 private constructor(
/**
* The Java version to set up. Takes a whole or semver Java version. See examples of supported
* syntax in README file
*/
public val javaVersion: String? = null,
/**
* The path to the `.java-version` file. See examples of supported syntax in README file
*/
public val javaVersionFile: String? = null,
/**
* Java distribution. See the list of supported distributions in README file
*/
public val distribution: SetupJavaV4.Distribution,
/**
* The package type (jdk, jre, jdk+fx, jre+fx)
*/
public val javaPackage: SetupJavaV4.JavaPackage? = null,
/**
* The architecture of the package (defaults to the action runner's architecture)
*/
public val architecture: String? = null,
/**
* Path to where the compressed JDK is located
*/
public val jdkFile: String? = null,
/**
* Set this option if you want the action to check for the latest available version that
* satisfies the version spec
*/
public val checkLatest: Boolean? = null,
/**
* ID of the distributionManagement repository in the pom.xml file. Default is `github`
*/
public val serverId: String? = null,
/**
* Environment variable name for the username for authentication to the Apache Maven repository.
* Default is $GITHUB_ACTOR
*/
public val serverUsername: String? = null,
/**
* Environment variable name for password or token for authentication to the Apache Maven
* repository. Default is $GITHUB_TOKEN
*/
public val serverPassword: String? = null,
/**
* Path to where the settings.xml file will be written. Default is ~/.m2.
*/
public val settingsPath: String? = null,
/**
* Overwrite the settings.xml file if it exists. Default is "true".
*/
public val overwriteSettings: Boolean? = null,
/**
* GPG private key to import. Default is empty string.
*/
public val gpgPrivateKey: String? = null,
/**
* Environment variable name for the GPG private key passphrase. Default is $GPG_PASSPHRASE.
*/
public val gpgPassphrase: String? = null,
/**
* Name of the build platform to cache dependencies. It can be "maven", "gradle" or "sbt".
*/
public val cache: SetupJavaV4.BuildPlatform? = null,
/**
* The path to a dependency file: pom.xml, build.gradle, build.sbt, etc. This option can be used
* with the `cache` option. If this option is omitted, the action searches for the dependency file
* in the entire repository. This option supports wildcards and a list of file names for caching
* multiple dependencies.
*/
public val cacheDependencyPath: String? = null,
/**
* Workaround to pass job status to post job step. This variable is not intended for manual
* setting
*/
public val jobStatus: String? = null,
/**
* The token used to authenticate when fetching version manifests hosted on github.com, such as
* for the Microsoft Build of OpenJDK. When running this action on github.com, the default value is
* sufficient. When running on GHES, you can pass a personal access token for github.com if you are
* experiencing rate limiting.
*/
public val token: String? = null,
/**
* Name of Maven Toolchain ID if the default name of "${distribution}_${java-version}" is not
* wanted. See examples of supported syntax in Advanced Usage file
*/
public val mvnToolchainId: String? = null,
/**
* Name of Maven Toolchain Vendor if the default name of "${distribution}" is not wanted. See
* examples of supported syntax in Advanced Usage file
*/
public val mvnToolchainVendor: String? = null,
/**
* Type-unsafe map where you can put any inputs that are not yet supported by the binding
*/
public val _customInputs: Map<String, String> = mapOf(),
/**
* Allows overriding action's version, for example to use a specific minor version, or a newer
* version that the binding doesn't yet know about
*/
public val _customVersion: String? = null,
) : RegularAction<SetupJavaV4.Outputs>("actions", "setup-java", _customVersion ?: "v4") {
public constructor(
vararg pleaseUseNamedArguments: Unit,
javaVersion: String? = null,
javaVersionFile: String? = null,
distribution: SetupJavaV4.Distribution,
javaPackage: SetupJavaV4.JavaPackage? = null,
architecture: String? = null,
jdkFile: String? = null,
checkLatest: Boolean? = null,
serverId: String? = null,
serverUsername: String? = null,
serverPassword: String? = null,
settingsPath: String? = null,
overwriteSettings: Boolean? = null,
gpgPrivateKey: String? = null,
gpgPassphrase: String? = null,
cache: SetupJavaV4.BuildPlatform? = null,
cacheDependencyPath: String? = null,
jobStatus: String? = null,
token: String? = null,
mvnToolchainId: String? = null,
mvnToolchainVendor: String? = null,
_customInputs: Map<String, String> = mapOf(),
_customVersion: String? = null,
) : this(javaVersion=javaVersion, javaVersionFile=javaVersionFile, distribution=distribution,
javaPackage=javaPackage, architecture=architecture, jdkFile=jdkFile,
checkLatest=checkLatest, serverId=serverId, serverUsername=serverUsername,
serverPassword=serverPassword, settingsPath=settingsPath,
overwriteSettings=overwriteSettings, gpgPrivateKey=gpgPrivateKey,
gpgPassphrase=gpgPassphrase, cache=cache, cacheDependencyPath=cacheDependencyPath,
jobStatus=jobStatus, token=token, mvnToolchainId=mvnToolchainId,
mvnToolchainVendor=mvnToolchainVendor, _customInputs=_customInputs,
_customVersion=_customVersion)

@Suppress("SpreadOperator")
override fun toYamlArguments(): LinkedHashMap<String, String> = linkedMapOf(
*listOfNotNull(
javaVersion?.let { "java-version" to it },
javaVersionFile?.let { "java-version-file" to it },
"distribution" to distribution.stringValue,
javaPackage?.let { "java-package" to it.stringValue },
architecture?.let { "architecture" to it },
jdkFile?.let { "jdkFile" to it },
checkLatest?.let { "check-latest" to it.toString() },
serverId?.let { "server-id" to it },
serverUsername?.let { "server-username" to it },
serverPassword?.let { "server-password" to it },
settingsPath?.let { "settings-path" to it },
overwriteSettings?.let { "overwrite-settings" to it.toString() },
gpgPrivateKey?.let { "gpg-private-key" to it },
gpgPassphrase?.let { "gpg-passphrase" to it },
cache?.let { "cache" to it.stringValue },
cacheDependencyPath?.let { "cache-dependency-path" to it },
jobStatus?.let { "job-status" to it },
token?.let { "token" to it },
mvnToolchainId?.let { "mvn-toolchain-id" to it },
mvnToolchainVendor?.let { "mvn-toolchain-vendor" to it },
*_customInputs.toList().toTypedArray(),
).toTypedArray()
)

override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId)

public sealed class Distribution(
public val stringValue: String,
) {
public object Adopt : SetupJavaV4.Distribution("adopt")

public object AdoptHotspot : SetupJavaV4.Distribution("adopt-hotspot")

public object AdoptOpenj9 : SetupJavaV4.Distribution("adopt-openj9")

public object Corretto : SetupJavaV4.Distribution("corretto")

public object Liberica : SetupJavaV4.Distribution("liberica")

public object Microsoft : SetupJavaV4.Distribution("microsoft")

public object Temurin : SetupJavaV4.Distribution("temurin")

public object Zulu : SetupJavaV4.Distribution("zulu")

public class Custom(
customStringValue: String,
) : SetupJavaV4.Distribution(customStringValue)
}

public sealed class JavaPackage(
public val stringValue: String,
) {
public object Jdk : SetupJavaV4.JavaPackage("jdk")

public object Jre : SetupJavaV4.JavaPackage("jre")

public object JdkPlusFx : SetupJavaV4.JavaPackage("jdk+fx")

public object JrePlusFx : SetupJavaV4.JavaPackage("jre+fx")

public class Custom(
customStringValue: String,
) : SetupJavaV4.JavaPackage(customStringValue)
}

public sealed class BuildPlatform(
public val stringValue: String,
) {
public object Maven : SetupJavaV4.BuildPlatform("maven")

public object Gradle : SetupJavaV4.BuildPlatform("gradle")

public object Sbt : SetupJavaV4.BuildPlatform("sbt")

public class Custom(
customStringValue: String,
) : SetupJavaV4.BuildPlatform(customStringValue)
}

public class Outputs(
stepId: String,
) : Action.Outputs(stepId) {
/**
* Distribution of Java that has been installed
*/
public val distribution: String = "steps.$stepId.outputs.distribution"

/**
* Actual version of the java environment that has been installed
*/
public val version: String = "steps.$stepId.outputs.version"

/**
* Path to where the java environment has been installed (same as $JAVA_HOME)
*/
public val path: String = "steps.$stepId.outputs.path"

/**
* A boolean value to indicate an exact match was found for the primary key
*/
public val cacheHit: String = "steps.$stepId.outputs.cache-hit"
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.typesafegithub.workflows.dsl

import io.github.typesafegithub.workflows.actions.actions.CheckoutV4
import io.github.typesafegithub.workflows.actions.actions.SetupJavaV3
import io.github.typesafegithub.workflows.actions.actions.SetupJavaV3.Distribution.Adopt
import io.github.typesafegithub.workflows.actions.actions.SetupJavaV4
import io.github.typesafegithub.workflows.actions.actions.SetupJavaV4.Distribution.Adopt
import io.github.typesafegithub.workflows.domain.RunnerType
import io.github.typesafegithub.workflows.domain.triggers.Push
import io.kotest.assertions.throwables.shouldThrow
Expand Down Expand Up @@ -44,11 +44,11 @@ class JobBuilderTest : FunSpec({
)
uses(
name = "Set up Java",
action = SetupJavaV3(distribution = Adopt, javaVersion = "11"),
action = SetupJavaV4(distribution = Adopt, javaVersion = "11"),
_customArguments = mapOf("foo4" to true),
)
uses(
action = SetupJavaV3(distribution = Adopt, javaVersion = "11"),
action = SetupJavaV4(distribution = Adopt, javaVersion = "11"),
_customArguments = mapOf("foo5" to true),
)
}
Expand Down

0 comments on commit ccebb81

Please sign in to comment.