Skip to content

Commit 7d8b723

Browse files
committed
Build and test with latest IPGP
1 parent 979d7b7 commit 7d8b723

3 files changed

Lines changed: 174 additions & 1 deletion

File tree

.github/workflows/build.yaml

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ jobs:
144144
shell: bash
145145
run: |
146146
gh cache list --json "key" --limit 1000 \
147-
-q '.[].key | select(startswith("gradle-home") and contains("Windows"))' | \
147+
--jq '.[].key | select(startswith("gradle-home") and contains("Windows"))' | \
148148
xargs -I '{}' gh cache delete '{}'
149149
-
150150
name: Set up Gradle
@@ -344,3 +344,112 @@ jobs:
344344
NIGHTLY_VERSION=$(grep -oP '^pluginVersion = \K\S+' gradle.properties)
345345
346346
./gradlew publishPlugin -Pchannel=Nightly -PpluginVersion=${NIGHTLY_VERSION}
347+
348+
build-latest-ipgp:
349+
name: Build with latest IPGP
350+
runs-on: ubuntu-latest
351+
352+
steps:
353+
-
354+
name: Fetch sources
355+
uses: actions/checkout@v5
356+
-
357+
name: Set up Java
358+
uses: actions/setup-java@v5
359+
with:
360+
distribution: zulu
361+
java-version: 21
362+
-
363+
name: Set up uv
364+
uses: astral-sh/setup-uv@v6
365+
-
366+
name: Set up Gradle
367+
uses: gradle/actions/setup-gradle@v4
368+
-
369+
name: Bump IntelliJ Platform Gradle Plugin
370+
env:
371+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
372+
run: |
373+
uv run scripts/update_ipgp.py
374+
-
375+
name: Build plugin
376+
run: |
377+
./gradlew buildPlugin
378+
-
379+
name: Prepare plugin artifact
380+
id: artifact
381+
shell: bash
382+
run: |
383+
cd ${{ github.workspace }}/build/distributions
384+
FILENAME=`ls *.zip`
385+
unzip "$FILENAME" -d content
386+
387+
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
388+
-
389+
name: Upload artifact
390+
uses: actions/upload-artifact@v4
391+
with:
392+
name: ${{ steps.artifact.outputs.filename }}-latest-IPGP
393+
path: ./build/distributions/content/*/*
394+
395+
test-latest-ipgp:
396+
name: Test with latest IPGP
397+
needs: [ build-latest-ipgp ]
398+
399+
strategy:
400+
matrix:
401+
platform: [ ubuntu-latest, macos-latest, windows-latest ]
402+
403+
runs-on: ${{ matrix.platform }}
404+
continue-on-error: true
405+
406+
steps:
407+
-
408+
name: Fetch sources
409+
uses: actions/checkout@v5
410+
-
411+
name: Set up Java
412+
uses: actions/setup-java@v5
413+
with:
414+
distribution: zulu
415+
java-version: 21
416+
-
417+
name: Set up Gradle
418+
uses: gradle/actions/setup-gradle@v4
419+
with:
420+
cache-read-only: true
421+
-
422+
name: Set up Rye
423+
uses: eifinger/setup-rye@v4
424+
with:
425+
version: latest
426+
-
427+
name: Set up uv
428+
uses: astral-sh/setup-uv@v6
429+
-
430+
name: Set up Ruff
431+
run: |
432+
uv tool install ruff
433+
-
434+
name: Set up ty
435+
run: |
436+
uv tool install ty
437+
-
438+
name: Bump IntelliJ Platform Gradle Plugin
439+
env:
440+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
441+
run: |
442+
uv run scripts/update_ipgp.py
443+
-
444+
name: Run tests
445+
id: tests
446+
continue-on-error: true
447+
run: |
448+
./gradlew check
449+
-
450+
name: Upload result
451+
if: ${{ steps.tests.outcome == 'failure' }}
452+
uses: actions/upload-artifact@v4
453+
with:
454+
name: tests-result-${{ matrix.platform }}-latest-ipgp
455+
path: ${{ github.workspace }}/build/reports/tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ scripts/*
22
!scripts/changelog.py
33
!scripts/edit_releases.py
44
!scripts/command_specs.py
5+
!scripts/update_ipgp.py
56

67
.run/*
78
!.run/Build.run.xml

scripts/update_ipgp.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# /// script
2+
# requires-python = ">=3.13"
3+
# dependencies = [
4+
# "pydantic"
5+
# ]
6+
# ///
7+
8+
import json
9+
import re
10+
import subprocess # noqa: S404
11+
from collections.abc import Iterable
12+
from pathlib import Path
13+
from typing import Final
14+
15+
from pydantic import BaseModel, Field, TypeAdapter
16+
17+
18+
_PROJECT_ROOT: Final = Path(__file__).parent.parent
19+
_LIBS_VERSION_TOML: Final = _PROJECT_ROOT / 'gradle' / 'libs.versions.toml'
20+
21+
_IPGP_VERSION_IN_SPECIFIER: Final = re.compile(r'(?m)(?<=^intelliJPlatform = ").+(?="$)')
22+
23+
24+
class Release(BaseModel):
25+
is_latest: bool = Field(alias = 'isLatest')
26+
tag_name: str = Field(alias = 'tagName')
27+
28+
@staticmethod
29+
def list_from(raw: Iterable[object]) -> 'list[Release]':
30+
adapter = TypeAdapter(list[Release])
31+
return adapter.validate_python(raw)
32+
33+
34+
def _get_latest_version() -> str:
35+
arguments = [
36+
'gh', 'release', 'list',
37+
'--json', 'isLatest,tagName',
38+
'--limit', '10',
39+
'--repo', 'JetBrains/intellij-platform-gradle-plugin'
40+
]
41+
output = subprocess.run(arguments, capture_output = True, check = True)
42+
43+
for release in Release.list_from(json.loads(output.stdout)):
44+
if release.is_latest:
45+
return release.tag_name.removeprefix('v')
46+
47+
raise RuntimeError
48+
49+
50+
def _replace_version(new_version: str) -> None:
51+
contents = _LIBS_VERSION_TOML.read_text()
52+
new_contents = _IPGP_VERSION_IN_SPECIFIER.sub(new_version, contents)
53+
54+
_LIBS_VERSION_TOML.write_text(new_contents)
55+
56+
57+
def main() -> None:
58+
latest_version = _get_latest_version()
59+
_replace_version(latest_version)
60+
61+
62+
if __name__ == '__main__':
63+
main()

0 commit comments

Comments
 (0)