1414# # JBIJPPTPL
1515
1616name : Build
17- on : [push, pull_request]
17+ on :
18+ # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
19+ push :
20+ branches : [main]
21+ # Trigger the workflow on any pull request
22+ pull_request :
1823
1924jobs :
2025
@@ -26,11 +31,11 @@ jobs:
2631
2732 # Check out current repository
2833 - name : Fetch Sources
29- uses : actions/checkout@v2
34+ uses : actions/checkout@v2.3.4
3035
3136 # Validate wrapper
3237 - name : Gradle Wrapper Validation
33- uses : gradle/wrapper-validation-action@v1
38+ uses : gradle/wrapper-validation-action@v1.0.4
3439
3540 # Run verifyPlugin and test Gradle tasks
3641 test :
@@ -39,39 +44,39 @@ jobs:
3944 runs-on : ubuntu-latest
4045 steps :
4146
42- # Check out current repository
43- - name : Fetch Sources
44- uses : actions/checkout@v2
45-
46- # Setup Java 11 environment for the next steps
47+ # Setup Java 1.8 environment for the next steps
4748 - name : Setup Java
4849 uses : actions/setup-java@v2
4950 with :
5051 distribution : ' adopt'
5152 java-version : 11
5253
54+ # Check out current repository
55+ - name : Fetch Sources
56+ uses : actions/checkout@v2.3.4
57+
5358 # Cache Gradle dependencies
54- - name : Setup Cache
55- uses : actions/cache@v2
59+ - name : Setup Gradle Dependencies Cache
60+ uses : actions/cache@v2.1.6
5661 with :
57- path : |
58- ~/.gradle/caches
59- ~/.gradle/wrapper
60- key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
61- restore-keys : ${{ runner.os }}-gradle-
62-
63- # Run detekt
64- - name : Run Linters
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+ uses : actions/cache@v2.1.6
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
6574 run : ./gradlew check
6675
6776 # Run verifyPlugin Gradle task
6877 - name : Verify Plugin
6978 run : ./gradlew verifyPlugin
7079
71- # Run test Gradle task
72- - name : Run Tests
73- run : ./gradlew test
74-
7580 # Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
7681 # Requires test job to be passed
7782 build :
@@ -85,34 +90,39 @@ jobs:
8590 artifact : ${{ steps.properties.outputs.artifact }}
8691 steps :
8792
88- # Check out current repository
89- - name : Fetch Sources
90- uses : actions/checkout@v2
91-
92- # Setup Java 11 environment for the next steps
9393 - name : Setup Java
9494 uses : actions/setup-java@v2
9595 with :
9696 distribution : ' adopt'
9797 java-version : 11
9898
99- # Cache Gradle dependencies
100- - name : Setup Cache
101- uses : actions/cache@v2
99+ # Check out current repository
100+ - name : Fetch Sources
101+ uses : actions/checkout@v2.3.4
102+
103+ # Cache Gradle Dependencies
104+ - name : Setup Gradle Dependencies Cache
105+ uses : actions/cache@v2.1.6
102106 with :
103- path : |
104- ~/.gradle/caches
105- ~/.gradle/wrapper
106- key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
107- restore-keys : ${{ runner.os }}-gradle-
107+ path : ~/.gradle/caches
108+ key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
109+
110+ # Cache Gradle Wrapper
111+ - name : Setup Gradle Wrapper Cache
112+ uses : actions/cache@v2.1.6
113+ with :
114+ path : ~/.gradle/wrapper
115+ key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
108116
109117 # Set environment variables
110118 - name : Export Properties
111119 id : properties
120+ shell : bash
112121 run : |
113- VERSION="$(./gradlew properties --console=plain -q | grep "^version:" | cut -f2- -d ' ')"
114- NAME="$(./gradlew properties --console=plain -q | grep "^name:" | cut -f2- -d ' ')"
115- CHANGELOG=$(./gradlew getChangelog --unreleased --no-header --console=plain -q)
122+ PROPERTIES="$(./gradlew properties --console=plain -q)"
123+ VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
124+ NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
125+ CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
116126 CHANGELOG="${CHANGELOG//'%'/'%25'}"
117127 CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
118128 CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
@@ -129,10 +139,10 @@ jobs:
129139
130140 # Upload plugin artifact to make it available in the next jobs
131141 - name : Upload artifact
132- uses : actions/upload-artifact@v1
142+ uses : actions/upload-artifact@v2.2.3
133143 with :
134144 name : plugin-artifact
135- path : ./build/distributions/${{ needs.build .outputs.artifact }}
145+ path : ./build/distributions/${{ steps.properties .outputs.artifact }}
136146
137147 # Verify built plugin using IntelliJ Plugin Verifier tool
138148 # Requires build job to be passed
@@ -142,44 +152,64 @@ jobs:
142152 runs-on : ubuntu-latest
143153 steps :
144154
145- # Download plugin artifact provided by the previous job
146- - name : Download Artifact
147- uses : actions/download-artifact@v1
155+ - name : Setup Java
156+ uses : actions/setup-java@v2
148157 with :
149- name : plugin-artifact
158+ distribution : ' adopt'
159+ java-version : 11
150160
151- # Run IntelliJ Plugin Verifier action using GitHub Action
152- - name : Verify Plugin
153- id : verify
154- uses : ChrisCarini/intellij-platform-plugin-verifier-action@v0.0.2
161+ # Check out current repository
162+ - name : Fetch Sources
163+ uses : actions/checkout@v2.3.4
164+
165+ # Cache Gradle Dependencies
166+ - name : Setup Gradle Dependencies Cache
167+ uses : actions/cache@v2.1.6
155168 with :
156- plugin-location : plugin-artifact/*.zip
157- ide-versions : |
158- ideaIC:2019.3
159- ideaIC:2020.1
160- ideaIC:2020.2
161-
162- # Print the output of the verify step
163- - name : Print Logs
164- if : ${{ always() }}
165- env :
166- OUTPUT_LOG : ${{ steps.verify.outputs.verification-output-log-filename }}
169+ path : ~/.gradle/caches
170+ key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
171+
172+ # Cache Gradle Wrapper
173+ - name : Setup Gradle Wrapper Cache
174+ uses : actions/cache@v2.1.6
175+ with :
176+ path : ~/.gradle/wrapper
177+ key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
178+
179+ # Set environment variables
180+ - name : Export Properties
181+ id : properties
182+ shell : bash
167183 run : |
168- echo "The verifier log file [$OUTPUT_LOG] contents : " ;
169- cat $OUTPUT_LOG
184+ PROPERTIES="$(./gradlew properties --console=plain -q)"
185+ IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
186+
187+ echo "::set-output name=ideVersions::$IDE_VERSIONS"
188+ echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
189+
190+ # Cache Plugin Verifier IDEs
191+ - name : Setup Plugin Verifier IDEs Cache
192+ uses : actions/cache@v2.1.6
193+ with :
194+ path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
195+ key : ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
196+
197+ # Run IntelliJ Plugin Verifier action using GitHub Action
198+ - name : Verify Plugin
199+ run : ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
170200
171201 # Prepare a draft release for GitHub Releases page for the manual verification
172202 # If accepted and published, release workflow would be triggered
173203 releaseDraft :
174204 name : Release Draft
175- if : github.ref == 'refs/heads/master '
205+ if : github.event_name != 'pull_request '
176206 needs : [build, verify]
177207 runs-on : ubuntu-latest
178208 steps :
179209
180210 # Check out current repository
181211 - name : Fetch Sources
182- uses : actions/checkout@v2
212+ uses : actions/checkout@v2.3.4
183213
184214 # Remove old release drafts by using the curl request for the available releases with draft flag
185215 - name : Remove Old Release Drafts
@@ -195,7 +225,7 @@ jobs:
195225 # Create new release draft - which is not publicly visible and requires manual acceptance
196226 - name : Create Release Draft
197227 id : createDraft
198- uses : actions/create-release@v1
228+ uses : actions/create-release@v1.1.4
199229 env :
200230 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
201231 with :
@@ -206,18 +236,18 @@ jobs:
206236
207237 # Download plugin artifact provided by the previous job
208238 - name : Download Artifact
209- uses : actions/download-artifact@v1
239+ uses : actions/download-artifact@v2
210240 with :
211241 name : plugin-artifact
212242
213243 # Upload artifact as a release asset
214244 - name : Upload Release Asset
215245 id : upload-release-asset
216- uses : actions/upload-release-asset@v1
246+ uses : actions/upload-release-asset@v1.0.2
217247 env :
218248 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
219249 with :
220250 upload_url : ${{ steps.createDraft.outputs.upload_url }}
221- asset_path : ./plugin-artifact/ ${{ needs.build.outputs.artifact }}
251+ asset_path : ./${{ needs.build.outputs.artifact }}
222252 asset_name : ${{ needs.build.outputs.artifact }}
223253 asset_content_type : application/zip
0 commit comments