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:
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
24
23
jobs :
25
24
26
25
# 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
82
28
build :
83
29
name : Build
84
- needs : test
85
30
runs-on : ubuntu-latest
86
31
outputs :
87
- name : ${{ steps.properties.outputs.name }}
88
32
version : ${{ steps.properties.outputs.version }}
89
33
changelog : ${{ steps.properties.outputs.changelog }}
90
- artifact : ${{ steps.properties.outputs.artifact }}
91
34
steps :
92
35
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
99
42
100
43
# Check out current repository
101
44
- name : Fetch Sources
102
- uses : actions/checkout@v2.3.4
45
+ uses : actions/checkout@v3
103
46
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
+
110
50
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
114
54
with :
115
- path : ~/.gradle/wrapper
116
- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
55
+ distribution : zulu
56
+ java-version : 11
117
57
118
58
# Set environment variables
119
59
- name : Export Properties
@@ -124,132 +64,109 @@ jobs:
124
64
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
125
65
NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
126
66
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"
131
67
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
136
75
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
140
77
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
144
86
with :
145
- name : plugin-artifact
146
- path : ./build/distributions/ ${{ steps.properties.outputs.artifact }}
87
+ name : tests-result
88
+ path : ${{ github.workspace }}/build/reports/tests
147
89
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
155
95
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
159
99
with :
160
- distribution : zulu
161
- java-version : 11
100
+ path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
101
+ key : plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
162
102
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 }}
166
106
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
170
111
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
173
114
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
+
180
118
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
184
122
shell : bash
185
123
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
188
127
189
- echo "::set-output name=ideVersions::$IDE_VERSIONS"
190
- echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
128
+ echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
191
129
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
195
133
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/*/*
202
136
203
137
# Prepare a draft release for GitHub Releases page for the manual verification
204
138
# If accepted and published, release workflow would be triggered
205
139
releaseDraft :
206
140
name : Release Draft
207
141
if : github.event_name != 'pull_request'
208
- needs : [ build, verify]
142
+ needs : build
209
143
runs-on : ubuntu-latest
144
+ permissions :
145
+ contents : write
210
146
steps :
211
147
212
148
# Check out current repository
213
149
- name : Fetch Sources
214
- uses : actions/checkout@v2.3.4
150
+ uses : actions/checkout@v3
215
151
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
217
153
- name : Remove Old Release Drafts
218
154
env :
219
155
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
220
156
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/{}
226
160
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
228
162
- name : Create Release Draft
229
- id : createDraft
230
-
231
163
env :
232
164
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