Skip to content

Instantly share code, notes, and snippets.

View krzema12's full-sized avatar

Piotr Krzemiński krzema12

View GitHub Profile
// No pinning - on each invocation,
// different action's revision may run.
@file:DependsOn("actions:checkout:v4")
// Pinning to a specific action's commit,
// but still different JARs can be used on
// each invocation. This is what is done for
// YAML-based workflows, and it's enough there.
@file:DependsOn("actions:checkout:11bd71901bbe5b1630ceea73d27597364c9af683") // v4.2.2
fun ActionCoords.buildVersionArtifacts(): Map<String, Artifact>? {
val jars = buildJars() ?: return null
val pom = buildPomFile()
val module = buildModuleFile()
return mapOf(
"$mavenName-$version.jar" to JarArtifact(jars.mainJar),
"$mavenName-$version.jar.md5" to TextArtifact { jars.mainJar().md5Checksum() },
"$mavenName-$version-sources.jar" to JarArtifact(jars.sourcesJar),
"$mavenName-$version-sources.jar.md5" to TextArtifact { jars.sourcesJar().md5Checksum() },
"$mavenName-$version.pom" to TextArtifact { pom },
val bindingsCache =
Cache
.Builder<ActionCoords, Result<Map<String, Artifact>>>()
.expireAfterWrite(1.hours)
.build()
routing {
route("{owner}/{name}/{version}/{file}") {
artifact(bindingsCache)
}
route("{owner}/{name}/{file}") {
metadata()
}
}
fun compileBinding(sourceFilePaths: List<Path>): Path {
val compilationOutput = createTempDirectory(prefix = "gwkt-classes_")
val args =
K2JVMCompilerArguments().apply {
destination = compilationOutput.toString()
classpath = System.getProperty("java.class.path")
freeArgs = sourceFilePaths.map { it.toString() }
noStdlib = true
noReflect = true
@file:Repository("https://some-custom-maven-repo.com/")
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:3.0.1")
// /\/\/\/\/\/\/\/\/\/\/\ | /\/\/\/\/\/\ | /\/\
// group ID artifact ID version
on:
push:
branches: [this-branch-must-never-be-created]
jobs:
some-job:
runs-on: ubuntu-latest
steps:
# List used actions below, as subsequent "- uses" items:
- uses: actions/checkout@v4
- id: 'step-1'
name: 'Generate action bindings'
run: '.github/workflows/generate-action-bindings.main.kts "build.yaml"'
#!/usr/bin/env kotlin
@file:DependsOn("io.github.typesafegithub:action-binding-generator:1.5.0")
import io.github.typesafegithub.workflows.actionbindinggenerator.generateActionBindings
generateActionBindings(args)
inputs:
ssh-strict:
type: boolean
persist-credentials:
type: boolean
clean:
type: boolean
fetch-depth:
type: integer
named-values: