1- # GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
1+ # GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps:
22# - validate Gradle Wrapper,
3- # - run test and verifyPlugin tasks,
4- # - run buildPlugin task and prepare artifact for the further tests,
5- # - run IntelliJ Plugin Verifier,
3+ # - run 'test' and 'verifyPlugin' tasks,
4+ # - run Qodana inspections,
5+ # - run 'buildPlugin' task and prepare artifact for the further tests,
6+ # - run 'runPluginVerifier' task,
67# - create a draft release.
78#
89# Workflow is triggered on push and pull_request events.
910#
10- # Docs:
11- # - GitHub Actions: https://help.github.com/en/actions
12- # - IntelliJ Plugin Verifier GitHub Action: https://github.com/ChrisCarini/intellij-platform-plugin-verifier-action
11+ # GitHub Actions reference: https://help.github.com/en/actions
1312#
1413# # JBIJPPTPL
1514
2423jobs :
2524
2625 # Run Gradle Wrapper Validation Action to verify the wrapper's checksum
27- gradleValidation :
28- name : Gradle Wrapper
29- runs-on : ubuntu-latest
30- steps :
31-
32- # Check out current repository
33- - name : Fetch Sources
34- 35-
36- # Validate wrapper
37- - name : Gradle Wrapper Validation
38- 39-
40- # Run verifyPlugin and test Gradle tasks
41- test :
42- name : Test
43- needs : gradleValidation
44- runs-on : ubuntu-latest
45- steps :
46-
47- # Setup Java 11 environment for the next steps
48- - name : Setup Java
49- uses : actions/setup-java@v2
50- with :
51- distribution : zulu
52- java-version : 11
53-
54- # Check out current repository
55- - name : Fetch Sources
56- 57-
58- # Cache Gradle dependencies
59- - name : Setup Gradle Dependencies Cache
60- 61- with :
62- path : ~/.gradle/caches
63- key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
64-
65- # Cache Gradle Wrapper
66- - name : Setup Gradle Wrapper Cache
67- 68- with :
69- path : ~/.gradle/wrapper
70- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
71-
72- # Run detekt, ktlint and tests
73- - name : Run Linters and Test
74- run : ./gradlew check
75-
76- # Run verifyPlugin Gradle task
77- - name : Verify Plugin
78- run : ./gradlew verifyPlugin
79-
80- # Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
81- # Requires test job to be passed
26+ # Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
27+ # Build plugin and provide the artifact for the next workflow jobs
8228 build :
8329 name : Build
84- needs : test
8530 runs-on : ubuntu-latest
8631 outputs :
87- name : ${{ steps.properties.outputs.name }}
8832 version : ${{ steps.properties.outputs.version }}
8933 changelog : ${{ steps.properties.outputs.changelog }}
90- artifact : ${{ steps.properties.outputs.artifact }}
9134 steps :
9235
93- # Setup Java 11 environment for the next steps
94- - name : Setup Java
95- uses : actions/setup-java@v2
96- with :
97- distribution : zulu
98- java-version : 11
36+ # Free GitHub Actions Environment Disk Space
37+ - name : Maximize Build Space
38+ run : |
39+ sudo rm -rf /usr/share/dotnet
40+ sudo rm -rf /usr/local/lib/android
41+ sudo rm -rf /opt/ghc
9942
10043 # Check out current repository
10144 - name : Fetch Sources
102- uses : actions/checkout@v2.3.4
45+ uses : actions/checkout@v3
10346
104- # Cache Gradle Dependencies
105- - name : Setup Gradle Dependencies Cache
106- 107- with :
108- path : ~/.gradle/caches
109- key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
47+ # Validate wrapper
48+ - name : Gradle Wrapper Validation
49+ 11050
111- # Cache Gradle Wrapper
112- - name : Setup Gradle Wrapper Cache
113- 51+ # Setup Java 11 environment for the next steps
52+ - name : Setup Java
53+ uses : actions/setup-java@v3
11454 with :
115- path : ~/.gradle/wrapper
116- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
55+ distribution : zulu
56+ java-version : 11
11757
11858 # Set environment variables
11959 - name : Export Properties
@@ -124,132 +64,109 @@ jobs:
12464 VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
12565 NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
12666 CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
127- CHANGELOG="${CHANGELOG//'%'/'%25'}"
128- CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
129- CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
130- ARTIFACT="${NAME}-${VERSION}.zip"
13167
132- echo "::set-output name=version::$VERSION"
133- echo "::set-output name=name::$NAME"
134- echo "::set-output name=changelog::$CHANGELOG"
135- echo "::set-output name=artifact::$ARTIFACT"
68+ echo "version=$VERSION" >> $GITHUB_OUTPUT
69+ echo "name=$NAME" >> $GITHUB_OUTPUT
70+ echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
71+
72+ echo "changelog<<EOF" >> $GITHUB_OUTPUT
73+ echo "$CHANGELOG" >> $GITHUB_OUTPUT
74+ echo "EOF" >> $GITHUB_OUTPUT
13675
137- # Build artifact using buildPlugin Gradle task
138- - name : Build Plugin
139- run : ./gradlew buildPlugin
76+ ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
14077
141- # Upload plugin artifact to make it available in the next jobs
142- - name : Upload artifact
143- 78+ # Run tests
79+ - name : Run Tests
80+ run : ./gradlew check
81+
82+ # Collect Tests Result of failed tests
83+ - name : Collect Tests Result
84+ if : ${{ failure() }}
85+ uses : actions/upload-artifact@v3
14486 with :
145- name : plugin-artifact
146- path : ./build/distributions/ ${{ steps.properties.outputs.artifact }}
87+ name : tests-result
88+ path : ${{ github.workspace }}/build/reports/tests
14789
148- # Verify built plugin using IntelliJ Plugin Verifier tool
149- # Requires build job to be passed
150- verify :
151- name : Verify
152- needs : build
153- runs-on : ubuntu-latest
154- steps :
90+ # Upload Kover report to CodeCov
91+ - name : Upload Code Coverage Report
92+ uses : codecov/codecov-action@v3
93+ with :
94+ files : ${{ github.workspace }}/build/reports/kover/xml/report.xml
15595
156- # Setup Java 11 environment for the next steps
157- - name : Setup Java
158- uses : actions/setup-java@v2
96+ # Cache Plugin Verifier IDEs
97+ - name : Setup Plugin Verifier IDEs Cache
98+ uses : actions/cache@v3
15999 with :
160- distribution : zulu
161- java-version : 11
100+ path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
101+ key : plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
162102
163- # Check out current repository
164- - name : Fetch Sources
165- 103+ # Run Verify Plugin task and IntelliJ Plugin Verifier tool
104+ - name : Run Plugin Verification tasks
105+ run : ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
166106
167- # Cache Gradle Dependencies
168- - name : Setup Gradle Dependencies Cache
169- 107+ # Collect Plugin Verifier Result
108+ - name : Collect Plugin Verifier Result
109+ if : ${{ always() }}
110+ uses : actions/upload-artifact@v3
170111 with :
171- path : ~/.gradle/caches
172- key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
112+ name : pluginVerifier-result
113+ path : ${{ github.workspace }}/build/reports/pluginVerifier
173114
174- # Cache Gradle Wrapper
175- - name : Setup Gradle Wrapper Cache
176- 177- with :
178- path : ~/.gradle/wrapper
179- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
115+ # Run Qodana inspections
116+ - name : Qodana - Code Inspection
117+ 180118
181- # Set environment variables
182- - name : Export Properties
183- id : properties
119+ # Prepare plugin archive content for creating artifact
120+ - name : Prepare Plugin Artifact
121+ id : artifact
184122 shell : bash
185123 run : |
186- PROPERTIES="$(./gradlew properties --console=plain -q)"
187- IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
124+ cd ${{ github.workspace }}/build/distributions
125+ FILENAME=`ls *.zip`
126+ unzip "$FILENAME" -d content
188127
189- echo "::set-output name=ideVersions::$IDE_VERSIONS"
190- echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
128+ echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
191129
192- # Cache Plugin Verifier IDEs
193- - name : Setup Plugin Verifier IDEs Cache
194- 130+ # Store already-built plugin as an artifact for downloading
131+ - name : Upload artifact
132+ uses : actions/upload-artifact@v3
195133 with :
196- path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
197- key : ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
198-
199- # Run IntelliJ Plugin Verifier action using GitHub Action
200- - name : Verify Plugin
201- run : ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
134+ name : ${{ steps.artifact.outputs.filename }}
135+ path : ./build/distributions/content/*/*
202136
203137 # Prepare a draft release for GitHub Releases page for the manual verification
204138 # If accepted and published, release workflow would be triggered
205139 releaseDraft :
206140 name : Release Draft
207141 if : github.event_name != 'pull_request'
208- needs : [ build, verify]
142+ needs : build
209143 runs-on : ubuntu-latest
144+ permissions :
145+ contents : write
210146 steps :
211147
212148 # Check out current repository
213149 - name : Fetch Sources
214- uses : actions/checkout@v2.3.4
150+ uses : actions/checkout@v3
215151
216- # Remove old release drafts by using the curl request for the available releases with draft flag
152+ # Remove old release drafts by using the curl request for the available releases with a draft flag
217153 - name : Remove Old Release Drafts
218154 env :
219155 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
220156 run : |
221- curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
222- | tr '\r\n' ' ' \
223- | jq '.[] | select(.draft == true) | .id' \
224- | xargs -I '{}' \
225- curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
157+ gh api repos/{owner}/{repo}/releases \
158+ --jq '.[] | select(.draft == true) | .id' \
159+ | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
226160
227- # Create new release draft - which is not publicly visible and requires manual acceptance
161+ # Create a new release draft which is not publicly visible and requires manual acceptance
228162 - name : Create Release Draft
229- id : createDraft
230- 231163 env :
232164 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
233- with :
234- tag_name : v${{ needs.build.outputs.version }}
235- release_name : v${{ needs.build.outputs.version }}
236- body : ${{ needs.build.outputs.changelog }}
237- draft : true
238-
239- # Download plugin artifact provided by the previous job
240- - name : Download Artifact
241- uses : actions/download-artifact@v2
242- with :
243- name : plugin-artifact
244-
245- # Upload artifact as a release asset
246- - name : Upload Release Asset
247- id : upload-release-asset
248- 249- env :
250- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
251- with :
252- upload_url : ${{ steps.createDraft.outputs.upload_url }}
253- asset_path : ./${{ needs.build.outputs.artifact }}
254- asset_name : ${{ needs.build.outputs.artifact }}
255- asset_content_type : application/zip
165+ run : |
166+ gh release create v${{ needs.build.outputs.version }} \
167+ --draft \
168+ --title "v${{ needs.build.outputs.version }}" \
169+ --notes "$(cat << 'EOM'
170+ ${{ needs.build.outputs.changelog }}
171+ EOM
172+ )"
0 commit comments