Skip to content

Commit 7865707

Browse files
authored
Merge pull request #39 from block/mehdi.auto-ij-version-upgrade
Auto upgrade the supported idea version
2 parents 49f9968 + 6be38d7 commit 7865707

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Idea major version upgrade
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
jobs:
7+
upgrade:
8+
name: Check for idea version updates
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
- run: ./scripts/upgrade-major-versions.sh
14+
- name: Create Pull Request
15+
uses: peter-evans/create-pull-request@v7
16+
with:
17+
branch: auto/idea-major-version-upgrade
18+
delete-branch: true
19+
title: "[Automatic] Upgrade of the idea major versions"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ build
1010
.intellijPlatform/
1111

1212
.kotlin/
13+
*.bak

scripts/upgrade-major-versions.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
# This script upgrades the versions of the IDEs in the build file, if the latest
4+
# major version is larger than the one in gradle.properties
5+
6+
# Returns the latest released version for the given JetBrains product code.
7+
latestRelease() {
8+
typeCode=$1
9+
releaseType=$2
10+
url="https://data.services.jetbrains.com/products?fields=code,releases.build,releases.type&code=${typeCode}"
11+
curl -s "${url}" | jq "[.[0]|.releases|.[]|select(.type==\"${releaseType}\")|.build][0]" | tr -d '"'
12+
}
13+
14+
# Returns the latest IDE version used to build the plugin for the given IDE
15+
currentVersion() {
16+
typeCode=$1
17+
releaseType=$2
18+
grep "${typeCode}.${releaseType}.version" gradle.properties | sed "s/^.*=\(.*\)/\1/"
19+
}
20+
21+
# Returns the major version for the given full version string
22+
majorVersion() {
23+
version=$1
24+
echo "${version}" | sed "s/^\([^.]*\).*/\1/"
25+
}
26+
27+
# Sets the version for the given product type in the build file
28+
setVersion() {
29+
typeCode=$1
30+
version=$2
31+
releaseType=$3
32+
sed -i.bak "s/^${typeCode}\.${releaseType}\.version=.*$/${typeCode}.${releaseType}.version=${version}/g" gradle.properties
33+
}
34+
35+
# Updates the version in gradle.properties if the major version of the latest release differs
36+
updateIfNeeded() {
37+
typeCode="IIC"
38+
releaseType="release"
39+
40+
latest=$(latestRelease "${typeCode}" "${releaseType}")
41+
current=$(currentVersion "${typeCode}" "${releaseType}")
42+
latestMajor=$(majorVersion "${latest}")
43+
currentMajor=$(majorVersion "${current}")
44+
45+
if [ "$latestMajor" != "$currentMajor" ]; then
46+
echo "Upgrading to ${latest}"
47+
setVersion "$typeCode" "$latest" "$releaseType"
48+
else
49+
echo "No upgrade needed for ${typeCode} ${releaseType}"
50+
fi
51+
}
52+
53+
updateIfNeeded

0 commit comments

Comments
 (0)