1- # GitHub Actions Workflow created for testing and preparing the plugin release in following steps:
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,
6- # - create a draft release.
1+ # GitHub Actions Workflow is created for testing and preparing the plugin release in the following steps:
2+ # - Validate Gradle Wrapper.
3+ # - Run ' test' and ' verifyPlugin' tasks.
4+ # - Run the ' buildPlugin' task and prepare artifact for further tests.
5+ # - Run the 'runPluginVerifier' task.
6+ # - Create a draft release.
77#
8- # Workflow is triggered on push and pull_request events.
8+ # The workflow is triggered on push and pull_request events.
99#
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
10+ # GitHub Actions reference: https://help.github.com/en/actions
1311#
1412# # JBIJPPTPL
1513
1614name : Build
1715on :
1816 # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g. for dependabot pull requests)
1917 push :
20- branches : [master]
18+ branches : [master, main ]
2119 # Trigger the workflow on any pull request
2220 pull_request :
2321
22+ concurrency :
23+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
24+ cancel-in-progress : true
25+
2426jobs :
2527
26- # Run Gradle Wrapper Validation Action to verify the wrapper's checksum
27- gradleValidation :
28- name : Gradle Wrapper
28+ # Prepare environment and build the plugin
29+ build :
30+ name : Build
2931 runs-on : ubuntu-latest
32+ outputs :
33+ version : ${{ steps.properties.outputs.version }}
34+ changelog : ${{ steps.properties.outputs.changelog }}
35+ pluginVerifierHomeDir : ${{ steps.properties.outputs.pluginVerifierHomeDir }}
3036 steps :
3137
32- # Check out current repository
38+ # Check out the current repository
3339 - name : Fetch Sources
3440 uses : actions/checkout@v4
3541
3642 # Validate wrapper
3743 - name : Gradle Wrapper Validation
38- uses : gradle/wrapper-validation-action@v1.0.4
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 17 environment for the next steps
48- - name : Setup Java
49- uses : actions/setup-java@v4
50- with :
51- distribution : zulu
52- java-version : 17
53-
54- # Check out current repository
55- - name : Fetch Sources
56- uses : actions/checkout@v4
57-
58- # Cache Gradle dependencies
59- - name : Setup Gradle Dependencies Cache
60- uses : actions/cache@v4
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- uses : actions/cache@v4
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
82- build :
83- name : Build
84- needs : test
85- runs-on : ubuntu-latest
86- outputs :
87- name : ${{ steps.properties.outputs.name }}
88- version : ${{ steps.properties.outputs.version }}
89- changelog : ${{ steps.properties.outputs.changelog }}
90- artifact : ${{ steps.properties.outputs.artifact }}
91- steps :
44+ uses : gradle/actions/wrapper-validation@v3
9245
93- # Setup Java 17 environment for the next steps
46+ # Set up Java environment for the next steps
9447 - name : Setup Java
9548 uses : actions/setup-java@v4
9649 with :
9750 distribution : zulu
9851 java-version : 17
9952
100- # Check out current repository
101- - name : Fetch Sources
102- uses : actions/checkout@v4
103-
104- # Cache Gradle Dependencies
105- - name : Setup Gradle Dependencies Cache
106- uses : actions/cache@v4
107- with :
108- path : ~/.gradle/caches
109- key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
110-
111- # Cache Gradle Wrapper
112- - name : Setup Gradle Wrapper Cache
113- uses : actions/cache@v4
114- with :
115- path : ~/.gradle/wrapper
116- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
53+ # Setup Gradle
54+ - name : Setup Gradle
55+ uses : gradle/actions/setup-gradle@v4
11756
11857 # Set environment variables
11958 - name : Export Properties
@@ -122,134 +61,152 @@ jobs:
12261 run : |
12362 PROPERTIES="$(./gradlew properties --console=plain -q)"
12463 VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
125- NAME="$(echo "$PROPERTIES" | grep "^pluginName:" | cut -f2- -d ' ')"
12664 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-
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"
136-
137- # Build artifact using buildPlugin Gradle task
138- - name : Build Plugin
65+
66+ echo "version=$VERSION" >> $GITHUB_OUTPUT
67+ echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
68+
69+ echo "changelog<<EOF" >> $GITHUB_OUTPUT
70+ echo "$CHANGELOG" >> $GITHUB_OUTPUT
71+ echo "EOF" >> $GITHUB_OUTPUT
72+
73+ # Build plugin
74+ - name : Build plugin
13975 run : ./gradlew buildPlugin
14076
141- # Upload plugin artifact to make it available in the next jobs
77+ # Prepare plugin archive content for creating artifact
78+ - name : Prepare Plugin Artifact
79+ id : artifact
80+ shell : bash
81+ run : |
82+ cd ${{ github.workspace }}/build/distributions
83+ FILENAME=`ls *.zip`
84+ unzip "$FILENAME" -d content
85+
86+ echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
87+
88+ # Store already-built plugin as an artifact for downloading
14289 - name : Upload artifact
14390 uses : actions/upload-artifact@v4
14491 with :
145- name : plugin- artifact
146- path : ./build/distributions/${{ steps.properties.outputs.artifact }}
92+ name : ${{ steps. artifact.outputs.filename }}
93+ path : ./build/distributions/content/*/*
14794
148- # Verify built plugin using IntelliJ Plugin Verifier tool
149- # Requires build job to be passed
150- verify :
151- name : Verify
152- needs : build
95+ # Run tests and upload test reports on failure
96+ test :
97+ name : Test
98+ needs : [ build ]
15399 runs-on : ubuntu-latest
154100 steps :
155101
156- # Setup Java 17 environment for the next steps
102+ # Check out the current repository
103+ - name : Fetch Sources
104+ uses : actions/checkout@v4
105+
106+ # Set up Java environment for the next steps
157107 - name : Setup Java
158108 uses : actions/setup-java@v4
159109 with :
160110 distribution : zulu
161111 java-version : 17
162112
163- # Check out current repository
164- - name : Fetch Sources
165- uses : actions/checkout @v4
113+ # Setup Gradle
114+ - name : Setup Gradle
115+ uses : gradle/ actions/setup-gradle @v4
166116
167- # Cache Gradle Dependencies
168- - name : Setup Gradle Dependencies Cache
169- uses : actions/cache@v4
117+ # Run tests
118+ - name : Run Tests
119+ run : ./gradlew check
120+
121+ # Collect Tests Result of failed tests
122+ - name : Collect Tests Result
123+ if : ${{ failure() }}
124+ uses : actions/upload-artifact@v4
170125 with :
171- path : ~/.gradle/caches
172- key : ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}
126+ name : tests-result
127+ path : ${{ github.workspace }}/build/reports/tests
173128
174- # Cache Gradle Wrapper
175- - name : Setup Gradle Wrapper Cache
176- uses : actions/cache@v4
129+ # Run plugin structure verification along with IntelliJ Plugin Verifier
130+ verify :
131+ name : Verify plugin
132+ needs : [ build ]
133+ runs-on : ubuntu-latest
134+ steps :
135+
136+ # Free GitHub Actions Environment Disk Space
137+ - name : Maximize Build Space
138+ uses : jlumbroso/free-disk-space@main
177139 with :
178- path : ~/.gradle/wrapper
179- key : ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
140+ tool-cache : false
141+ large-packages : false
180142
181- # Set environment variables
182- - name : Export Properties
183- id : properties
184- shell : bash
185- run : |
186- PROPERTIES="$(./gradlew properties --console=plain -q)"
187- IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
143+ # Check out the current repository
144+ - name : Fetch Sources
145+ uses : actions/checkout@v4
146+
147+ # Set up Java environment for the next steps
148+ - name : Setup Java
149+ uses : actions/setup-java@v4
150+ with :
151+ distribution : zulu
152+ java-version : 17
188153
189- echo "::set-output name=ideVersions::$IDE_VERSIONS"
190- echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
154+ # Setup Gradle
155+ - name : Setup Gradle
156+ uses : gradle/actions/setup-gradle@v4
191157
192158 # Cache Plugin Verifier IDEs
193159 - name : Setup Plugin Verifier IDEs Cache
194160 uses : actions/cache@v4
195161 with :
196- path : ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
197- key : ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}
162+ path : ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
163+ key : plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
164+
165+ # Run Verify Plugin task and IntelliJ Plugin Verifier tool
166+ - name : Run Plugin Verification tasks
167+ run : ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}
198168
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 }}
169+ # Collect Plugin Verifier Result
170+ - name : Collect Plugin Verifier Result
171+ if : ${{ always() }}
172+ uses : actions/upload-artifact@v4
173+ with :
174+ name : pluginVerifier-result
175+ path : ${{ github.workspace }}/build/reports/pluginVerifier
202176
203177 # Prepare a draft release for GitHub Releases page for the manual verification
204178 # If accepted and published, release workflow would be triggered
205179 releaseDraft :
206180 name : Release Draft
207181 if : github.event_name != 'pull_request'
208- needs : [build, verify]
182+ needs : [build, test, verify]
209183 runs-on : ubuntu-latest
184+ permissions :
185+ contents : write
210186 steps :
211187
212188 # Check out current repository
213189 - name : Fetch Sources
214190 uses : actions/checkout@v4
215191
216- # Remove old release drafts by using the curl request for the available releases with draft flag
192+ # Remove old release drafts by using the curl request for the available releases with a draft flag
217193 - name : Remove Old Release Drafts
218194 env :
219195 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
220196 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/{}
197+ gh api repos/{owner}/{repo}/releases \
198+ --jq '.[] | select(.draft == true) | .id' \
199+ | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
226200
227- # Create new release draft - which is not publicly visible and requires manual acceptance
201+ # Create a new release draft which is not publicly visible and requires manual acceptance
228202 - name : Create Release Draft
229- id : createDraft
230- uses : actions/create-release@v1.1.4
231- env :
232- 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@v4
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- uses : actions/upload-release-asset@v1.0.2
249203 env :
250204 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
205+ run : |
206+ gh release create "v${{ needs.build.outputs.version }}" \
207+ --draft \
208+ --title "v${{ needs.build.outputs.version }}" \
209+ --notes "$(cat << 'EOM'
210+ ${{ needs.build.outputs.changelog }}
211+ EOM
212+ )"
0 commit comments