11# GitHub Actions Workflow created for testing and preparing the plugin release in 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 ' buildPlugin' task and prepare artifact for the further tests,
5+ # - run 'runPluginVerifier' task ,
66# - create a draft release.
77#
88# Workflow is triggered on push and pull_request events.
99#
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
10+ # GitHub Actions reference: https://help.github.com/en/actions
1311#
1412# # JBIJPPTPL
1513
1614name : Build
17- on : [push, pull_request]
15+ on :
16+ # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
17+ push :
18+ branches : [main]
19+ # Trigger the workflow on any pull request
20+ pull_request :
21+
1822jobs :
1923
2024 # Run Gradle Wrapper Validation Action to verify the wrapper's checksum
21- gradleValidation :
22- name : Gradle Wrapper
25+ # Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
26+ # Build plugin and provide the artifact for the next workflow jobs
27+ build :
28+ name : Build
2329 runs-on : ubuntu-latest
30+ outputs :
31+ version : ${{ steps.properties.outputs.version }}
32+ changelog : ${{ steps.properties.outputs.changelog }}
2433 steps :
2534
2635 # Check out current repository
2736 - name : Fetch Sources
28- uses : actions/checkout@v2.3.4
37+ uses : actions/checkout@v2.4.0
2938
3039 # Validate wrapper
3140 - name : Gradle Wrapper Validation
32413342
34- # Run verifyPlugin and test Gradle tasks
35- test :
36- name : Test
37- needs : gradleValidation
38- runs-on : ubuntu-latest
39- steps :
40-
41- # Setup Java 11 environment for the next steps
42- - name : Setup Java
43- uses : actions/setup-java@v2
44- with :
45- distribution : zulu
46- java-version : 11
47-
48- # Check out current repository
49- - name : Fetch Sources
50- 51-
52- # Cache Gradle dependencies
53- - name : Setup Gradle Dependencies Cache
54- 55- with :
56- path : ~/.gradle/caches
57- key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
58-
59- # Cache Gradle Wrapper
60- - name : Setup Gradle Wrapper Cache
61- 62- with :
63- path : ~/.gradle/wrapper
64- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
65-
66- # Run detekt, ktlint and tests
67- - name : Run Linters and Test
68- run : ./gradlew check
69-
70- # Run verifyPlugin Gradle task
71- - name : Verify Plugin
72- run : ./gradlew verifyPlugin
73-
74- # Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
75- # Requires test job to be passed
76- build :
77- name : Build
78- needs : test
79- runs-on : ubuntu-latest
80- outputs :
81- name : ${{ steps.properties.outputs.name }}
82- version : ${{ steps.properties.outputs.version }}
83- changelog : ${{ steps.properties.outputs.changelog }}
84- artifact : ${{ steps.properties.outputs.artifact }}
85- steps :
86-
8743 # Setup Java 11 environment for the next steps
8844 - name : Setup Java
8945 uses : actions/setup-java@v2
9046 with :
9147 distribution : zulu
9248 java-version : 11
93-
94- # Check out current repository
95- - name : Fetch Sources
96- uses : actions/checkout@v2
97-
98- # Cache Gradle Dependencies
99- - name : Setup Gradle Dependencies Cache
100- 101- with :
102- path : ~/.gradle/caches
103- key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
104-
105- # Cache Gradle Wrapper
106- - name : Setup Gradle Wrapper Cache
107- 108- with :
109- path : ~/.gradle/wrapper
110- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
49+ cache : gradle
11150
11251 # Set environment variables
11352 - name : Export Properties
@@ -121,129 +60,94 @@ jobs:
12160 CHANGELOG="${CHANGELOG//'%'/'%25'}"
12261 CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
12362 CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
124- ARTIFACT="${NAME}-${VERSION}.zip"
12563
12664 echo "::set-output name=version::$VERSION"
12765 echo "::set-output name=name::$NAME"
12866 echo "::set-output name=changelog::$CHANGELOG"
129- echo "::set-output name=artifact::$ARTIFACT "
67+ echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier "
13068
131- # Build artifact using buildPlugin Gradle task
132- - name : Build Plugin
133- run : ./gradlew buildPlugin
69+ ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
13470
135- # Upload plugin artifact to make it available in the next jobs
136- - name : Upload artifact
137- 138- with :
139- name : plugin-artifact
140- path : ./build/distributions/${{ steps.properties.outputs.artifact }}
71+ # Run tests
72+ - name : Run Tests
73+ run : ./gradlew test
14174
142- # Verify built plugin using IntelliJ Plugin Verifier tool
143- # Requires build job to be passed
144- verify :
145- name : Verify
146- needs : build
147- runs-on : ubuntu-latest
148- steps :
149-
150- # Setup Java 11 environment for the next steps
151- - name : Setup Java
152- uses : actions/setup-java@v2
75+ # Collect Tests Result of failed tests
76+ - name : Collect Tests Result
77+ if : ${{ failure() }}
78+ uses : actions/upload-artifact@v2
15379 with :
154- distribution : zulu
155- java-version : 11
156-
157- # Check out current repository
158- - name : Fetch Sources
159- 80+ name : tests-result
81+ path : ${{ github.workspace }}/build/reports/tests
16082
161- # Cache Gradle Dependencies
162- - name : Setup Gradle Dependencies Cache
83+ # Cache Plugin Verifier IDEs
84+ - name : Setup Plugin Verifier IDEs Cache
1638516486 with :
165- path : ~/.gradle/caches
166- key : ${{ runner.os }}-gradle-caches- ${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties ') }}
87+ path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
88+ key : plugin-verifier- ${{ hashFiles('build/listProductsReleases.txt ') }}
16789
168- # Cache Gradle Wrapper
169- - name : Setup Gradle Wrapper Cache
170- 90+ # Run Verify Plugin task and IntelliJ Plugin Verifier tool
91+ - name : Run Plugin Verification tasks
92+ run : ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
93+
94+ # Collect Plugin Verifier Result
95+ - name : Collect Plugin Verifier Result
96+ if : ${{ always() }}
97+ uses : actions/upload-artifact@v2
17198 with :
172- path : ~/.gradle/wrapper
173- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
99+ name : pluginVerifier-result
100+ path : ${{ github.workspace }}/build/reports/pluginVerifier
174101
175- # Set environment variables
176- - name : Export Properties
177- id : properties
102+ # Prepare plugin archive content for creating artifact
103+ - name : Prepare Plugin Artifact
104+ id : artifact
178105 shell : bash
179106 run : |
180- PROPERTIES="$(./gradlew properties --console=plain -q)"
181- IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
107+ cd ${{ github.workspace }}/build/distributions
108+ FILENAME=`ls *.zip`
109+ unzip "$FILENAME" -d content
182110
183- echo "::set-output name=ideVersions::$IDE_VERSIONS"
184- echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
111+ echo "::set-output name=filename::$FILENAME"
185112
186- # Cache Plugin Verifier IDEs
187- - name : Setup Plugin Verifier IDEs Cache
188- uses : actions/cache @v2.1.6
113+ # Store already-built plugin as an artifact for downloading
114+ - name : Upload artifact
115+ uses : actions/upload-artifact @v2.2.4
189116 with :
190- path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
191- key : ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
192-
193- # Run IntelliJ Plugin Verifier action using GitHub Action
194- - name : Verify Plugin
195- run : ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
117+ name : ${{ steps.artifact.outputs.filename }}
118+ path : ./build/distributions/content/*/*
196119
197120 # Prepare a draft release for GitHub Releases page for the manual verification
198121 # If accepted and published, release workflow would be triggered
199122 releaseDraft :
200123 name : Release Draft
201124 if : github.event_name != 'pull_request'
202- needs : [ build, verify]
125+ needs : build
203126 runs-on : ubuntu-latest
204127 steps :
205128
206129 # Check out current repository
207130 - name : Fetch Sources
208- uses : actions/checkout@v2.3.4
131+ uses : actions/checkout@v2.4.0
209132
210133 # Remove old release drafts by using the curl request for the available releases with draft flag
211134 - name : Remove Old Release Drafts
212135 env :
213136 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
214137 run : |
215- curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
216- | tr '\r\n' ' ' \
217- | jq '.[] | select(.draft == true) | .id' \
218- | xargs -I '{}' \
219- curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
138+ gh api repos/{owner}/{repo}/releases \
139+ --jq '.[] | select(.draft == true) | .id' \
140+ | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
220141
221142 # Create new release draft - which is not publicly visible and requires manual acceptance
222143 - name : Create Release Draft
223- id : createDraft
224- 225- env :
226- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
227- with :
228- tag_name : v${{ needs.build.outputs.version }}
229- release_name : v${{ needs.build.outputs.version }}
230- body : ${{ needs.build.outputs.changelog }}
231- draft : true
232-
233- # Download plugin artifact provided by the previous job
234- - name : Download Artifact
235- uses : actions/download-artifact@v2
236- with :
237- name : plugin-artifact
238-
239- # Upload artifact as a release asset
240- - name : Upload Release Asset
241- id : upload-release-asset
242- 243144 env :
244145 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
245- with :
246- upload_url : ${{ steps.createDraft.outputs.upload_url }}
247- asset_path : ./${{ needs.build.outputs.artifact }}
248- asset_name : ${{ needs.build.outputs.artifact }}
249- asset_content_type : application/zip
146+ run : |
147+ gh release create v${{ needs.build.outputs.version }} \
148+ --draft \
149+ --title "v${{ needs.build.outputs.version }}" \
150+ --notes "$(cat << 'EOM'
151+ ${{ needs.build.outputs.changelog }}
152+ EOM
153+ )"
0 commit comments