Skip to content

Commit 40cb013

Browse files
authored
Merge pull request #35 from ekino/fix/replacement_suggestion_2021.2
fix: replacement suggestions popup appears now on IntelliJ Platform 2021.2
2 parents 8574ecc + cfe9382 commit 40cb013

20 files changed

+306
-342
lines changed

.github/workflows/build.yml

+60-133
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
## JBIJPPTPL
1515

1616
name: Build
17-
on: [push, pull_request]
17+
on:
18+
# Trigger the workflow on pushes to only the 'master' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
19+
push:
20+
branches: [master]
21+
# Trigger the workflow on any pull request
22+
pull_request:
23+
1824
jobs:
1925

2026
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
@@ -25,7 +31,7 @@ jobs:
2531

2632
# Check out current repository
2733
- name: Fetch Sources
28-
uses: actions/checkout@v2
34+
uses: actions/checkout@v2.3.4
2935

3036
# Validate wrapper
3137
- name: Gradle Wrapper Validation
@@ -38,75 +44,74 @@ jobs:
3844
runs-on: ubuntu-latest
3945
steps:
4046

47+
# Check out current repository
48+
- name: Fetch Sources
49+
uses: actions/checkout@v2.3.4
50+
4151
# Setup Java 11 environment for the next steps
4252
- name: Setup Java
4353
uses: actions/setup-java@v2
4454
with:
45-
distribution: "temurin"
55+
distribution: zulu
4656
java-version: 11
57+
cache: gradle
4758

48-
# Check out current repository
49-
- name: Fetch Sources
50-
uses: actions/checkout@v2
59+
# Set environment variables
60+
- name: Export Properties
61+
id: properties
62+
shell: bash
63+
run: |
64+
PROPERTIES="$(./gradlew properties --console=plain -q)"
65+
IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
5166
52-
# Cache Gradle dependencies
53-
- name: Setup Gradle Dependencies Cache
54-
uses: actions/cache@v2.1.6
55-
with:
56-
path: ~/.gradle/caches
57-
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
67+
echo "::set-output name=ideVersions::$IDE_VERSIONS"
68+
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
5869
59-
# Cache Gradle Wrapper
60-
- name: Setup Gradle Wrapper Cache
70+
# Cache Plugin Verifier IDEs
71+
- name: Setup Plugin Verifier IDEs Cache
6172
uses: actions/cache@v2.1.6
6273
with:
63-
path: ~/.gradle/wrapper
64-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
74+
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
75+
key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
76+
77+
# Run Qodana inspections
78+
- name: Qodana - Code Inspection
79+
uses: JetBrains/qodana-action@v2.1-eap
6580

66-
# Run detekt, ktlint and tests
67-
- name: Run Linters and Test
68-
run: ./gradlew check
81+
# Run tests
82+
- name: Run Tests
83+
run: ./gradlew test
6984

7085
# Run verifyPlugin Gradle task
7186
- name: Verify Plugin
7287
run: ./gradlew verifyPlugin
7388

89+
# Run IntelliJ Plugin Verifier action using GitHub Action
90+
- name: Run Plugin Verifier
91+
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
92+
7493
# Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
7594
# Requires test job to be passed
7695
build:
7796
name: Build
7897
needs: test
7998
runs-on: ubuntu-latest
8099
outputs:
81-
name: ${{ steps.properties.outputs.name }}
82100
version: ${{ steps.properties.outputs.version }}
83101
changelog: ${{ steps.properties.outputs.changelog }}
84-
artifact: ${{ steps.properties.outputs.artifact }}
85102
steps:
86103

87-
# Setup Java 11 environment for the next steps
88-
- name: Setup Java
89-
uses: actions/setup-java@v1
90-
with:
91-
java-version: 11
92-
93104
# Check out current repository
94105
- name: Fetch Sources
95-
uses: actions/checkout@v2
96-
97-
# Cache Gradle Dependencies
98-
- name: Setup Gradle Dependencies Cache
99-
uses: actions/cache@v2.1.6
100-
with:
101-
path: ~/.gradle/caches
102-
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
106+
uses: actions/checkout@v2.3.4
103107

104-
# Cache Gradle Wrapper
105-
- name: Setup Gradle Wrapper Cache
106-
uses: actions/cache@v2.1.6
108+
# Setup Java 11 environment for the next steps
109+
- name: Setup Java
110+
uses: actions/setup-java@v2
107111
with:
108-
path: ~/.gradle/wrapper
109-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
112+
distribution: zulu
113+
java-version: 11
114+
cache: gradle
110115

