Skip to content

Commit

Permalink
apply fix for dependencies and add (temporary) demo script
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkyAI committed Apr 20, 2024
1 parent c329c53 commit b6f24a0
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env kotlin

// usage:
// echo "" > summary.md && GITHUB_STEP_SUMMARY=summary.md GITHUB_TOKEN=$token ./outdated_workflow.main.kts
// echo "" > summary.md && GITHUB_STEP_SUMMARY=summary.md GITHUB_TOKEN=$token ./demo_updates.main.kts

@file:Repository("https://repo1.maven.org/maven2/")
@file:Repository("file://~/.m2/repository/")
Expand All @@ -11,25 +11,27 @@
"actions:checkout:v3",
"actions:setup-java:v3",
)
@file:DependsOn("actions:setup-node:v3")
@file:DependsOn("gradle:actions__setup-gradle:v3")

import io.github.typesafegithub.workflows.actions.actions.Checkout
import io.github.typesafegithub.workflows.actions.actions.SetupJava
import io.github.typesafegithub.workflows.actions.actions.SetupNode
import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle
import io.github.typesafegithub.workflows.domain.RunnerType
import io.github.typesafegithub.workflows.domain.triggers.PullRequest
import io.github.typesafegithub.workflows.domain.triggers.Push
import io.github.typesafegithub.workflows.dsl.expressions.expr
import io.github.typesafegithub.workflows.dsl.workflow
import io.github.typesafegithub.workflows.shared.internal.findGitRoot
import io.github.typesafegithub.workflows.updates.reportAvailableUpdates
import io.github.typesafegithub.workflows.yaml.writeToFile
import java.io.File
import kotlin.io.path.relativeTo

val workflow =
workflow(
name = "This is a example of a horribly outdated workflow",
name = "demo version updates",
on =
listOf(
PullRequest(),
Push(branches = listOf("action-updates")),
),
sourceFile = __FILE__.toPath(),
) {
Expand All @@ -44,22 +46,32 @@ val workflow =
action = Checkout(),
)
uses(
name = "setup jdk",
name = "Set up JDK",
action =
SetupJava(
javaPackage = SetupJava.JavaPackage.Jdk,
javaVersion = "21",
architecture = "x64",
distribution = SetupJava.Distribution.Adopt,
cache = SetupJava.BuildPlatform.Gradle,
javaVersion = "11",
distribution = SetupJava.Distribution.Zulu,
),
)
uses(
name = "setup nodejs",
action = SetupNode(),
uses(action = ActionsSetupGradle())
run(
name = "Publish to mavenLocal",
command = "./gradlew publishToMavenLocal",
)
val currentFile = __FILE__.toPath().relativeTo(File(".").toPath().findGitRoot())
run(
name = "execute script with github token",
command =
"""
'$currentFile'
""".trimIndent(),
env =
linkedMapOf(
"GITHUB_TOKEN" to expr("secrets.GITHUB_TOKEN"),
),
)
}
}

workflow.reportAvailableUpdates()
workflow.writeToFile(addConsistencyCheck = true)
workflow.writeToFile(addConsistencyCheck = false)
31 changes: 31 additions & 0 deletions .github/workflows/demo_updates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This file was generated using Kotlin DSL (.github/workflows/demo_updates.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt

name: 'demo version updates'
on:
pull_request: {}
jobs:
build:
runs-on: 'ubuntu-latest'
timeout-minutes: 30
steps:
- id: 'step-0'
name: 'checkout'
uses: 'actions/checkout@v3'
- id: 'step-1'
name: 'Set up JDK'
uses: 'actions/setup-java@v3'
with:
java-version: '11'
distribution: 'zulu'
- id: 'step-2'
uses: 'gradle/actions/setup-gradle@v3'
- id: 'step-3'
name: 'Publish to mavenLocal'
run: './gradlew publishToMavenLocal'
- id: 'step-4'
name: 'execute script with github token'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
run: '''.github/workflows/demo_updates.main.kts'''
4 changes: 2 additions & 2 deletions action-versions-updates/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ group = rootProject.group
version = rootProject.version

dependencies {
implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.0"))
implementation(("org.jetbrains.kotlinx:kotlinx-coroutines-core"))
// see https://youtrack.jetbrains.com/issue/KT-67618
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")

implementation(projects.githubWorkflowsKt)
implementation(projects.sharedInternal)
Expand Down
10 changes: 5 additions & 5 deletions shared-internal/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ group = rootProject.group
version = rootProject.version

dependencies {
implementation(platform("io.ktor:ktor-bom:2.3.10"))
implementation("io.ktor:ktor-client-core")
implementation("io.ktor:ktor-client-cio")
implementation("io.ktor:ktor-client-content-negotiation")
implementation("io.ktor:ktor-serialization-kotlinx-json")
// note: see https://youtrack.jetbrains.com/issue/KT-67618
implementation("io.ktor:ktor-client-core:2.3.10")
implementation("io.ktor:ktor-client-cio:2.3.10")
implementation("io.ktor:ktor-client-content-negotiation:2.3.10")
implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.10")
}

0 comments on commit b6f24a0

Please sign in to comment.