Elffuss BraidHub

kikocis/continue public

972ea8cfaef0 · 19.1 KiBRawPermalink
1# GitHub Actions Workflow created for handling the release process based on the draft release prepared with the Build workflow.
2# Running the publishPlugin task requires all following secrets to be provided: PUBLISH_TOKEN, PRIVATE_KEY, PRIVATE_KEY_PASSWORD, CERTIFICATE_CHAIN.
3# See https://plugins.jetbrains.com/docs/intellij/plugin-signing.html for more information.
4
5name: JetBrains Release
6
7on:
8 release:
9 types: [prereleased]
10 workflow_dispatch:
11 inputs:
12 publish_build:
13 description: "Whether or not to publish the built extension to the JetBrains marketplace"
14 required: true
15 default: false
16
17defaults:
18 run:
19 working-directory: extensions/intellij
20
21concurrency:
22 group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
23 cancel-in-progress: true
24
25jobs:
26 check_release_name:
27 runs-on: ubuntu-latest
28 outputs:
29 should_run: ${{ steps.check.outputs.should_run }}
30 steps:
31 - id: check
32 working-directory: .
33 run: |
34 if [[ "${{ github.event.release.tag_name }}" == v1.0.*-jetbrains ]]; then
35 echo "should_run=true" >> $GITHUB_OUTPUT
36 else
37 echo "should_run=false" >> $GITHUB_OUTPUT
38 fi
39
40 bump-version:
41 runs-on: ubuntu-latest
42 needs:
43 - check_release_name
44 if: github.event_name != 'workflow_dispatch' || github.event.inputs.publish_build == 'true'
45 permissions:
46 contents: write
47 pull-requests: write
48 steps:
49 # 0. Setup git
50 - name: Checkout
51 uses: actions/checkout@v4
52
53 - name: Set up Git
54 run: |
55 git config --local user.email "action@github.com"
56 git config --local user.name "GitHub Action"
57
58 - name: Create PR branch
59 run: |
60 BRANCH_NAME="chore/bump-jetbrains-version-$(date +%Y%m%d-%H%M%S)"
61 git checkout -b $BRANCH_NAME
62 echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
63
64 - name: Bump version in gradle.properties
65 run: |
66 cd extensions/intellij
67 awk '/pluginVersion=/{split($0,a,"="); split(a[2],b,"."); b[3]+=1; printf "%s=%s.%s.%s\n",a[1],b[1],b[2],b[3];next}1' gradle.properties > tmp && mv tmp gradle.properties
68 rm -rf tmp
69 NEW_VERSION=$(grep 'pluginVersion=' gradle.properties | cut -d'=' -f2)
70 echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
71
72 - name: Create Pull Request
73 uses: peter-evans/create-pull-request@v7
74 with:
75 token: ${{ secrets.CI_GITHUB_TOKEN }}
76 commit-message: "chore: bump jetbrains extension version to ${{ env.NEW_VERSION }}"
77 title: "chore: bump jetbrains extension version to ${{ env.NEW_VERSION }}"
78 body: |
79 Automated PR to bump the JetBrains extension version after successful pre-release publication.
80
81 - Bumped version in extensions/intellij/gradle.properties to ${{ env.NEW_VERSION }}
82 branch: ${{ env.BRANCH_NAME }}
83 base: main
84 delete-branch: true
85
86 # Prepare and publish the plugin to JetBrains Marketplace repository
87 build:
88 needs: check_release_name
89 if: needs.check_release_name.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
90 name: Build Plugin
91 runs-on: macos-latest
92 permissions:
93 contents: write
94 pull-requests: write
95 steps:
96 # Check out current repository
97 - name: Fetch Sources
98 uses: actions/checkout@v4
99 with:
100 ref: ${{ github.event.release.tag_name }}
101
102 - name: Import Apple certificate
103 uses: apple-actions/import-codesign-certs@v5
104 with:
105 keychain: ${{ github.run_id }}
106 keychain-password: ${{ github.run_id }}
107 p12-file-base64: ${{ secrets.APPLE_CERT_DATA }}
108 p12-password: ${{ secrets.APPLE_CERT_PASSWORD }}
109
110 # Validate wrapper
111 - name: Gradle Wrapper Validation
112 uses: gradle/actions/wrapper-validation@v3
113
114 # # Set up Java environment for the next steps
115 - name: Setup Java
116 uses: actions/setup-java@v4
117 with:
118 distribution: zulu
119 java-version: 17
120
121 # # Setup Gradle
122 - name: Setup Gradle
123 uses: gradle/actions/setup-gradle@v3
124 with:
125 gradle-home-cache-cleanup: true
126
127 # Set environment variables
128 - name: Export Properties
129 id: properties
130 shell: bash
131 run: |
132 PROPERTIES="$(./gradlew properties --console=plain -q)"
133 VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
134 # CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
135 CHANGELOG=""
136
137 echo "version=$VERSION" >> $GITHUB_OUTPUT
138 echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
139
140 echo "changelog<<EOF" >> $GITHUB_OUTPUT
141 echo "$CHANGELOG" >> $GITHUB_OUTPUT
142 echo "EOF" >> $GITHUB_OUTPUT
143
144 ./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
145
146 # # Setup Node.js
147 - name: Use Node.js from .nvmrc
148 uses: actions/setup-node@v4
149 with:
150 node-version-file: ".nvmrc"
151
152 - name: Cache core node_modules
153 uses: actions/cache@v3
154 with:
155 path: core/node_modules
156 key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
157
158 - name: Cache binary node_modules
159 uses: actions/cache@v3
160 with:
161 path: binary/node_modules
162 key: ${{ runner.os }}-node-${{ hashFiles('binary/package-lock.json') }}
163
164 - name: Cache gui node_modules
165 uses: actions/cache@v3
166 with:
167 path: gui/node_modules
168 key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
169
170 - uses: actions/cache@v4
171 id: config-yaml-cache
172 with:
173 path: packages/config-yaml/node_modules
174 key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
175
176 - name: Build and check config-yaml
177 run: |
178 cd ../../packages/config-yaml
179 npm i
180 npx tsc --noEmit
181 # Tests are currently failing, commenting out for now
182 # npm test
183 npm run build
184
185 # npm install core
186 - name: Install core node_modules
187 run: |
188 cd ../../core
189 npm ci
190
191 # npm install gui
192 - name: Install gui node_modules and build
193 run: |
194 cd ../../gui
195 npm ci
196 npm run build
197
198 # Run prepackage.js script
199 - name: Run prepackage script
200 run: |
201 cd ../../extensions/vscode
202 npm ci
203 npm run prepackage
204 env:
205 # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
206 GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
207
208 # npm install binary
209 - name: Install binary node_modules
210 run: |
211 cd ../../binary
212 npm ci
213
214 # Build binaries
215 - name: Build the binaries
216 run: |
217 cd ../../binary
218 npm run build
219
220 # - name: Code sign darwin binaries
221 # run: |
222 # echo "Signing executable with keychain: ${{ github.run_id }}"
223 # codesign --sign - ../../binary/bin/darwin-x64/continue-binary
224 # codesign --sign - ../../binary/bin/darwin-arm64/continue-binary
225
226 # - name: Sign darwin-arm64 binary
227 # uses: lando/code-sign-action@v2
228 # with:
229 # file: ./binary/bin/darwin-arm64/continue-binary
230 # certificate-data: ${{ secrets.APPLE_CERT_DATA }}
231 # certificate-password: ${{ secrets.APPLE_CERT_PASSWORD }}
232 # apple-notary-user: ${{ secrets.APPLE_NOTARY_USER }}
233 # apple-notary-password: ${{ secrets.APPLE_NOTARY_PASSWORD }}
234 # apple-notary-tool: altool
235 # apple-team-id: 43XFLY66ZD
236 # apple-product-id: dev.continue.continue-binary
237 # options: --options runtime --entitlements entitlements.xml
238
239 # Build plugin
240 - name: Build plugin
241 run: ./gradlew buildPlugin
242
243 # Publish the plugin to JetBrains Marketplace
244 - name: Publish EAP Plugin
245 if: github.event_name == 'release' || github.event.inputs.publish_build == 'true'
246 env:
247 PUBLISH_TOKEN: ${{ secrets.JETBRAINS_PUBLISH_TOKEN }}
248 CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_CERTIFICATE_CHAIN }}
249 PRIVATE_KEY: ${{ secrets.JETBRAINS_PRIVATE_KEY }}
250 PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_PRIVATE_KEY_PASSWORD }}
251 RELEASE_CHANNEL: eap
252 run: ./gradlew publishPlugin
253
254 - name: Publish Stable Plugin
255 if: github.event_name == 'release' || github.event.inputs.publish_build == 'true'
256 env:
257 PUBLISH_TOKEN: ${{ secrets.JETBRAINS_PUBLISH_TOKEN }}
258 CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_CERTIFICATE_CHAIN }}
259 PRIVATE_KEY: ${{ secrets.JETBRAINS_PRIVATE_KEY }}
260 PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_PRIVATE_KEY_PASSWORD }}
261 RELEASE_CHANNEL: default
262 run: ./gradlew publishPlugin
263
264 # Prepare plugin archive content for creating artifact
265 - name: Prepare Plugin Artifact
266 id: artifact
267 shell: bash
268 run: |
269 cd ../../extensions/intellij/build/distributions
270 echo "Contents of distributions folder:"
271 ls
272 echo "---"
273 FILENAME=`ls continue-intellij-extension-*.zip`
274 echo "Filename=${FILENAME}"
275 unzip "$FILENAME" -d content
276
277 echo "filename=${FILENAME%.????}" >> $GITHUB_OUTPUT
278
279 # Store already-built plugin as an artifact for downloading
280 - name: Upload artifact
281 uses: actions/upload-artifact@v4
282 with:
283 name: ${{ steps.artifact.outputs.filename }}
284 path: ./extensions/intellij/build/distributions/content/*/*
285
286 # Upload binaries as artifacts
287 - name: Upload artifact (darwin-arm64)
288 uses: actions/upload-artifact@v4
289 with:
290 name: continue-binary-darwin-arm64
291 path: ./binary/bin/darwin-arm64/
292
293 - name: Upload artifact (darwin-x64)
294 uses: actions/upload-artifact@v4
295 with:
296 name: continue-binary-darwin-x64
297 path: ./binary/bin/darwin-x64/
298
299 - name: Upload artifact (win32-x64)
300 uses: actions/upload-artifact@v4
301 with:
302 name: continue-binary-win32-x64
303 path: ./binary/bin/win32-x64/
304
305 - name: Upload artifact (win32-arm64)
306 uses: actions/upload-artifact@v4
307 with:
308 name: continue-binary-win32-arm64
309 path: ./binary/bin/win32-arm64/
310
311 - name: Upload artifact (linux-arm64)
312 uses: actions/upload-artifact@v4
313 with:
314 name: continue-binary-linux-arm64
315 path: ./binary/bin/linux-arm64/
316
317 - name: Upload artifact (linux-x64)
318 uses: actions/upload-artifact@v4
319 with:
320 name: continue-binary-linux-x64
321 path: ./binary/bin/linux-x64/
322
323 test-binaries:
324 needs: build
325 strategy:
326 matrix:
327 include:
328 - os: windows-latest
329 platform: win32
330 arch: x64
331 npm_config_arch: x64
332 - os: ubuntu-latest
333 platform: linux
334 arch: x64
335 npm_config_arch: x64
336 # arm64 not actually supported by GitHub
337 # - os: ubuntu-latest
338 # platform: linux
339 # arch: arm64
340 # npm_config_arch: arm64
341 - os: macos-12
342 platform: darwin
343 arch: x64
344 npm_config_arch: x64
345 - os: macos-latest
346 platform: darwin
347 arch: arm64
348 npm_config_arch: arm64
349 runs-on: ${{ matrix.os }}
350 steps:
351 # 1. Check-out repository
352 - name: Check-out repository
353 uses: actions/checkout@v4
354
355 # 2. Install npm dependencies
356 - name: Use Node.js from .nvmrc
357 uses: actions/setup-node@v4
358 with:
359 node-version-file: ".nvmrc"
360
361 - name: Cache core node_modules
362 uses: actions/cache@v3
363 with:
364 path: core/node_modules
365 key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
366
367 - name: Cache binary node_modules
368 uses: actions/cache@v3
369 with:
370 path: binary/node_modules
371 key: ${{ runner.os }}-node-${{ hashFiles('binary/package-lock.json') }}
372
373 - name: Install Core Dependencies
374 run: |
375 cd ../../core
376 npm ci
377
378 - name: Install Binary Dependencies
379 run: |
380 cd ../../binary
381 npm ci
382
383 # Download the binary artifact
384 - name: Download binary artifact
385 uses: actions/download-artifact@v4
386 with:
387 name: continue-binary-${{ matrix.platform }}-${{ matrix.arch }}
388 path: ./binary/bin/${{ matrix.platform }}-${{ matrix.arch }}/
389
390 # Set execute permissions for the binary (non-Windows)
391 - name: Set execute permissions
392 run: |
393 cd ../../binary/bin/${{ matrix.platform }}-${{ matrix.arch }}
394 chmod +x continue-binary
395 chmod +x build/Release/node_sqlite3.node
396 chmod +x index.node
397 if: ${{ matrix.platform }} != 'win32'
398
399 # Run tests for binary
400 - name: Run binary tests
401 run: |
402 cd ../../binary
403 npm run test
404
405 - name: Upload logs
406 if: ${{ always() }}
407 uses: actions/upload-artifact@v4
408 with:
409 name: core-logs-${{ matrix.platform }}-${{ matrix.arch }}
410 path: ~/.continue/logs/core.log
411
412 # Run tests and upload a code coverage report
413 test:
414 name: Test
415 needs: [build]
416 runs-on: ubuntu-latest
417 steps:
418 # Check out current repository
419 - name: Fetch Sources
420 uses: actions/checkout@v4
421
422 # Set up Java environment for the next steps
423 - name: Setup Java
424 uses: actions/setup-java@v4
425 with:
426 distribution: zulu
427 java-version: 17
428
429 # Setup Gradle
430 - name: Setup Gradle
431 uses: gradle/actions/setup-gradle@v3
432 with:
433 gradle-home-cache-cleanup: true
434
435 # Run tests
436 - name: Run Tests
437 run: ./gradlew check
438
439 # Collect Tests Result of failed tests
440 - name: Collect Tests Result
441 if: ${{ failure() }}
442 uses: actions/upload-artifact@v4
443 with:
444 name: tests-result
445 path: ${{ github.workspace }}/extensions/intellij/build/reports/tests
446
447 # Upload the Kover report to CodeCov
448 # - name: Upload Code Coverage Report
449 # uses: codecov/codecov-action@v4
450 # with:
451 # files: ${{ github.workspace }}/build/reports/kover/report.xml
452
453 # Run Qodana inspections and provide report
454 inspectCode:
455 if: false
456 name: Inspect code
457 needs: [build]
458 runs-on: ubuntu-latest
459 permissions:
460 contents: write
461 checks: write
462 pull-requests: write
463 steps:
464 # Free GitHub Actions Environment Disk Space
465 - name: Maximize Build Space
466 uses: jlumbroso/free-disk-space@main
467 with:
468 tool-cache: false
469 large-packages: false
470
471 # Check out current repository
472 - name: Fetch Sources
473 uses: actions/checkout@v4
474
475 # Set up Java environment for the next steps
476 - name: Setup Java
477 uses: actions/setup-java@v4
478 with:
479 distribution: zulu
480 java-version: 17
481
482 # Run Qodana inspections
483 - name: Qodana - Code Inspection
484 uses: JetBrains/qodana-action@v2025.1.1
485 with:
486 cache-default-branch-only: true
487
488 # Run plugin structure verification along with IntelliJ Plugin Verifier
489 verify:
490 if: false
491 name: Verify plugin
492 needs: [build]
493 runs-on: ubuntu-latest
494 steps:
495 # Free GitHub Actions Environment Disk Space
496 - name: Maximize Build Space
497 uses: jlumbroso/free-disk-space@main
498 with:
499 tool-cache: false
500 large-packages: false
501
502 # Check out current repository
503 - name: Fetch Sources
504 uses: actions/checkout@v4
505
506 # Set up Java environment for the next steps
507 - name: Setup Java
508 uses: actions/setup-java@v4
509 with:
510 distribution: zulu
511 java-version: 17
512
513 # Setup Gradle
514 - name: Setup Gradle
515 uses: gradle/actions/setup-gradle@v3
516 with:
517 gradle-home-cache-cleanup: true
518
519 # Cache Plugin Verifier IDEs
520 - name: Setup Plugin Verifier IDEs Cache
521 uses: actions/cache@v4
522 with:
523 path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
524 key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
525
526 # Run Verify Plugin task and IntelliJ Plugin Verifier tool
527 - name: Run Plugin Verification tasks
528 run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}
529
530 # Collect Plugin Verifier Result
531 - name: Collect Plugin Verifier Result
532 if: ${{ always() }}
533 uses: actions/upload-artifact@v4
534 with:
535 name: pluginVerifier-result
536 path: ${{ github.workspace }}/build/reports/pluginVerifier
537
538 upload-release:
539 if: false
540 name: Upload Release
541 needs:
542 - build
543 - test-binaries
544 - test
545 runs-on: ubuntu-latest
546 steps:
547 # # Update Unreleased section with the current release note
548 # - name: Patch Changelog
549 # if: ${{ steps.properties.outputs.changelog != '' }}
550 # env:
551 # CHANGELOG: ${{ steps.properties.outputs.changelog }}
552 # run: |
553 # ./gradlew patchChangelog --release-note="$CHANGELOG"
554
555 - name: Download the plugin
556 uses: actions/download-artifact@v4
557 with:
558 name: ${{ steps.artifact.outputs.filename }}
559 path: ./build/distributions/
560
561 # Upload artifact as a release asset
562 # - name: Upload Release Asset
563 # env:
564 # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
565 # run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
566
567 # Publish the plugin to JetBrains Marketplace
568 - name: Publish Plugin
569 env:
570 PUBLISH_TOKEN: ${{ secrets.JETBRAINS_PUBLISH_TOKEN }}
571 CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_CERTIFICATE_CHAIN }}
572 PRIVATE_KEY: ${{ secrets.JETBRAINS_PRIVATE_KEY }}
573 PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_PRIVATE_KEY_PASSWORD }}
574 run: ./gradlew publishPlugin
575
576 # Create a pull request
577 - name: Create Pull Request
578 if: ${{ steps.properties.outputs.changelog != '' }}
579 env:
580 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
581 run: |
582 VERSION="${{ github.event.release.tag_name }}"
583 BRANCH="changelog-update-$VERSION"
584 LABEL="release changelog"
585
586 git config user.email "action@github.com"
587 git config user.name "GitHub Action"
588
589 git checkout -b $BRANCH
590 git commit -am "Changelog update - $VERSION"
591 git push --set-upstream origin $BRANCH
592
593 gh label create "$LABEL" \
594 --description "Pull requests with release changelog update" \
595 --force \
596 || true
597
598 gh pr create \
599 --title "Changelog update - \`$VERSION\`" \
600 --body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
601 --label "$LABEL" \
602 --head $BRANCH