14
14
# # JBIJPPTPL
15
15
16
16
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
+
18
24
jobs :
19
25
20
26
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
25
31
26
32
# Check out current repository
27
33
- name : Fetch Sources
28
- uses : actions/checkout@v2
34
+ uses : actions/checkout@v2.3.4
29
35
30
36
# Validate wrapper
31
37
- name : Gradle Wrapper Validation
@@ -38,75 +44,74 @@ jobs:
38
44
runs-on : ubuntu-latest
39
45
steps :
40
46
47
+ # Check out current repository
48
+ - name : Fetch Sources
49
+ uses : actions/checkout@v2.3.4
50
+
41
51
# Setup Java 11 environment for the next steps
42
52
- name : Setup Java
43
53
uses : actions/setup-java@v2
44
54
with :
45
- distribution : " temurin "
55
+ distribution : zulu
46
56
java-version : 11
57
+ cache : gradle
47
58
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)"
51
66
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"
58
69
59
- # Cache Gradle Wrapper
60
- - name : Setup Gradle Wrapper Cache
70
+ # Cache Plugin Verifier IDEs
71
+ - name : Setup Plugin Verifier IDEs Cache
61
72
uses : actions/cache@v2.1.6
62
73
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
65
80
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
69
84
70
85
# Run verifyPlugin Gradle task
71
86
- name : Verify Plugin
72
87
run : ./gradlew verifyPlugin
73
88
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
+
74
93
# Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
75
94
# Requires test job to be passed
76
95
build :
77
96
name : Build
78
97
needs : test
79
98
runs-on : ubuntu-latest
80
99
outputs :
81
- name : ${{ steps.properties.outputs.name }}
82
100
version : ${{ steps.properties.outputs.version }}
83
101
changelog : ${{ steps.properties.outputs.changelog }}
84
- artifact : ${{ steps.properties.outputs.artifact }}
85
102
steps :
86
103
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
-
93
104
# Check out current repository
94
105
- 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
103
107
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
107
111
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
110
115
111
116
# Set environment variables
112
117
- name : Export Properties
@@ -115,133 +120,55 @@ jobs:
115
120
run : |
116
121
PROPERTIES="$(./gradlew properties --console=plain -q)"
117
122
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 ' ')"
119
124
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
120
125
CHANGELOG="${CHANGELOG//'%'/'%25'}"
121
126
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
122
127
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
123
- ARTIFACT="${NAME}-${VERSION}.zip"
124
128
125
129
echo "::set-output name=version::$VERSION"
126
130
echo "::set-output name=name::$NAME"
127
131
echo "::set-output name=changelog::$CHANGELOG"
128
- echo "::set-output name=artifact::$ARTIFACT"
129
132
130
133
# Build artifact using buildPlugin Gradle task
131
134
- name : Build Plugin
132
135
run : ./gradlew buildPlugin
133
136
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
136
139
uses : actions/upload-artifact@v2.2.4
137
140
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/*
194
143
195
144
# Prepare a draft release for GitHub Releases page for the manual verification
196
145
# If accepted and published, release workflow would be triggered
197
146
releaseDraft :
198
147
name : Release Draft
199
148
if : github.event_name != 'pull_request'
200
- needs : [ build, verify]
149
+ needs : build
201
150
runs-on : ubuntu-latest
202
151
steps :
203
152
204
153
# Check out current repository
205
154
- name : Fetch Sources
206
- uses : actions/checkout@v2
155
+ uses : actions/checkout@v2.3.4
207
156
208
157
# Remove old release drafts by using the curl request for the available releases with draft flag
209
158
- name : Remove Old Release Drafts
210
159
env :
211
160
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
212
161
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/{}
218
165
219
166
# Create new release draft - which is not publicly visible and requires manual acceptance
220
167
- 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
241
168
env :
242
169
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 }}"
0 commit comments