forked from smallcloudai/refact
-
-
Notifications
You must be signed in to change notification settings - Fork 7
414 lines (372 loc) · 14.9 KB
/
Copy pathplugin_release.yml
File metadata and controls
414 lines (372 loc) · 14.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
name: Plugin Release
on:
workflow_dispatch:
inputs:
stable_release:
description: "Publish stable release version"
default: false
type: boolean
push:
tags:
- "release/v*"
concurrency:
group: plugin-release-${{ github.ref_name }}
cancel-in-progress: false
permissions:
contents: write
defaults:
run:
shell: bash
jobs:
engine:
uses: ./.github/workflows/agent_engine_build.yml
gui:
uses: ./.github/workflows/agent_gui_build.yml
engine-release:
name: Engine release
if: startsWith(github.ref, 'refs/tags/release/v')
needs: [engine]
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download engine artifacts
uses: actions/download-artifact@v4
with:
pattern: dist-*
path: engine-dist
- name: Package engine release assets
id: engine-assets
run: |
version="${GITHUB_REF_NAME#release/v}"
bash tools/dev/package_engine_release_assets.sh \
--version "$version" \
--input-dir engine-dist \
--output-dir engine-release-assets
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Resolve release notes
id: release_notes
run: |
notes_path="docs/release-notes/v${{ steps.engine-assets.outputs.version }}.md"
if [[ -f "$notes_path" ]]; then
echo "found=true" >> "$GITHUB_OUTPUT"
echo "body_path=$notes_path" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
echo "Release notes file $notes_path not found; using generated notes."
fi
- name: Publish engine release
if: ${{ steps.release_notes.outputs.found == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: engine/v${{ steps.engine-assets.outputs.version }}
name: Engine v${{ steps.engine-assets.outputs.version }}
body_path: ${{ steps.release_notes.outputs.body_path }}
prerelease: false
make_latest: true
overwrite_files: true
fail_on_unmatched_files: true
files: |
engine-release-assets/*
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Publish engine release with generated notes
if: ${{ steps.release_notes.outputs.found != 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: engine/v${{ steps.engine-assets.outputs.version }}
name: Engine v${{ steps.engine-assets.outputs.version }}
generate_release_notes: true
prerelease: false
make_latest: true
overwrite_files: true
fail_on_unmatched_files: true
files: |
engine-release-assets/*
env:
GITHUB_TOKEN: ${{ github.token }}
intellij:
name: JetBrains plugin
# Wait for the engine release to publish FIRST so a freshly-installed plugin can always
# download its pinned engine/v{version} (otherwise early installers hit
# "engine release unavailable"). engine-release is skipped on non-release dispatch (EAP),
# in which case we still run.
needs: [gui, engine-release]
if: ${{ always() && needs.gui.result == 'success' && (needs.engine-release.result == 'success' || needs.engine-release.result == 'skipped') }}
runs-on: ubuntu-latest
outputs:
version: ${{ steps.setupvars.outputs.plugin_version }}
steps:
- name: Maximize build space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
- name: Set release channel and check tag version
id: setupvars
working-directory: plugins/intellij
run: |
if [[ "${{ github.event_name }}" == "push" || "${{ inputs.stable_release }}" == "true" ]]; then
echo "PUBLISH_CHANNEL=default" >> "$GITHUB_ENV"
echo "PUBLISH_EAP=0" >> "$GITHUB_ENV"
else
echo "PUBLISH_CHANNEL=eap" >> "$GITHUB_ENV"
echo "PUBLISH_EAP=1" >> "$GITHUB_ENV"
fi
PLUGIN_VERSION="$(./gradlew properties -q | awk '/^version:/ {print $2}')"
if [[ "${{ github.ref }}" == refs/tags/release/v* ]]; then
TAG_VERSION="${GITHUB_REF_NAME#release/v}"
if [[ "$TAG_VERSION" != "$PLUGIN_VERSION" ]]; then
echo "release tag version $TAG_VERSION does not match JetBrains plugin version $PLUGIN_VERSION"
exit 1
fi
fi
echo "plugin_version=${PLUGIN_VERSION}" >> "$GITHUB_OUTPUT"
- name: Download GUI package
uses: actions/download-artifact@v4
with:
pattern: lts-refact-chat-js-*.tgz
path: plugins/intellij/chat_package
merge-multiple: true
- name: Prepare GUI package
working-directory: plugins/intellij
run: |
mkdir -p ./chat_package_fixed
find ./chat_package -name "*.tgz" -type f -exec tar -xzf {} -C ./chat_package_fixed/ \;
rm -rf ./src/main/resources/webview/dist
mv ./chat_package_fixed/package/dist ./src/main/resources/webview/dist
rm -rf ./chat_package ./chat_package_fixed
- name: Export properties
id: properties
working-directory: plugins/intellij
run: |
echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
./gradlew properties --console=plain -q
./gradlew printProductsReleases
- name: Run tests
working-directory: plugins/intellij
run: ./gradlew check
- name: Collect test results
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: intellij-tests-result
path: plugins/intellij/build/reports/tests
- name: Setup Plugin Verifier IDEs cache
uses: actions/cache@v4
with:
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
key: plugin-verifier-${{ hashFiles('plugins/intellij/build/listProductsReleases.txt') }}
- name: Run plugin verification tasks
working-directory: plugins/intellij
run: |
for attempt in 1 2; do
if ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}; then
exit 0
fi
if [[ "$attempt" == "2" ]]; then
exit 1
fi
echo "Plugin verifier failed, retrying once after cleaning verifier reports"
rm -rf build/reports/pluginVerifier
sleep 10
done
- name: Collect plugin verifier result
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: intellij-pluginVerifier-result
path: plugins/intellij/build/reports/pluginVerifier
- name: Prepare plugin artifact
id: artifact
working-directory: plugins/intellij
run: |
cd build/distributions
FILENAME=$(ls *.zip)
unzip "$FILENAME" -d content
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
- name: Upload JetBrains plugin artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.filename }}
path: plugins/intellij/build/distributions/content/*/*
- name: Publish JetBrains plugin
working-directory: plugins/intellij
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
PUBLISH_CHANNEL: ${{ env.PUBLISH_CHANNEL }}
PUBLISH_EAP: ${{ env.PUBLISH_EAP }}
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
run: |
set +e
./gradlew publishPlugin 2>&1 | tee publishPlugin.log
status=${PIPESTATUS[0]}
set -e
if [[ "$status" -eq 0 ]]; then
exit 0
fi
if grep -q "plugin already contains version" publishPlugin.log; then
echo "JetBrains Marketplace already contains version ${{ steps.setupvars.outputs.plugin_version }}; treating publish as successful for an idempotent release rerun."
exit 0
fi
exit "$status"
- name: Resolve release notes
if: startsWith(github.ref, 'refs/tags/release/v')
id: release_notes
run: |
version="${{ steps.setupvars.outputs.plugin_version }}"
notes_path="docs/release-notes/v${version}.md"
echo "version=$version" >> "$GITHUB_OUTPUT"
if [[ -f "$notes_path" ]]; then
echo "found=true" >> "$GITHUB_OUTPUT"
echo "body_path=$notes_path" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
echo "Release notes file $notes_path not found; using generated notes."
fi
- name: Upload JetBrains plugin to release
if: startsWith(github.ref, 'refs/tags/release/v') && steps.release_notes.outputs.found == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: v${{ steps.release_notes.outputs.version }}
body_path: ${{ steps.release_notes.outputs.body_path }}
overwrite_files: true
fail_on_unmatched_files: true
files: plugins/intellij/build/distributions/*.zip
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload JetBrains plugin to release with generated notes
if: startsWith(github.ref, 'refs/tags/release/v') && steps.release_notes.outputs.found != 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: v${{ steps.release_notes.outputs.version }}
generate_release_notes: true
overwrite_files: true
fail_on_unmatched_files: true
files: plugins/intellij/build/distributions/*.zip
env:
GITHUB_TOKEN: ${{ github.token }}
vscode:
name: VS Code plugin
# Wait for the engine release to publish FIRST so a freshly-installed plugin can always
# download its pinned engine/v{version} (otherwise early installers hit
# "engine release unavailable"). engine-release is skipped on non-release dispatch (EAP),
# in which case we still run.
needs: [gui, engine-release]
if: ${{ always() && needs.gui.result == 'success' && (needs.engine-release.result == 'success' || needs.engine-release.result == 'skipped') }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: plugins/vscode
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Download GUI package
uses: actions/download-artifact@v4
with:
pattern: lts-refact-chat-js-*.tgz
path: plugins/vscode/chat_package
merge-multiple: true
- name: Prepare GUI package
run: |
mkdir -p ./chat_package_fixed
find ./chat_package -name "*.tgz" -type f -exec cp {} ./chat_package_fixed/ \;
ls -la ./chat_package_fixed
- name: Install dependencies and VSCE
run: |
npm ci --ignore-scripts
npm install ./chat_package_fixed/*.tgz --no-save --ignore-scripts
REFACT_CHAT_JS_VERSION=$(node -p "require('./node_modules/refact-chat-js/package.json').version")
npm pkg set "dependencies.refact-chat-js=${REFACT_CHAT_JS_VERSION}"
npm install -g @vscode/vsce
rm -rf ./chat_package ./chat_package_fixed
- name: Check release tag version
if: startsWith(github.ref, 'refs/tags/release/v')
run: |
TAG_VERSION="${GITHUB_REF_NAME#release/v}"
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
if [[ "$TAG_VERSION" != "$PACKAGE_VERSION" ]]; then
echo "release tag version $TAG_VERSION does not match VS Code package version $PACKAGE_VERSION"
exit 1
fi
- name: Package VS Code extension
run: |
if [[ "${{ github.event_name }}" != "push" && "${{ inputs.stable_release }}" != "true" ]]; then
export PRERELEASE=--pre-release
fi
echo "PRERELEASE=${PRERELEASE}"
vsce package ${PRERELEASE}
- name: Publish VS Code extension
run: |
if [[ "${{ github.event_name }}" != "push" && "${{ inputs.stable_release }}" != "true" ]]; then
export PRERELEASE=--pre-release
fi
echo "PRERELEASE=${PRERELEASE}"
vsce publish --skip-duplicate --pat ${{ secrets.VSCE_PAT }} ${PRERELEASE} --packagePath *.vsix
- name: Upload VS Code package
uses: actions/upload-artifact@v4
with:
name: vscode-plugin
path: plugins/vscode/*.vsix
- name: Resolve release notes
if: startsWith(github.ref, 'refs/tags/release/v')
id: release_notes
run: |
version="${GITHUB_REF_NAME#release/v}"
notes_path="docs/release-notes/v${version}.md"
echo "version=$version" >> "$GITHUB_OUTPUT"
if [[ -f "$GITHUB_WORKSPACE/$notes_path" ]]; then
echo "found=true" >> "$GITHUB_OUTPUT"
echo "body_path=$notes_path" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
echo "Release notes file $notes_path not found; using generated notes."
fi
- name: Upload VS Code package to release
if: startsWith(github.ref, 'refs/tags/release/v') && steps.release_notes.outputs.found == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: v${{ steps.release_notes.outputs.version }}
body_path: ${{ steps.release_notes.outputs.body_path }}
overwrite_files: true
fail_on_unmatched_files: true
files: plugins/vscode/*.vsix
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload VS Code package to release with generated notes
if: startsWith(github.ref, 'refs/tags/release/v') && steps.release_notes.outputs.found != 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: v${{ steps.release_notes.outputs.version }}
generate_release_notes: true
overwrite_files: true
fail_on_unmatched_files: true
files: plugins/vscode/*.vsix
env:
GITHUB_TOKEN: ${{ github.token }}