Skip to content

Commit 03edccd

Browse files
authored
Merge pull request #93 from KotlinIsland/intellij
IntelliJ plugin
2 parents 4689c3c + e90f07f commit 03edccd

22 files changed

+1274
-0
lines changed

.github/workflows/build.yml

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
# GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps:
2+
# - Validate Gradle Wrapper.
3+
# - Run 'test' and 'verifyPlugin' tasks.
4+
# - Run Qodana inspections.
5+
# - Run the 'buildPlugin' task and prepare artifact for further tests.
6+
# - Run the 'runPluginVerifier' task.
7+
# - Create a draft release.
8+
#
9+
# The workflow is triggered on push and pull_request events.
10+
#
11+
# GitHub Actions reference: https://help.github.com/en/actions
12+
#
13+
## JBIJPPTPL
14+
15+
name: Build
16+
on:
17+
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests)
18+
push:
19+
branches: [ main ]
20+
# Trigger the workflow on any pull request
21+
pull_request:
22+
paths:
23+
- "intellij/**"
24+
25+
jobs:
26+
27+
# Prepare environment and build the plugin
28+
build:
29+
name: Build
30+
runs-on: ubuntu-latest
31+
outputs:
32+
version: ${{ steps.properties.outputs.version }}
33+
changelog: ${{ steps.properties.outputs.changelog }}
34+
pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }}
35+
steps:
36+
37+
# Check out current repository
38+
- name: Fetch Sources
39+
uses: actions/checkout@v4
40+
41+
# Validate wrapper
42+
- name: Gradle Wrapper Validation
43+
uses: gradle/[email protected]
44+
45+
# Set up Java environment for the next steps
46+
- name: Setup Java
47+
uses: actions/setup-java@v4
48+
with:
49+
distribution: zulu
50+
java-version: 17
51+
52+
# Setup Gradle
53+
- name: Setup Gradle
54+
uses: gradle/gradle-build-action@v2
55+
with:
56+
gradle-home-cache-cleanup: true
57+
58+
# Set environment variables
59+
- name: Export Properties
60+
working-directory: ./intellij
61+
id: properties
62+
shell: bash
63+
run: |
64+
PROPERTIES="$(./gradlew properties --console=plain -q)"
65+
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
66+
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
67+
68+
echo "version=$VERSION" >> $GITHUB_OUTPUT
69+
echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
70+
71+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
72+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
73+
echo "EOF" >> $GITHUB_OUTPUT
74+
75+
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
76+
77+
# Build plugin
78+
- name: Build plugin
79+
working-directory: ./intellij
80+
run: ./gradlew buildPlugin
81+
82+
# Prepare plugin archive content for creating artifact
83+
- name: Prepare Plugin Artifact
84+
id: artifact
85+
shell: bash
86+
run: |
87+
cd ${{ github.workspace }}/intellij/build/distributions
88+
FILENAME=`ls *.zip`
89+
unzip "$FILENAME" -d content
90+
91+
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
92+
93+
# Store already-built plugin as an artifact for downloading
94+
- name: Upload artifact
95+
uses: actions/upload-artifact@v3
96+
with:
97+
name: ${{ steps.artifact.outputs.filename }}
98+
path: ./intellij/build/distributions/content/*/*
99+
100+
# Run tests and upload a code coverage report
101+
test:
102+
name: Test
103+
needs: [ build ]
104+
runs-on: ubuntu-latest
105+
steps:
106+
107+
# Check out current repository
108+
- name: Fetch Sources
109+
uses: actions/checkout@v4
110+
111+
# Set up Java environment for the next steps
112+
- name: Setup Java
113+
uses: actions/setup-java@v4
114+
with:
115+
distribution: zulu
116+
java-version: 17
117+
118+
# Setup Gradle
119+
- name: Setup Gradle
120+
uses: gradle/gradle-build-action@v2
121+
with:
122+
gradle-home-cache-cleanup: true
123+
124+
# Run tests
125+
- name: Run Tests
126+
working-directory: ./intellij
127+
run: ./gradlew check
128+
129+
# Collect Tests Result of failed tests
130+
- name: Collect Tests Result
131+
if: ${{ failure() }}
132+
uses: actions/upload-artifact@v3
133+
with:
134+
name: tests-result
135+
path: ${{ github.workspace }}/intellij/build/reports/tests
136+
137+
# Upload the Kover report to CodeCov
138+
- name: Upload Code Coverage Report
139+
uses: codecov/codecov-action@v3
140+
with:
141+
files: ${{ github.workspace }}/intellij/build/reports/kover/report.xml
142+
143+
# Run Qodana inspections and provide report
144+
inspectCode:
145+
name: Inspect code
146+
needs: [ build ]
147+
runs-on: ubuntu-latest
148+
permissions:
149+
contents: write
150+
checks: write
151+
pull-requests: write
152+
steps:
153+
154+
# Free GitHub Actions Environment Disk Space
155+
- name: Maximize Build Space
156+
uses: jlumbroso/free-disk-space@main
157+
with:
158+
tool-cache: false
159+
large-packages: false
160+
161+
# Check out current repository
162+
- name: Fetch Sources
163+
uses: actions/checkout@v4
164+
165+
# Set up Java environment for the next steps
166+
- name: Setup Java
167+
uses: actions/setup-java@v4
168+
with:
169+
distribution: zulu
170+
java-version: 17
171+
172+
173+
# Run plugin structure verification along with IntelliJ Plugin Verifier
174+
verify:
175+
name: Verify plugin
176+
needs: [ build ]
177+
runs-on: ubuntu-latest
178+
steps:
179+
180+
# Free GitHub Actions Environment Disk Space
181+
- name: Maximize Build Space
182+
uses: jlumbroso/free-disk-space@main
183+
with:
184+
tool-cache: false
185+
large-packages: false
186+
187+
# Check out current repository
188+
- name: Fetch Sources
189+
uses: actions/checkout@v4
190+
191+
# Set up Java environment for the next steps
192+
- name: Setup Java
193+
uses: actions/setup-java@v4
194+
with:
195+
distribution: zulu
196+
java-version: 17
197+
198+
# Setup Gradle
199+
- name: Setup Gradle
200+
uses: gradle/gradle-build-action@v2
201+
with:
202+
gradle-home-cache-cleanup: true
203+
204+
# Cache Plugin Verifier IDEs
205+
- name: Setup Plugin Verifier IDEs Cache
206+
uses: actions/cache@v3
207+
with:
208+
path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
209+
key: plugin-verifier-${{ hashFiles('intellij/build/listProductsReleases.txt') }}
210+
211+
# Run Verify Plugin task and IntelliJ Plugin Verifier tool
212+
- name: Run Plugin Verification tasks
213+
working-directory: ./intellij
214+
run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}
215+
216+
# Collect Plugin Verifier Result
217+
- name: Collect Plugin Verifier Result
218+
if: ${{ always() }}
219+
uses: actions/upload-artifact@v3
220+
with:
221+
name: pluginVerifier-result
222+
path: ${{ github.workspace }}/intellij/build/reports/pluginVerifier
223+
224+
# Prepare a draft release for GitHub Releases page for the manual verification
225+
# If accepted and published, release workflow would be triggered
226+
# releaseDraft:
227+
# name: Release draft
228+
# if: github.event_name != 'pull_request'
229+
# needs: [ build, test, inspectCode, verify ]
230+
# runs-on: ubuntu-latest
231+
# permissions:
232+
# contents: write
233+
# steps:
234+
#
235+
# # Check out current repository
236+
# - name: Fetch Sources
237+
# uses: actions/checkout@v4
238+
#
239+
# # Set up Java environment for the next steps
240+
# - name: Setup Java
241+
# uses: actions/setup-java@v4
242+
# with:
243+
# distribution: zulu
244+
# java-version: 17
245+
#
246+
# # Remove old release drafts by using the curl request for the available releases with a draft flag
247+
# - name: Remove Old Release Drafts
248+
# env:
249+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
250+
# run: |
251+
# gh api repos/{owner}/{repo}/releases \
252+
# --jq '.[] | select(.draft == true) | .id' \
253+
# | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
254+
#
255+
# # Create a new release draft which is not publicly visible and requires manual acceptance
256+
# - name: Create Release Draft
257+
# env:
258+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
259+
# run: |
260+
# gh release create v${{ needs.build.outputs.version }} \
261+
# --draft \
262+
# --title "v${{ needs.build.outputs.version }}" \
263+
# --notes "$(cat << 'EOM'
264+
# ${{ needs.build.outputs.changelog }}
265+
# EOM
266+
# )"

.github/workflows/release.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# GitHub Actions Workflow created for handling the release process based on the draft release prepared with the Build workflow.
2+
# Running the publishPlugin task requires all following secrets to be provided: PUBLISH_TOKEN, PRIVATE_KEY, PRIVATE_KEY_PASSWORD, CERTIFICATE_CHAIN.
3+
# See https://plugins.jetbrains.com/docs/intellij/plugin-signing.html for more information.
4+
5+
name: Release
6+
on:
7+
workflow_dispatch:
8+
# release:
9+
# types: [prereleased, released]
10+
11+
jobs:
12+
13+
# Prepare and publish the plugin to JetBrains Marketplace repository
14+
release:
15+
name: Publish Plugin
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
steps:
21+
22+
# Check out current repository
23+
- name: Fetch Sources
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{ github.event.release.tag_name }}
27+
28+
# Set up Java environment for the next steps
29+
- name: Setup Java
30+
uses: actions/setup-java@v4
31+
with:
32+
distribution: zulu
33+
java-version: 17
34+
35+
# Setup Gradle
36+
- name: Setup Gradle
37+
uses: gradle/gradle-build-action@v2
38+
with:
39+
gradle-home-cache-cleanup: true
40+
41+
# Set environment variables
42+
- name: Export Properties
43+
id: properties
44+
shell: bash
45+
run: |
46+
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
47+
${{ github.event.release.body }}
48+
EOM
49+
)"
50+
51+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
52+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
53+
echo "EOF" >> $GITHUB_OUTPUT
54+
55+
# Update Unreleased section with the current release note
56+
- name: Patch Changelog
57+
if: ${{ steps.properties.outputs.changelog != '' }}
58+
env:
59+
CHANGELOG: ${{ steps.properties.outputs.changelog }}
60+
run: |
61+
./gradlew patchChangelog --release-note="$CHANGELOG"
62+
63+
# Publish the plugin to JetBrains Marketplace
64+
- name: Publish Plugin
65+
env:
66+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
67+
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
68+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
69+
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
70+
run: ./gradlew publishPlugin
71+
72+
# Upload artifact as a release asset
73+
- name: Upload Release Asset
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
77+
78+
# Create a pull request
79+
- name: Create Pull Request
80+
if: ${{ steps.properties.outputs.changelog != '' }}
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
run: |
84+
VERSION="${{ github.event.release.tag_name }}"
85+
BRANCH="changelog-update-$VERSION"
86+
LABEL="release changelog"
87+
88+
git config user.email "[email protected]"
89+
git config user.name "GitHub Action"
90+
91+
git checkout -b $BRANCH
92+
git commit -am "Changelog update - $VERSION"
93+
git push --set-upstream origin $BRANCH
94+
95+
gh label create "$LABEL" \
96+
--description "Pull requests with release changelog update" \
97+
--force \
98+
|| true
99+
100+
gh pr create \
101+
--title "Changelog update - \`$VERSION\`" \
102+
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
103+
--label "$LABEL" \
104+
--head $BRANCH

0 commit comments

Comments
 (0)