111116
# Set environment variables
112117
- name: Export Properties
@@ -115,133 +120,55 @@ jobs:
115120
run: |
116121
PROPERTIES="$(./gradlew properties --console=plain -q)"
117122
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
118-
NAME="$(echo "$PROPERTIES" | grep "^pluginName_:" | cut -f2- -d ' ')"
123+
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
119124
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
120125
CHANGELOG="${CHANGELOG//'%'/'%25'}"
121126
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
122127
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
123-
ARTIFACT="${NAME}-${VERSION}.zip"
124128
125129
echo "::set-output name=version::$VERSION"
126130
echo "::set-output name=name::$NAME"
127131
echo "::set-output name=changelog::$CHANGELOG"
128-
echo "::set-output name=artifact::$ARTIFACT"
129132
130133
# Build artifact using buildPlugin Gradle task
131134
- name: Build Plugin
132135
run: ./gradlew buildPlugin
133136

134-
# Upload plugin artifact to make it available in the next jobs
135-
- name: Upload artifact
137+
# Store built plugin as an artifact for downloading
138+
- name: Upload artifacts
136139
uses: actions/upload-artifact@v2.2.4
137140
with:
138-
name: plugin-artifact
139-
path: ./build/distributions/${{ needs.build.outputs.artifact }}
140-
141-
# Verify built plugin using IntelliJ Plugin Verifier tool
142-
# Requires build job to be passed
143-
verify:
144-
name: Verify
145-
needs: build
146-
runs-on: ubuntu-latest
147-
steps:
148-
149-
# Setup Java 11 environment for the next steps
150-
- name: Setup Java
151-
uses: actions/setup-java@v1
152-
with:
153-
java-version: 11
154-
155-
# Check out current repository
156-
- name: Fetch Sources
157-
uses: actions/checkout@v2
158-
159-
# Cache Gradle Dependencies
160-
- name: Setup Gradle Dependencies Cache
161-
uses: actions/cache@v2.1.6
162-
with:
163-
path: ~/.gradle/caches
164-
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
165-
166-
# Cache Gradle Wrapper
167-
- name: Setup Gradle Wrapper Cache
168-
uses: actions/cache@v2.1.6
169-
with:
170-
path: ~/.gradle/wrapper
171-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
172-
173-
# Set environment variables
174-
- name: Export Properties
175-
id: properties
176-
shell: bash
177-
run: |
178-
PROPERTIES="$(./gradlew properties --console=plain -q)"
179-
IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
180-
181-
echo "::set-output name=ideVersions::$IDE_VERSIONS"
182-
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
183-
184-
# Cache Plugin Verifier IDEs
185-
- name: Setup Plugin Verifier IDEs Cache
186-
uses: actions/cache@v2.1.6
187-
with:
188-
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
189-
key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
190-
191-
# Run IntelliJ Plugin Verifier action using GitHub Action
192-
- name: Verify Plugin
193-
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
141+
name: "${{ steps.properties.outputs.name }} - ${{ steps.properties.outputs.version }}"
142+
path: ./build/distributions/*
194143

195144
# Prepare a draft release for GitHub Releases page for the manual verification
196145
# If accepted and published, release workflow would be triggered
197146
releaseDraft:
198147
name: Release Draft
199148
if: github.event_name != 'pull_request'
200-
needs: [build, verify]
149+
needs: build
201150
runs-on: ubuntu-latest
202151
steps:
203152

204153
# Check out current repository
205154
- name: Fetch Sources
206-
uses: actions/checkout@v2
155+
uses: actions/checkout@v2.3.4
207156

208157
# Remove old release drafts by using the curl request for the available releases with draft flag
209158
- name: Remove Old Release Drafts
210159
env:
211160
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
212161
run: |
213-
curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
214-
| tr '\r\n' ' ' \
215-
| jq '.[] | select(.draft == true) | .id' \
216-
| xargs -I '{}' \
217-
curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
162+
gh api repos/{owner}/{repo}/releases \
163+
--jq '.[] | select(.draft == true) | .id' \
164+
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
218165
219166
# Create new release draft - which is not publicly visible and requires manual acceptance
220167
- name: Create Release Draft
221-
id: createDraft
222-
uses: actions/create-release@v1
223-
env:
224-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
225-
with:
226-
tag_name: v${{ needs.build.outputs.version }}
227-
release_name: v${{ needs.build.outputs.version }}
228-
body: ${{ needs.build.outputs.changelog }}
229-
draft: true
230-
231-
# Download plugin artifact provided by the previous job
232-
- name: Download Artifact
233-
uses: actions/download-artifact@v2
234-
with:
235-
name: plugin-artifact
236-
237-
# Upload artifact as a release asset
238-
- name: Upload Release Asset
239-
id: upload-release-asset
240-
uses: actions/upload-release-asset@v1
241168
env:
242169
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
243-
with:
244-
upload_url: ${{ steps.createDraft.outputs.upload_url }}
245-
asset_path: ./${{ needs.build.outputs.artifact }}
246-
asset_name: ${{ needs.build.outputs.artifact }}
247-
asset_content_type: application/zip
170+
run: |
171+
gh release create v${{ needs.build.outputs.version }} \
172+
--draft \
173+
--title "v${{ needs.build.outputs.version }}" \
174+
--notes "${{ needs.build.outputs.changelog }}"

.github/workflows/release.yml

+39-40
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# GitHub Actions Workflow created for handling the release process based on the draft release prepared
2-
# with the Build workflow. Running the publishPlugin task requires the INTELLIJ_PUBLISH_TOKEN secret provided.
2+
# with the Build workflow. Running the publishPlugin task requires the PUBLISH_TOKEN secret provided.
33

44
name: Release
55
on:
@@ -14,57 +14,56 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616

17+
# Check out current repository
18+
- name: Fetch Sources
19+
uses: actions/checkout@v2.3.4
20+
with:
21+
ref: ${{ github.event.release.tag_name }}
22+
1723
# Setup Java 11 environment for the next steps
1824
- name: Setup Java
19-
uses: actions/setup-java@v1
25+
uses: actions/setup-java@v2
2026
with:
27+
distribution: zulu
2128
java-version: 11
29+
cache: gradle
2230

23-
# Check out current repository
24-
- name: Fetch Sources
25-
uses: actions/checkout@v2
26-
with:
27-
ref: ${{ github.event.release.tag_name }}
31+
# Update Unreleased section with the current release note
32+
- name: Patch Changelog
33+
run: |
34+
./gradlew patchChangelog --release-note="`cat << EOM
35+
${{ github.event.release.body }}
36+
EOM`"
2837
2938
# Publish the plugin to the Marketplace
3039
- name: Publish Plugin
3140
env:
32-
PUBLISH_TOKEN: ${{ secrets.INTELLIJ_PUBLISH_TOKEN }}
41+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
3342
run: ./gradlew publishPlugin
3443

35-
# Patch changelog, commit and push to the current repository
36-
changelog:
37-
name: Update Changelog
38-
needs: release
39-
runs-on: ubuntu-latest
40-
steps:
41-
42-
# Setup Java 11 environment for the next steps
43-
- name: Setup Java
44-
uses: actions/setup-java@v1
45-
with:
46-
java-version: 11
44+
# Upload artifact as a release asset
45+
- name: Upload Release Asset
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
4749

48-
# Check out current repository
49-
- name: Fetch Sources
50-
uses: actions/checkout@v2
51-
with:
52-
ref: ${{ github.event.release.tag_name }}
50+
# Create pull request
51+
- name: Create Pull Request
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
run: |
55+
VERSION="${{ github.event.release.tag_name }}"
56+
BRANCH="changelog-update-$VERSION"
5357
54-
# Update Unreleased section with the current version
55-
- name: Patch Changelog
56-
run: ./gradlew patchChangelog
58+
git config user.email "action@github.com"
59+
git config user.name "GitHub Action"
5760
58-
# Commit patched Changelog
59-
- name: Commit files
60-
run: |
61-
git config --local user.email "action@github.com"
62-
git config --local user.name "GitHub Action"
63-
git commit -m "Update changelog" -a
61+
git checkout -b $BRANCH
62+
git commit -am "Changelog update - $VERSION"
63+
git push --set-upstream origin $BRANCH
6464
65-
# Push changes
66-
- name: Push changes
67-
uses: ad-m/github-push-action@master
68-
with:
69-
branch: master
70-
github_token: ${{ secrets.GITHUB_TOKEN }}
65+
gh pr create \
66+
--title "Changelog update - \`$VERSION\`" \
67+
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
68+
--base master \
69+
--head $BRANCH

0 commit comments

Comments
 (0)