11name : Build
22on :
3+ # Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests)
34 push :
4- tags :
5- - ' v*'
5+ branches : [ main ]
6+ # Trigger the workflow on any pull request
7+ pull_request :
68
79concurrency :
8- group : " ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
10+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
911 cancel-in-progress : true
1012
1113jobs :
14+
15+ # Prepare the environment and build the plugin
1216 build :
1317 name : Build
1418 runs-on : ubuntu-latest
15- outputs :
16- version : ${{ steps.properties.outputs.version }}
17- changelog : ${{ steps.properties.outputs.changelog }}
1819 steps :
20+
1921 # Free GitHub Actions Environment Disk Space
2022 - name : Maximize Build Space
21232224 with :
2325 tool-cache : false
2426 large-packages : false
2527
26- # Check out current repository
28+ # Check out the current repository
2729 - name : Fetch Sources
2830 uses : actions/checkout@v4
29- with :
30- submodules : ' true'
31- token : ${{ secrets.FETCH_SUBMODULES_PAT }}
3231
33- - name : Remove .updates file
34- run : |
35- rm -f src/main/resources/bitrix-idea-library/.updates
36-
37- # Validate wrapper
38- - name : Gradle Wrapper Validation
39- uses : gradle/actions/wrapper-validation@v3
40-
41- # Setup Java environment for the next steps
32+ # Set up the Java environment for the next steps
4233 - name : Setup Java
4334 uses : actions/setup-java@v4
4435 with :
4536 distribution : zulu
4637 java-version : 21
4738
48- # Setup Java environment for the next steps
39+ # Setup Gradle
4940 - name : Setup Gradle
5041 uses : gradle/actions/setup-gradle@v4
5142
52- # Set environment variables
53- - name : Export Properties
54- id : properties
55- shell : bash
56- run : |
57- PROPERTIES="$(./gradlew properties --console=plain -q)"
58- VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
59- CHANGELOG="$(./gradlew getChangelog --console=plain -q)"
60-
61- echo "version=$VERSION" >> $GITHUB_OUTPUT
62-
63- echo "changelog<<EOF" >> $GITHUB_OUTPUT
64- echo "$CHANGELOG" >> $GITHUB_OUTPUT
65- echo "EOF" >> $GITHUB_OUTPUT
66-
6743 # Build plugin
6844 - name : Build plugin
6945 run : ./gradlew buildPlugin
@@ -79,31 +55,32 @@ jobs:
7955
8056 echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
8157
82- # Store already-built plugin as an artifact for downloading
58+ # Store an already-built plugin as an artifact for downloading
8359 - name : Upload artifact
8460 uses : actions/upload-artifact@v4
8561 with :
8662 name : ${{ steps.artifact.outputs.filename }}
8763 path : ./build/distributions/content/*/*
88-
64+
8965 # Run tests and upload a code coverage report
9066 test :
9167 name : Test
92- needs : build
68+ needs : [ build ]
9369 runs-on : ubuntu-latest
9470 steps :
71+
9572 # Free GitHub Actions Environment Disk Space
9673 - name : Maximize Build Space
97749875 with :
9976 tool-cache : false
10077 large-packages : false
10178
102- # Check out current repository
79+ # Check out the current repository
10380 - name : Fetch Sources
10481 uses : actions/checkout@v4
105-
106- # Setup Java environment for the next steps
82+
83+ # Set up the Java environment for the next steps
10784 - name : Setup Java
10885 uses : actions/setup-java@v4
10986 with :
@@ -128,30 +105,70 @@ jobs:
128105 name : tests-result
129106 path : ${{ github.workspace }}/build/reports/tests
130107
131- # Upload Kover report to CodeCov
108+ # Upload the Kover report to CodeCov
132109 - name : Upload Code Coverage Report
133- uses : codecov/codecov-action@v3
110+ uses : codecov/codecov-action@v5
134111 with :
135112 files : ${{ github.workspace }}/build/reports/kover/report.xml
136-
113+ token : ${{ secrets.CODECOV_TOKEN }}
114+
115+ # Run Qodana inspections and provide a report
116+ inspectCode :
117+ name : Inspect code
118+ needs : [ build ]
119+ runs-on : ubuntu-latest
120+ permissions :
121+ contents : write
122+ checks : write
123+ pull-requests : write
124+ steps :
125+
126+ # Free GitHub Actions Environment Disk Space
127+ - name : Maximize Build Space
128+ 129+ with :
130+ tool-cache : false
131+ large-packages : false
132+
133+ # Check out the current repository
134+ - name : Fetch Sources
135+ uses : actions/checkout@v4
136+ with :
137+ ref : ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
138+ fetch-depth : 0 # a full history is required for pull request analysis
139+
140+ # Set up the Java environment for the next steps
141+ - name : Setup Java
142+ uses : actions/setup-java@v4
143+ with :
144+ distribution : zulu
145+ java-version : 21
146+
147+ # Run Qodana inspections
148+ - name : Qodana - Code Inspection
149+ 150+ with :
151+ cache-default-branch-only : true
152+
137153 # Run plugin structure verification along with IntelliJ Plugin Verifier
138154 verify :
139155 name : Verify plugin
140- needs : build
156+ needs : [ build ]
141157 runs-on : ubuntu-latest
142158 steps :
159+
143160 # Free GitHub Actions Environment Disk Space
144161 - name : Maximize Build Space
145162146163 with :
147164 tool-cache : false
148165 large-packages : false
149166
150- # Check out current repository
167+ # Check out the current repository
151168 - name : Fetch Sources
152169 uses : actions/checkout@v4
153-
154- # Setup Java environment for the next steps
170+
171+ # Set up the Java environment for the next steps
155172 - name : Setup Java
156173 uses : actions/setup-java@v4
157174 with :
@@ -161,10 +178,6 @@ jobs:
161178 # Setup Gradle
162179 - name : Setup Gradle
163180 uses : gradle/actions/setup-gradle@v4
164-
165- # Cache Plugin Verifier IDEs
166- - name : Setup Plugin Verifier IDEs Cache
167- uses : actions/cache@v4
168181 with :
169182 cache-read-only : true
170183
@@ -181,15 +194,21 @@ jobs:
181194 path : ${{ github.workspace }}/build/reports/pluginVerifier
182195
183196 # Prepare a draft release for GitHub Releases page for the manual verification
184- # If accepted and published, release workflow would be triggered
197+ # If accepted and published, the release workflow would be triggered
185198 releaseDraft :
186- name : Release Draft
187- needs : build
199+ name : Release draft
200+ if : github.event_name != 'pull_request'
201+ needs : [ build, test, inspectCode, verify ]
188202 runs-on : ubuntu-latest
189203 permissions :
190204 contents : write
191205 steps :
192- # Remove old release drafts by using the curl request for the available releases with draft flag
206+
207+ # Check out the current repository
208+ - name : Fetch Sources
209+ uses : actions/checkout@v4
210+
211+ # Remove old release drafts by using the curl request for the available releases with a draft flag
193212 - name : Remove Old Release Drafts
194213 env :
195214 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -198,17 +217,16 @@ jobs:
198217 --jq '.[] | select(.draft == true) | .id' \
199218 | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
200219
201- # Create new release draft - which is not publicly visible and requires manual acceptance
220+ # Create a new release draft which is not publicly visible and requires manual acceptance
202221 - name : Create Release Draft
203222 env :
204223 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
205224 run : |
206- gh release create "${{ needs.build.outputs.version }}"" \
225+ VERSION=$(./gradlew properties --property version --quiet --console=plain | tail -n 1 | cut -f2- -d ' ')
226+ RELEASE_NOTE="./build/tmp/release_note.txt"
227+ ./gradlew getChangelog --unreleased --no-header --quiet --console=plain --output-file=$RELEASE_NOTE
228+
229+ gh release create $VERSION \
207230 --draft \
208- --title "${{ needs.build.outputs.version }}""
209-
210- # Upload artifact as a release asset
211- - name : Upload Release Asset
212- env :
213- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
214- run : gh release upload ${{ needs.build.outputs.version }}" ./build/distributions/*
231+ --title $VERSION \
232+ --notes-file $RELEASE_NOTE
0 commit comments