1
1
# GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
2
2
# - 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,
6
7
# - create a draft release.
7
8
#
8
9
# Workflow is triggered on push and pull_request events.
9
10
#
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
13
12
#
14
13
# # JBIJPPTPL
15
14
16
15
name : Build
17
- on : [push, pull_request]
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
+
18
23
jobs :
19
24
20
25
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
21
- gradleValidation :
22
- name : Gradle Wrapper
23
- runs-on : ubuntu-latest
24
- steps :
25
-
26
- # Check out current repository
27
- - name : Fetch Sources
28
- uses : actions/checkout@v3
29
-
30
- # Validate wrapper
31
- - name : Gradle Wrapper Validation
32
- uses : gradle/wrapper-validation-action@v1.0.5
33
-
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@v3
44
- with :
45
- distribution : zulu
46
- java-version : 11
47
-
48
- # Check out current repository
49
- - name : Fetch Sources
50
- uses : actions/checkout@v3
51
-
52
- # Cache Gradle dependencies
53
- - name : Setup Gradle Dependencies Cache
54
- uses : actions/cache@v3
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
- uses : actions/cache@v3
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
26
+ # Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
27
+ # Build plugin and provide the artifact for the next workflow jobs
76
28
build :
77
29
name : Build
78
- needs : test
79
30
runs-on : ubuntu-latest
80
31
outputs :
81
- name : ${{ steps.properties.outputs.name }}
82
32
version : ${{ steps.properties.outputs.version }}
83
33
changelog : ${{ steps.properties.outputs.changelog }}
84
- artifact : ${{ steps.properties.outputs.artifact }}
85
34
steps :
86
35
87
- # Setup Java 11 environment for the next steps
88
- - name : Setup Java
89
- uses : actions/setup-java@v3
90
- with :
91
- distribution : zulu
92
- 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
93
42
94
43
# Check out current repository
95
44
- name : Fetch Sources
96
45
uses : actions/checkout@v3
97
46
98
- # Cache Gradle Dependencies
99
- - name : Setup Gradle Dependencies Cache
100
- uses : actions/cache@v3
101
- with :
102
- path : ~/.gradle/caches
103
- key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
47
+ # Validate wrapper
48
+ - name : Gradle Wrapper Validation
49
+ uses : gradle/wrapper-validation-action@v1.0.5
104
50
105
- # Cache Gradle Wrapper
106
- - name : Setup Gradle Wrapper Cache
107
- uses : actions/cache @v3
51
+ # Setup Java 17 environment for the next steps
52
+ - name : Setup Java
53
+ uses : actions/setup-java @v3
108
54
with :
109
- path : ~/.gradle/wrapper
110
- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
55
+ distribution : zulu
56
+ java-version : 17
111
57
112
58
# Set environment variables
113
59
- name : Export Properties
@@ -121,86 +67,82 @@ jobs:
121
67
CHANGELOG="${CHANGELOG//'%'/'%25'}"
122
68
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
123
69
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
124
- ARTIFACT="${NAME}-${VERSION}.zip"
125
70
126
71
echo "::set-output name=version::$VERSION"
127
72
echo "::set-output name=name::$NAME"
128
73
echo "::set-output name=changelog::$CHANGELOG"
129
- echo "::set-output name=artifact::$ARTIFACT "
74
+ echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier "
130
75
131
- # Build artifact using buildPlugin Gradle task
132
- - name : Build Plugin
133
- run : ./gradlew buildPlugin
76
+ ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
134
77
135
- # Upload plugin artifact to make it available in the next jobs
136
- - name : Upload artifact
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() }}
137
85
uses : actions/upload-artifact@v3
138
86
with :
139
- name : plugin-artifact
140
- path : ./build/distributions/${{ steps.properties.outputs.artifact }}
141
-
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 :
87
+ name : tests-result
88
+ path : ${{ github.workspace }}/build/reports/tests
149
89
150
- # Setup Java 11 environment for the next steps
151
- - name : Setup Java
152
- uses : actions/setup-java @v3
90
+ # Upload Kover report to CodeCov
91
+ - name : Upload Code Coverage Report
92
+ uses : codecov/codecov-action @v3
153
93
with :
154
- distribution : zulu
155
- java-version : 11
94
+ files : ${{ github.workspace }}/build/reports/kover/xml/report.xml
156
95
157
- # Check out current repository
158
- - name : Fetch Sources
159
- uses : actions/checkout@v3
160
-
161
- # Cache Gradle Dependencies
162
- - name : Setup Gradle Dependencies Cache
96
+ # Cache Plugin Verifier IDEs
97
+ - name : Setup Plugin Verifier IDEs Cache
163
98
uses : actions/cache@v3
164
99
with :
165
- path : ~/.gradle/caches
166
- key : ${{ runner.os }}-gradle-caches- ${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties ') }}
100
+ path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
101
+ key : plugin-verifier- ${{ hashFiles('build/listProductsReleases.txt ') }}
167
102
168
- # Cache Gradle Wrapper
169
- - name : Setup Gradle Wrapper Cache
170
- uses : actions/cache@v3
103
+ # Run Verify Plugin task and IntelliJ Plugin Verifier tool
104
+ - name : Run Plugin Verification tasks
105
+ run : ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
106
+
107
+ # Collect Plugin Verifier Result
108
+ - name : Collect Plugin Verifier Result
109
+ if : ${{ always() }}
110
+ uses : actions/upload-artifact@v3
171
111
with :
172
- path : ~/.gradle/wrapper
173
- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
112
+ name : pluginVerifier-result
113
+ path : ${{ github.workspace }}/build/reports/pluginVerifier
174
114
175
- # Set environment variables
176
- - name : Export Properties
177
- id : properties
115
+ # Run Qodana inspections
116
+ - name : Qodana - Code Inspection
117
+ uses : JetBrains/qodana-action@v2022.2.3
118
+
119
+ # Prepare plugin archive content for creating artifact
120
+ - name : Prepare Plugin Artifact
121
+ id : artifact
178
122
shell : bash
179
123
run : |
180
- PROPERTIES="$(./gradlew properties --console=plain -q)"
181
- IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
124
+ cd ${{ github.workspace }}/build/distributions
125
+ FILENAME=`ls *.zip`
126
+ unzip "$FILENAME" -d content
182
127
183
- echo "::set-output name=ideVersions::$IDE_VERSIONS"
184
- echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
128
+ echo "::set-output name=filename::${FILENAME:0:-4}"
185
129
186
- # Cache Plugin Verifier IDEs
187
- - name : Setup Plugin Verifier IDEs Cache
188
- uses : actions/cache @v3
130
+ # Store already-built plugin as an artifact for downloading
131
+ - name : Upload artifact
132
+ uses : actions/upload-artifact @v3
189
133
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 }}
134
+ name : ${{ steps.artifact.outputs.filename }}
135
+ path : ./build/distributions/content/*/*
196
136
197
137
# Prepare a draft release for GitHub Releases page for the manual verification
198
138
# If accepted and published, release workflow would be triggered
199
139
releaseDraft :
200
140
name : Release Draft
201
141
if : github.event_name != 'pull_request'
202
- needs : [ build, verify]
142
+ needs : build
203
143
runs-on : ubuntu-latest
144
+ permissions :
145
+ contents : write
204
146
steps :
205
147
206
148
# Check out current repository
@@ -212,38 +154,19 @@ jobs:
212
154
env :
213
155
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
214
156
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/{}
157
+ gh api repos/{owner}/{repo}/releases \
158
+ --jq '.[] | select(.draft == true) | .id' \
159
+ | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
220
160
221
161
# Create new release draft - which is not publicly visible and requires manual acceptance
222
162
- name : Create Release Draft
223
- id : createDraft
224
- uses : actions/create-release@v1.1.4
225
163
env :
226
164
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@v3
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
- uses : actions/upload-release-asset@v1.0.2
243
- env :
244
- 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
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