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:
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 Qodana inspections,
5+ # - run 'buildPlugin' task and prepare artifact for the further tests,
6+ # - run 'runPluginVerifier' task,
67# - create a draft release.
78#
89# Workflow is triggered on push and pull_request events.
910#
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
1312#
1413# # JBIJPPTPL
1514
2423jobs :
2524
2625 # Run Gradle Wrapper Validation Action to verify the wrapper's checksum
27- gradleValidation :
28- name : Gradle Wrapper
29- # runs-on: self-hosted
30- runs-on : ubuntu-latest
31- steps :
32-
33- # Check out current repository
34- - name : Fetch Sources
35- uses : actions/checkout@v2.3.4
36-
37- # Validate wrapper
38- - name : Gradle Wrapper Validation
39- uses : gradle/wrapper-validation-action@v1.0.4
40-
41- # Run verifyPlugin and test Gradle tasks
42- test :
43- name : Test
44- needs : gradleValidation
45- # runs-on: self-hosted
46- runs-on : ubuntu-latest
47- steps :
48-
49- # Setup Java 11 environment for the next steps
50- - name : Setup Java
51- uses : actions/setup-java@v2
52- with :
53- distribution : zulu
54- java-version : 11
55-
56- # Check out current repository
57- - name : Fetch Sources
58- uses : actions/checkout@v2.3.4
59-
60- # Cache Gradle dependencies
61- - name : Setup Gradle Dependencies Cache
62- uses : actions/cache@v2.1.6
63- with :
64- path : ~/.gradle/caches
65- key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
66-
67- # Cache Gradle Wrapper
68- - name : Setup Gradle Wrapper Cache
69- uses : actions/cache@v2.1.6
70- with :
71- path : ~/.gradle/wrapper
72- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
73-
74- # Run detekt, ktlint and tests
75- - name : Run Linters and Test
76- run : ./gradlew check
77-
78- # Run verifyPlugin Gradle task
79- - name : Verify Plugin
80- run : ./gradlew verifyPlugin
81-
82- # Build plugin with buildPlugin Gradle task and provide the artifact for the next workflow jobs
83- # 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
8428 build :
8529 name : Build
86- needs : test
87- # runs-on: self-hosted
8830 runs-on : ubuntu-latest
8931 outputs :
90- name : ${{ steps.properties.outputs.name }}
9132 version : ${{ steps.properties.outputs.version }}
9233 changelog : ${{ steps.properties.outputs.changelog }}
93- artifact : ${{ steps.properties.outputs.artifact }}
9434 steps :
9535
96- # Setup Java 11 environment for the next steps
97- - name : Setup Java
98- uses : actions/setup-java@v2
99- with :
100- distribution : zulu
101- 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
10242
10343 # Check out current repository
10444 - name : Fetch Sources
105- uses : actions/checkout@v2.3.4
45+ uses : actions/checkout@v3
10646
107- # Cache Gradle Dependencies
108- - name : Setup Gradle Dependencies Cache
109- uses : actions/cache@v2.1.6
110- with :
111- path : ~/.gradle/caches
112- 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.6
11350
114- # Cache Gradle Wrapper
115- - name : Setup Gradle Wrapper Cache
116- uses : actions/cache@v2.1.6
51+ # Setup Java environment for the next steps
52+ - name : Setup Java
53+ uses : actions/setup-java@v3
11754 with :
118- path : ~/.gradle/wrapper
119- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
55+ distribution : zulu
56+ java-version : 17
57+ cache : gradle
12058
12159 # Set environment variables
12260 - name : Export Properties
@@ -127,134 +65,109 @@ jobs:
12765 VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
12866 NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
12967 CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
130- CHANGELOG="${CHANGELOG//'%'/'%25'}"
131- CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
132- CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
133- ARTIFACT="${NAME}-${VERSION}.zip"
13468
135- echo "::set-output name=version::$VERSION"
136- echo "::set-output name=name::$NAME"
137- echo "::set-output name=changelog::$CHANGELOG"
138- echo "::set-output name=artifact::$ARTIFACT"
69+ echo "version=$VERSION" >> $GITHUB_OUTPUT
70+ echo "name=$NAME" >> $GITHUB_OUTPUT
71+ echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
72+
73+ echo "changelog<<EOF" >> $GITHUB_OUTPUT
74+ echo "$CHANGELOG" >> $GITHUB_OUTPUT
75+ echo "EOF" >> $GITHUB_OUTPUT
13976
140- # Build artifact using buildPlugin Gradle task
141- - name : Build Plugin
142- run : ./gradlew buildPlugin
77+ ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
14378
144- # Upload plugin artifact to make it available in the next jobs
145- - name : Upload artifact
146- uses : actions/upload-artifact@v2.2.3
79+ # Run tests
80+ - name : Run Tests
81+ run : ./gradlew check
82+
83+ # Collect Tests Result of failed tests
84+ - name : Collect Tests Result
85+ if : ${{ failure() }}
86+ uses : actions/upload-artifact@v3
14787 with :
148- name : plugin-artifact
149- path : ./build/distributions/ ${{ steps.properties.outputs.artifact }}
88+ name : tests-result
89+ path : ${{ github.workspace }}/build/reports/tests
15090
151- # Verify built plugin using IntelliJ Plugin Verifier tool
152- # Requires build job to be passed
153- verify :
154- name : Verify
155- needs : build
156- # runs-on: self-hosted
157- runs-on : ubuntu-latest
158- steps :
91+ # Upload Kover report to CodeCov
92+ - name : Upload Code Coverage Report
93+ uses : codecov/codecov-action@v3
94+ with :
95+ files : ${{ github.workspace }}/build/reports/kover/xml/report.xml
15996
160- # Setup Java 11 environment for the next steps
161- - name : Setup Java
162- uses : actions/setup-java@v2
97+ # Cache Plugin Verifier IDEs
98+ - name : Setup Plugin Verifier IDEs Cache
99+ uses : actions/cache@v3
163100 with :
164- distribution : zulu
165- java-version : 11
101+ path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
102+ key : plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
166103
167- # Check out current repository
168- - name : Fetch Sources
169- uses : actions/checkout@v2.3.4
104+ # Run Verify Plugin task and IntelliJ Plugin Verifier tool
105+ - name : Run Plugin Verification tasks
106+ run : ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
170107
171- # Cache Gradle Dependencies
172- - name : Setup Gradle Dependencies Cache
173- uses : actions/cache@v2.1.6
108+ # Collect Plugin Verifier Result
109+ - name : Collect Plugin Verifier Result
110+ if : ${{ always() }}
111+ uses : actions/upload-artifact@v3
174112 with :
175- path : ~/.gradle/caches
176- key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
113+ name : pluginVerifier-result
114+ path : ${{ github.workspace }}/build/reports/pluginVerifier
177115
178- # Cache Gradle Wrapper
179- - name : Setup Gradle Wrapper Cache
180- uses : actions/cache@v2.1.6
181- with :
182- path : ~/.gradle/wrapper
183- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
116+ # Run Qodana inspections
117+ - name : Qodana - Code Inspection
118+ uses : JetBrains/qodana-action@v2023.1.0
184119
185- # Set environment variables
186- # - name: Export Properties
187- # id: properties
188- # shell: bash
189- # run: |
190- # PROPERTIES="$(./gradlew properties --console=plain -q)"
191- # IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
192- #
193- # echo "::set-output name=ideVersions::$IDE_VERSIONS"
194- # echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
120+ # Prepare plugin archive content for creating artifact
121+ - name : Prepare Plugin Artifact
122+ id : artifact
123+ shell : bash
124+ run : |
125+ cd ${{ github.workspace }}/build/distributions
126+ FILENAME=`ls *.zip`
127+ unzip "$FILENAME" -d content
195128
196- # Cache Plugin Verifier IDEs
197- - name : Setup Plugin Verifier IDEs Cache
198- uses : actions/cache@v2.1.6
199- with :
200- path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
201- key : ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
129+ echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
202130
203- # Run IntelliJ Plugin Verifier action using GitHub Action
204- - name : Verify Plugin
205- run : ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
131+ # Store already-built plugin as an artifact for downloading
132+ - name : Upload artifact
133+ uses : actions/upload-artifact@v3
134+ with :
135+ name : ${{ steps.artifact.outputs.filename }}
136+ path : ./build/distributions/content/*/*
206137
207138 # Prepare a draft release for GitHub Releases page for the manual verification
208139 # If accepted and published, release workflow would be triggered
209140 releaseDraft :
210141 name : Release Draft
211142 if : github.event_name != 'pull_request'
212- needs : [build, verify]
213- # runs-on: self-hosted
143+ needs : build
214144 runs-on : ubuntu-latest
145+ permissions :
146+ contents : write
215147 steps :
216148
217149 # Check out current repository
218150 - name : Fetch Sources
219- uses : actions/checkout@v2.3.4
151+ uses : actions/checkout@v3
220152
221- # Remove old release drafts by using the curl request for the available releases with draft flag
153+ # Remove old release drafts by using the curl request for the available releases with a draft flag
222154 - name : Remove Old Release Drafts
223155 env :
224156 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
225157 run : |
226- curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
227- | tr '\r\n' ' ' \
228- | jq '.[] | select(.draft == true) | .id' \
229- | xargs -I '{}' \
230- curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
158+ gh api repos/{owner}/{repo}/releases \
159+ --jq '.[] | select(.draft == true) | .id' \
160+ | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
231161
232- # Create new release draft - which is not publicly visible and requires manual acceptance
162+ # Create a new release draft which is not publicly visible and requires manual acceptance
233163 - name : Create Release Draft
234- id : createDraft
235- uses : actions/create-release@v1.1.4
236164 env :
237165 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
238- with :
239- tag_name : v${{ needs.build.outputs.version }}
240- release_name : v${{ needs.build.outputs.version }}
241- body : ${{ needs.build.outputs.changelog }}
242- draft : true
243-
244- # Download plugin artifact provided by the previous job
245- - name : Download Artifact
246- uses : actions/download-artifact@v2
247- with :
248- name : plugin-artifact
249-
250- # Upload artifact as a release asset
251- - name : Upload Release Asset
252- id : upload-release-asset
253- uses : actions/upload-release-asset@v1.0.2
254- env :
255- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
256- with :
257- upload_url : ${{ steps.createDraft.outputs.upload_url }}
258- asset_path : ./${{ needs.build.outputs.artifact }}
259- asset_name : ${{ needs.build.outputs.artifact }}
260- asset_content_type : application/zip
166+ run : |
167+ gh release create v${{ needs.build.outputs.version }} \
168+ --draft \
169+ --title "v${{ needs.build.outputs.version }}" \
170+ --notes "$(cat << 'EOM'
171+ ${{ needs.build.outputs.changelog }}
172+ EOM
173+ )"
0 commit comments