mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
Add automation for updating library release versions
Automated script was added to update library release versions in a separate 'v-releases.list' file. To ensure regular updates, a GitHub Action was added to run the update script on a daily basis.
This commit is contained in:
parent
c935642591
commit
b1a3299973
64
.github/scripts/libraries_releases.main.kts
vendored
Executable file
64
.github/scripts/libraries_releases.main.kts
vendored
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/env kotlin
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This script is used to update the versions of libraries stored in the v-releases.list releases file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import java.net.HttpURLConnection
|
||||||
|
import java.net.URL
|
||||||
|
|
||||||
|
val FILE_PATH = "v-releases.list"
|
||||||
|
val UNKNOWN = "unknown"
|
||||||
|
|
||||||
|
val releasesList = mapOf(
|
||||||
|
"gradle-intellij-plugin-version" to ReleaseInfo(
|
||||||
|
type = ReleaseType.GitHub,
|
||||||
|
url = "https://github.com/JetBrains/gradle-intellij-plugin/releases/latest",
|
||||||
|
),
|
||||||
|
"gradle-grammar-kit-plugin-version" to ReleaseInfo(
|
||||||
|
type = ReleaseType.GitHub,
|
||||||
|
url = "https://github.com/JetBrains/gradle-grammar-kit-plugin/releases/latest",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
val vars = releasesList.mapValues { (key, releaseInfo) ->
|
||||||
|
when (releaseInfo.type) {
|
||||||
|
ReleaseType.GitHub -> run {
|
||||||
|
try {
|
||||||
|
URL(releaseInfo.url).openConnection().run {
|
||||||
|
(this as HttpURLConnection).instanceFollowRedirects = false
|
||||||
|
getHeaderField("Location").split('/').last().removePrefix("v")
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Cannot resolve the latest $key version")
|
||||||
|
UNKNOWN
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.map { (key, version) ->
|
||||||
|
"<var name=\"$key\" value=\"$version\"/>"
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE vars
|
||||||
|
SYSTEM "https://helpserver.labs.jb.gg/help/schemas/mvp/vars.dtd">
|
||||||
|
|
||||||
|
<vars>
|
||||||
|
${vars.joinToString("\n ")}
|
||||||
|
</vars>
|
||||||
|
""".trimStart().let(file(FILE_PATH)::writeText)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fun file(path: String) = File(System.getenv("GITHUB_WORKSPACE") ?: "../../").resolve(path).also(File::createNewFile)
|
||||||
|
|
||||||
|
enum class ReleaseType {
|
||||||
|
GitHub
|
||||||
|
}
|
||||||
|
|
||||||
|
data class ReleaseInfo(
|
||||||
|
val type: ReleaseType,
|
||||||
|
val url: String,
|
||||||
|
)
|
19
.github/workflows/generate-libraries-releases.yml
vendored
Normal file
19
.github/workflows/generate-libraries-releases.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Generate Libraries releases variable file
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "1 1 * * *"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Generate
|
||||||
|
run: "${GITHUB_WORKSPACE}/.github/scripts/libraries_releases.main.kts"
|
||||||
|
- name: Commit changes
|
||||||
|
uses: Endbug/add-and-commit@v9
|
||||||
|
with:
|
||||||
|
message: 'Generate Libraries releases variable file'
|
||||||
|
add: 'v-releases.list'
|
@ -11,6 +11,7 @@
|
|||||||
<topics dir="reference_guide"/>
|
<topics dir="reference_guide"/>
|
||||||
<images dir="images" web-path="/img/idea-sdk/"/>
|
<images dir="images" web-path="/img/idea-sdk/"/>
|
||||||
<vars src="v.list" />
|
<vars src="v.list" />
|
||||||
|
<vars src="v-releases.list" />
|
||||||
<snippets dir="code_samples"/>
|
<snippets dir="code_samples"/>
|
||||||
<instance src="ijs.tree" keymaps-mode="none" id="intellij" web-path="/intellij/"/>
|
<instance src="ijs.tree" keymaps-mode="none" id="intellij" web-path="/intellij/"/>
|
||||||
</ihp>
|
</ihp>
|
||||||
|
8
v-releases.list
Normal file
8
v-releases.list
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE vars
|
||||||
|
SYSTEM "https://helpserver.labs.jb.gg/help/schemas/mvp/vars.dtd">
|
||||||
|
|
||||||
|
<vars>
|
||||||
|
<var name="gradle-intellij-plugin-version" value="1.15.0"/>
|
||||||
|
<var name="gradle-grammar-kit-plugin-version" value="2022.3.1"/>
|
||||||
|
</vars>
|
4
v.list
4
v.list
@ -16,8 +16,4 @@
|
|||||||
|
|
||||||
<var name="gh-ij-plugins" value="https://github.com/JetBrains/intellij-plugins/tree/idea/%ijPlatformBuild%"/>
|
<var name="gh-ij-plugins" value="https://github.com/JetBrains/intellij-plugins/tree/idea/%ijPlatformBuild%"/>
|
||||||
<var name="gh-ij-plugins-master" value="https://github.com/JetBrains/intellij-plugins/tree/master"/>
|
<var name="gh-ij-plugins-master" value="https://github.com/JetBrains/intellij-plugins/tree/master"/>
|
||||||
|
|
||||||
<!-- Tool release versions -->
|
|
||||||
<var name="gradle-intellij-plugin-version" value="1.15.0"/>
|
|
||||||
<var name="gradle-grammar-kit-plugin-version" value="2022.3.1"/>
|
|
||||||
</vars>
|
</vars>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user