-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gha] fix JetBrains Platform Version update script (#20076)
* Add bun script * Update GHA * fix gha
- Loading branch information
1 parent
a803391
commit 61d7b78
Showing
5 changed files
with
267 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,17 +9,13 @@ on: | |
description: ID of the plugin in lowercase and without spaces. | ||
type: string | ||
required: true | ||
productCode: | ||
description: JB Product Code | ||
taskId: | ||
description: ID of task to exec | ||
type: string | ||
required: true | ||
productType: | ||
description: JB Product Type | ||
type: string | ||
required: true | ||
gradlePropertiesPath: | ||
description: Path for the gradle.properties file of the plugin. | ||
type: string | ||
isBackendPlugin: | ||
description: Action is execing for Gitpod JetBrains Backend Plugin or not | ||
type: boolean | ||
required: true | ||
secrets: | ||
slackWebhook: | ||
|
@@ -33,45 +29,34 @@ jobs: | |
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Get Current Platform Version | ||
id: current-version | ||
- name: Install dependencies | ||
run: | | ||
CURRENT_VERSION=$(cat ${{ inputs.gradlePropertiesPath }} | grep platformVersion= | sed 's/platformVersion=//') | ||
echo "Current platform version: $CURRENT_VERSION" | ||
echo "::set-output name=result::$CURRENT_VERSION" | ||
- name: Get Latest Platform Version | ||
id: latest-version | ||
curl -fsSL https://github.com/csweichel/oci-tool/releases/download/v0.2.1/oci-tool_0.2.1_linux_amd64.tar.gz | tar xz -C /usr/local/bin | ||
chmod +x /usr/local/bin/oci-tool | ||
cd ./components/ide/gha-update-image/ | ||
yarn | ||
npm i -g bun | ||
- name: Check for Update | ||
id: change | ||
run: | | ||
URL="https://data.services.jetbrains.com/products/releases?code=${{ inputs.productCode }}&type=${{ inputs.productType }}&platform=linux" | ||
echo "URL: $URL" | ||
RELEASE=$(curl -s "$URL" |jq ".${{ inputs.productCode }}[0]") | ||
MAJOR_VERSION=$(echo $RELEASE |jq -r ".majorVersion") | ||
echo "MAJOR_VERSION: $MAJOR_VERSION" | ||
BUILD=$(echo $RELEASE |jq -r ".build") | ||
echo "BUILD: $BUILD" | ||
MAJOR=$(cut -d. -f1 <<< $BUILD) | ||
echo "MAJOR: $MAJOR" | ||
MINOR=$(cut -d. -f2 <<< $BUILD) | ||
echo "MINOR: $MINOR" | ||
LATEST_VERSION="$MAJOR.$MINOR-EAP-CANDIDATE-SNAPSHOT" | ||
echo "Latest platform version: $LATEST_VERSION" | ||
cd ./components/ide/gha-update-image/ | ||
bun run index-jb-platform-update.ts --task=${{ inputs.taskId }} | ||
echo "::set-output name=sinceBuild::$MAJOR.$MINOR" | ||
echo "::set-output name=untilBuild::$MAJOR.*" | ||
echo "::set-output name=majorVersion::$MAJOR_VERSION" | ||
echo "::set-output name=result::$LATEST_VERSION" | ||
- name: Update ${{ inputs.gradlePropertiesPath }} | ||
if: ${{ steps.latest-version.outputs.result != steps.current-version.outputs.result }} | ||
if [ -f /tmp/__gh_output.txt ] | ||
then | ||
cat /tmp/__gh_output.txt >> $GITHUB_OUTPUT | ||
fi | ||
- name: Detect file changes | ||
id: changes | ||
run: | | ||
sed -i "s/pluginSinceBuild=.*/pluginSinceBuild=${{ steps.latest-version.outputs.sinceBuild }}/" ${{ inputs.gradlePropertiesPath }} | ||
sed -i "s/pluginUntilBuild=.*/pluginUntilBuild=${{ steps.latest-version.outputs.untilBuild }}/" ${{ inputs.gradlePropertiesPath }} | ||
sed -i "s/pluginVerifierIdeVersions=.*/pluginVerifierIdeVersions=${{ steps.latest-version.outputs.majorVersion }}/" ${{ inputs.gradlePropertiesPath }} | ||
sed -i 's/platformVersion=${{ steps.current-version.outputs.result }}/platformVersion=${{ steps.latest-version.outputs.result }}/' ${{ inputs.gradlePropertiesPath }} | ||
git diff | ||
if [ $(git status --porcelain | wc -l) -gt 0 ]; then | ||
echo "dirty=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "dirty=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Create Pull Request for Gateway Plugin | ||
id: create-gateway-pr | ||
if: ${{ contains(inputs.pluginId, 'gateway-plugin') && steps.latest-version.outputs.result != steps.current-version.outputs.result }} | ||
if: ${{ steps.changes.outputs.dirty && !inputs.isBackendPlugin }} | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
title: "[JetBrains] Update Platform Version from ${{ inputs.pluginName }}" | ||
|
@@ -118,7 +103,7 @@ jobs: | |
author: Robo Quat <[email protected]> | ||
- name: Create Pull Request for Backend Plugin | ||
id: create-backend-pr | ||
if: ${{ contains(inputs.pluginId, 'backend-plugin') && steps.latest-version.outputs.result != steps.current-version.outputs.result }} | ||
if: ${{ steps.changes.outputs.dirty && inputs.isBackendPlugin }} | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
title: "[JetBrains] Update Platform Version from ${{ inputs.pluginName }}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
components/ide/gha-update-image/index-jb-platform-update.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// Copyright (c) 2024 Gitpod GmbH. All rights reserved. | ||
// Licensed under the GNU Affero General Public License (AGPL). | ||
// See License.AGPL.txt in the project root for license information. | ||
|
||
// Update JetBrains Platform Version | ||
|
||
import path from "path"; | ||
import { parseArgs } from "util"; | ||
import { pathToProjectRoot } from "./lib/common"; | ||
import { jbUpdatePlatformVersion } from "./lib/jb-update-platform-version"; | ||
|
||
const targetInfo = [ | ||
{ | ||
id: 1, | ||
taskName: "Latest Backend Plugin", | ||
productCode: "IIU", | ||
productType: "eap,rc,release", | ||
xmlName: "IntelliJ IDEA", | ||
xmlChannels: ["IC-IU-EAP-licensing-RELEASE", "IC-IU-EAP-licensing-EAP", "IC-IU-RELEASE-licensing-RELEASE"], | ||
useXml: true, | ||
gradlePropertiesPath: path.resolve( | ||
pathToProjectRoot, | ||
"components/ide/jetbrains/backend-plugin/gradle-latest.properties", | ||
), | ||
gradlePropertiesTemplate: `# Code generated by gha-update-image/index-jb-platform-update.ts. DO NOT EDIT. | ||
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html | ||
# for insight into build numbers and IntelliJ Platform versions. | ||
pluginSinceBuild={{pluginSinceBuild}} | ||
pluginUntilBuild={{pluginUntilBuild}} | ||
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl | ||
# See https://jb.gg/intellij-platform-builds-list for available build versions. | ||
pluginVerifierIdeVersions={{pluginVerifierIdeVersions}} | ||
# Version from "com.jetbrains.intellij.idea" which can be found at https://www.jetbrains.com/intellij-repository/snapshots | ||
platformVersion={{platformVersion}} | ||
`, | ||
}, | ||
{ | ||
id: 2, | ||
taskName: "Latest Frontend Plugin", | ||
productCode: "GW", | ||
productType: "eap,rc,release", | ||
xmlName: "Gateway", | ||
xmlChannels: ["GW-EAP-licensing-EAP", "GW-RELEASE-licensing-RELEASE", "GW-EAP-licensing-RELEASE"], | ||
useXml: true, | ||
gradlePropertiesPath: path.resolve( | ||
pathToProjectRoot, | ||
"components/ide/jetbrains/gateway-plugin/gradle-latest.properties", | ||
), | ||
gradlePropertiesTemplate: `# Code generated by gha-update-image/index-jb-platform-update.ts. DO NOT EDIT. | ||
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html | ||
# for insight into build numbers and IntelliJ Platform versions. | ||
pluginSinceBuild={{pluginSinceBuild}} | ||
pluginUntilBuild={{pluginUntilBuild}} | ||
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl | ||
# See https://jb.gg/intellij-platform-builds-list for available build versions. | ||
pluginVerifierIdeVersions={{pluginVerifierIdeVersions}} | ||
# Version from "com.jetbrains.gateway" which can be found at https://www.jetbrains.com/intellij-repository/snapshots | ||
platformVersion={{platformVersion}} | ||
`, | ||
}, | ||
{ | ||
id: 3, | ||
taskName: "Stable Backend Plugin", | ||
productCode: "GW", | ||
productType: "release", | ||
xmlName: "Gateway", | ||
xmlChannels: ["GW-RELEASE-licensing-RELEASE"], | ||
useXml: false, | ||
gradlePropertiesPath: path.resolve( | ||
pathToProjectRoot, | ||
"components/ide/jetbrains/gateway-plugin/gradle-stable.properties", | ||
), | ||
gradlePropertiesTemplate: `# Code generated by gha-update-image/index-jb-platform-update.ts. DO NOT EDIT. | ||
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html | ||
# for insight into build numbers and IntelliJ Platform versions. | ||
pluginSinceBuild={{pluginSinceBuild}} | ||
pluginUntilBuild={{pluginUntilBuild}} | ||
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl | ||
# See https://jb.gg/intellij-platform-builds-list for available build versions. | ||
pluginVerifierIdeVersions={{pluginVerifierIdeVersions}} | ||
# Version from "com.jetbrains.gateway" which can be found at https://www.jetbrains.com/updates/updates.xml | ||
platformVersion={{platformVersion}} | ||
`, | ||
}, | ||
]; | ||
|
||
const { values } = parseArgs({ | ||
args: Bun.argv, | ||
options: { | ||
task: { | ||
type: "string", | ||
}, | ||
}, | ||
strict: true, | ||
allowPositionals: true, | ||
}); | ||
|
||
const taskID = Number.parseInt(values.task ?? "NaN"); | ||
|
||
const target = targetInfo.find((e) => e.id === taskID); | ||
if (!target) { | ||
throw new Error( | ||
`Invalid task id: ${taskID}, update cmd with \`--task="<name>"\`, available tasks: \n\t- ${targetInfo | ||
.map((e) => `(${e.id}) ${e.taskName}`) | ||
.join("\n\t- ")}`, | ||
); | ||
} | ||
console.log("Updating", target.taskName); | ||
jbUpdatePlatformVersion(target); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.