1+ name : Build
2+ on :
3+ push :
4+ branches : [ main ]
5+ pull_request :
6+
7+ concurrency :
8+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
9+ cancel-in-progress : true
10+
11+ defaults :
12+ run :
13+ working-directory : intellij-aicoder
14+
15+ jobs :
16+ build :
17+ name : Build
18+ runs-on : ubuntu-latest
19+ outputs :
20+ version : ${{ steps.properties.outputs.version }}
21+ changelog : ${{ steps.properties.outputs.changelog }}
22+ pluginVerifierHomeDir : ${{ steps.properties.outputs.pluginVerifierHomeDir }}
23+ steps :
24+ - name : Fetch Sources
25+ uses : actions/checkout@v4
26+
27+ - name : Gradle Wrapper Validation
28+ uses : gradle/actions/wrapper-validation@v3
29+ with :
30+ working-directory : intellij-aicoder
31+
32+ - name : Setup Java
33+ uses : actions/setup-java@v4
34+ with :
35+ distribution : zulu
36+ java-version : 17
37+
38+ - name : Setup Gradle
39+ uses : gradle/actions/setup-gradle@v4
40+ with :
41+ gradle-home-cache-cleanup : true
42+
43+ - name : Export Properties
44+ id : properties
45+ shell : bash
46+ run : |
47+ PROPERTIES="$(./gradlew properties --console=plain -q)"
48+ VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
49+ CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
50+
51+ echo "version=$VERSION" >> $GITHUB_OUTPUT
52+ echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
53+
54+ echo "changelog<<EOF" >> $GITHUB_OUTPUT
55+ echo "$CHANGELOG" >> $GITHUB_OUTPUT
56+ echo "EOF" >> $GITHUB_OUTPUT
57+
58+ - name : Build plugin
59+ run : ./gradlew buildPlugin
60+
61+ - name : Prepare Plugin Artifact
62+ id : artifact
63+ shell : bash
64+ run : |
65+ cd ${{ github.workspace }}/intellij-aicoder/build/distributions
66+ FILENAME=`ls *.zip`
67+ echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
68+
69+ - name : Upload artifact
70+ uses : actions/upload-artifact@v4
71+ with :
72+ name : ${{ steps.artifact.outputs.filename }}
73+ path : intellij-aicoder/build/distributions/*
74+
75+ test :
76+ name : Test
77+ needs : [ build ]
78+ runs-on : ubuntu-latest
79+ steps :
80+ - name : Fetch Sources
81+ uses : actions/checkout@v4
82+
83+ - name : Setup Java
84+ uses : actions/setup-java@v4
85+ with :
86+ distribution : zulu
87+ java-version : 17
88+
89+ - name : Setup Gradle
90+ uses : gradle/actions/setup-gradle@v4
91+
92+ - name : Run Tests
93+ run : ./gradlew check
94+
95+ - name : Collect Tests Result
96+ if : ${{ failure() }}
97+ uses : actions/upload-artifact@v4
98+ with :
99+ name : tests-result
100+ path : intellij-aicoder/build/reports/tests
101+
102+ - name : Upload Code Coverage Report
103+ uses : codecov/codecov-action@v4
104+ with :
105+ files : intellij-aicoder/build/reports/kover/report.xml
106+
107+ verify :
108+ name : Verify plugin
109+ needs : [ build ]
110+ runs-on : ubuntu-latest
111+ steps :
112+ - name : Maximize Build Space
113+ uses : jlumbroso/free-disk-space@main
114+ with :
115+ tool-cache : false
116+ large-packages : false
117+
118+ - name : Fetch Sources
119+ uses : actions/checkout@v4
120+
121+ - name : Setup Java
122+ uses : actions/setup-java@v4
123+ with :
124+ distribution : zulu
125+ java-version : 17
126+
127+ - name : Setup Gradle
128+ uses : gradle/actions/setup-gradle@v4
129+
130+ - name : Setup Plugin Verifier IDEs Cache
131+ uses : actions/cache@v4
132+ with :
133+ path : ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
134+ key : plugin-verifier-${{ hashFiles('intellij-aicoder/build/listProductsReleases.txt') }}
135+
136+ - name : Run Plugin Verification tasks
137+ run : ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}
138+
139+ - name : Collect Plugin Verifier Result
140+ if : ${{ always() }}
141+ uses : actions/upload-artifact@v4
142+ with :
143+ name : pluginVerifier-result
144+ path : intellij-aicoder/build/reports/pluginVerifier
145+
146+ releaseDraft :
147+ name : Release draft
148+ if : github.event_name != 'pull_request'
149+ needs : [ build, test, verify ]
150+ runs-on : ubuntu-latest
151+ permissions :
152+ contents : write
153+ steps :
154+ - name : Fetch Sources
155+ uses : actions/checkout@v4
156+
157+ - name : Remove Old Release Drafts
158+ env :
159+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
160+ run : |
161+ gh api repos/{owner}/{repo}/releases \
162+ --jq '.[] | select(.draft == true) | .id' \
163+ | xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
164+
165+ - name : Create Release Draft
166+ id : create_release
167+ env :
168+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
169+ run : |
170+ gh release create "v${{ needs.build.outputs.version }}" \
171+ --draft \
172+ --title "v${{ needs.build.outputs.version }}" \
173+ --notes "${{ needs.build.outputs.changelog }}"
174+ RELEASE_URL=$(gh release view "v${{ needs.build.outputs.version }}" --json url -q .url)
175+ echo "release_url=$RELEASE_URL" >> $GITHUB_OUTPUT
176+
177+ - name : Download Artifact
178+ uses : actions/download-artifact@v4
179+ with :
180+ name : ${{ steps.artifact.outputs.filename }}
181+ path : ./artifact
182+
183+ - name : Upload Release Asset
184+ uses : actions/upload-release-asset@v1
185+ env :
186+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
187+ with :
188+ upload_url : ${{ steps.create_release.outputs.release_url }}
189+ asset_path : ./artifact/intellij-aicoder-${{ needs.build.outputs.version }}/intellij-aicoder-${{ needs.build.outputs.version }}.zip
190+ asset_name : intellij-aicoder-${{ needs.build.outputs.version }}.zip
191+ asset_content_type : application/zip
0 commit comments