Skip to content

Commit 5ac64f8

Browse files
authored
Add bump kotlin shadow job (#5999)
* Add bump kotlin shadow job * Update job name * Fetch latest versions
1 parent 5d86b23 commit 5ac64f8

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Bump kotlin nightlies
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
push-kotlin-nightlies-branch:
10+
runs-on: macos-14
11+
steps:
12+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
13+
- name: Bump Kotlin version
14+
run: ./scripts/bump-kotlin-nightlies.main.kts
15+
- name: Push changes to kotlin-nightlies branch
16+
run: |
17+
git checkout -b kotlin-nightlies
18+
git add .
19+
git commit -m "Bump Kotlin version"
20+
git push --force origin kotlin-nightlies
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env kotlin
2+
3+
import java.io.File
4+
import java.net.URL
5+
import javax.xml.parsers.DocumentBuilderFactory
6+
7+
fun main() {
8+
// Update versions in libraries.toml
9+
val kotlinVersion = getLatestVersion("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/org/jetbrains/kotlin/kotlin-stdlib/maven-metadata.xml")
10+
val kspVersion = getLatestVersion("https://oss.sonatype.org/content/repositories/snapshots/com/google/devtools/ksp/com.google.devtools.ksp.gradle.plugin/maven-metadata.xml")
11+
File("gradle/libraries.toml").let { file ->
12+
file.writeText(
13+
file.readText()
14+
.replaceVersion("kotlin-plugin", kotlinVersion)
15+
.replaceVersion("kotlin-plugin-max", kotlinVersion)
16+
.replaceVersion("kotlin-stdlib", kotlinVersion)
17+
.replaceVersion("ksp", kspVersion)
18+
)
19+
}
20+
21+
// Uncomment Kotlin dev maven repository, add Sonatype snapshots repository
22+
setOf(
23+
File("gradle/repositories.gradle.kts"),
24+
File("intellij-plugin/build.gradle.kts"),
25+
)
26+
.forEach { file ->
27+
file.writeText(
28+
file.readText()
29+
.replace(
30+
"""// maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") }""",
31+
"""
32+
maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") }
33+
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
34+
""".trimIndent()
35+
)
36+
)
37+
}
38+
}
39+
40+
fun String.replaceVersion(key: String, version: String): String {
41+
return replace(Regex("""$key = ".*""""), """$key = "$version"""")
42+
}
43+
44+
fun getLatestVersion(url: String): String {
45+
return URL(url)
46+
.openConnection()
47+
.getInputStream().use { inputStream ->
48+
DocumentBuilderFactory.newInstance()
49+
.newDocumentBuilder()
50+
.parse(inputStream)
51+
}
52+
.getElementsByTagName("latest")
53+
.item(0)
54+
.textContent
55+
}
56+
57+
main()

0 commit comments

Comments
 (0)