Elffuss BraidHub

kikocis/continue public

22e692d80113 · 18.7 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 - name: Build packages (Unix)
171 run: cd ../.. && ./scripts/build-packages.sh
172
173 # npm install core
174 - name: Install core node_modules
175 run: |
176 cd ../../core
177 npm ci
178
179 # npm install gui
180 - name: Install gui node_modules and build
181 run: |
182 cd ../../gui
183 npm ci
184 npm run build
185
186 # Run prepackage.js script
187 - name: Run prepackage script
188 run: |
189 cd ../../extensions/vscode
190 npm ci
191 npm run prepackage
192 env:
193 # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
194 GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
195
196 # npm install binary
197 - name: Install binary node_modules
198 run: |
199 cd ../../binary
200 npm ci
201
202 # Build binaries
203 - name: Build the binaries
204 run: |
205 cd ../../binary
206 npm run build
207
208 # - name: Code sign darwin binaries
209 # run: |
210 # echo "Signing executable with keychain: ${{ github.run_id }}"
211 # codesign --sign - ../../binary/bin/darwin-x64/continue-binary
212 # codesign --sign - ../../binary/bin/darwin-arm64/continue-binary
213
214 # - name: Sign darwin-arm64 binary
215 # uses: lando/code-sign-action@v2
216 # with:
217 # file: ./binary/bin/darwin-arm64/continue-binary
218 # certificate-data: ${{ secrets.APPLE_CERT_DATA }}
219 # certificate-password: ${{ secrets.APPLE_CERT_PASSWORD }}
220 # apple-notary-user: ${{ secrets.APPLE_NOTARY_USER }}
221 # apple-notary-password: ${{ secrets.APPLE_NOTARY_PASSWORD }}
222 # apple-notary-tool: altool
223 # apple-team-id: 43XFLY66ZD
224 # apple-product-id: dev.continue.continue-binary
225 # options: --options runtime --entitlements entitlements.xml
226
227 # Build plugin
228 - name: Build plugin
229 run: ./gradlew buildPlugin
230
231 # Publish the plugin to JetBrains Marketplace
232 - name: Publish EAP Plugin
233 if: github.event_name == 'release' || github.event.inputs.publish_build == 'true'
234 env:
235 PUBLISH_TOKEN: ${{ secrets.JETBRAINS_PUBLISH_TOKEN }}
236 CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_CERTIFICATE_CHAIN }}
237 PRIVATE_KEY: ${{ secrets.JETBRAINS_PRIVATE_KEY }}
238 PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_PRIVATE_KEY_PASSWORD }}
239 RELEASE_CHANNEL: eap
240 run: ./gradlew publishPlugin
241
242 - name: Publish Stable Plugin
243 if: github.event_name == 'release' || github.event.inputs.publish_build == 'true'
244 env:
245 PUBLISH_TOKEN: ${{ secrets.JETBRAINS_PUBLISH_TOKEN }}
246 CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_CERTIFICATE_CHAIN }}
247 PRIVATE_KEY: ${{ secrets.JETBRAINS_PRIVATE_KEY }}
248 PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_PRIVATE_KEY_PASSWORD }}
249 RELEASE_CHANNEL: default
250 run: ./gradlew publishPlugin
251
252 # Prepare plugin archive content for creating artifact
253 - name: Prepare Plugin Artifact
254 id: artifact
255 shell: bash
256 run: |
257 cd ../../extensions/intellij/build/distributions
258 echo "Contents of distributions folder:"
259 ls
260 echo "---"
261 FILENAME=`ls continue-intellij-extension-*.zip`
262 echo "Filename=${FILENAME}"
263 unzip "$FILENAME" -d content
264
265 echo "filename=${FILENAME%.????}" >> $GITHUB_OUTPUT
266
267 # Store already-built plugin as an artifact for downloading
268 - name: Upload artifact
269 uses: actions/upload-artifact@v4
270 with:
271 name: ${{ steps.artifact.outputs.filename }}
272 path: ./extensions/intellij/build/distributions/content/*/*
273
274 # Upload binaries as artifacts
275 - name: Upload artifact (darwin-arm64)
276 uses: actions/upload-artifact@v4
277 with:
278 name: continue-binary-darwin-arm64
279 path: ./binary/bin/darwin-arm64/
280
281 - name: Upload artifact (darwin-x64)
282 uses: actions/upload-artifact@v4
283 with:
284 name: continue-binary-darwin-x64
285 path: ./binary/bin/darwin-x64/
286
287 - name: Upload artifact (win32-x64)
288 uses: actions/upload-artifact@v4
289 with:
290 name: continue-binary-win32-x64
291 path: ./binary/bin/win32-x64/
292
293 - name: Upload artifact (win32-arm64)
294 uses: actions/upload-artifact@v4
295 with:
296 name: continue-binary-win32-arm64
297 path: ./binary/bin/win32-arm64/
298
299 - name: Upload artifact (linux-arm64)
300 uses: actions/upload-artifact@v4
301 with:
302 name: continue-binary-linux-arm64
303 path: ./binary/bin/linux-arm64/
304
305 - name: Upload artifact (linux-x64)
306 uses: actions/upload-artifact@v4
307 with:
308 name: continue-binary-linux-x64
309 path: ./binary/bin/linux-x64/
310
311 test-binaries:
312 needs: build
313 strategy:
314 matrix:
315 include:
316 - os: windows-latest
317 platform: win32
318 arch: x64
319 npm_config_arch: x64
320 - os: ubuntu-latest
321 platform: linux
322 arch: x64
323 npm_config_arch: x64
324 # arm64 not actually supported by GitHub
325 # - os: ubuntu-latest
326 # platform: linux
327 # arch: arm64
328 # npm_config_arch: arm64
329 - os: macos-12
330 platform: darwin
331 arch: x64
332 npm_config_arch: x64
333 - os: macos-latest
334 platform: darwin
335 arch: arm64
336 npm_config_arch: arm64
337 runs-on: ${{ matrix.os }}
338 steps:
339 # 1. Check-out repository
340 - name: Check-out repository
341 uses: actions/checkout@v4
342
343 # 2. Install npm dependencies
344 - name: Use Node.js from .nvmrc
345 uses: actions/setup-node@v4
346 with:
347 node-version-file: ".nvmrc"
348
349 - name: Cache core node_modules
350 uses: actions/cache@v3
351 with:
352 path: core/node_modules
353 key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
354
355 - name: Cache binary node_modules
356 uses: actions/cache@v3
357 with:
358 path: binary/node_modules
359 key: ${{ runner.os }}-node-${{ hashFiles('binary/package-lock.json') }}
360
361 - name: Install Core Dependencies
362 run: |
363 cd ../../core
364 npm ci
365
366 - name: Install Binary Dependencies
367 run: |
368 cd ../../binary
369 npm ci
370
371 # Download the binary artifact
372 - name: Download binary artifact
373 uses: actions/download-artifact@v4
374 with:
375 name: continue-binary-${{ matrix.platform }}-${{ matrix.arch }}
376 path: ./binary/bin/${{ matrix.platform }}-${{ matrix.arch }}/
377
378 # Set execute permissions for the binary (non-Windows)
379 - name: Set execute permissions
380 run: |
381 cd ../../binary/bin/${{ matrix.platform }}-${{ matrix.arch }}
382 chmod +x continue-binary
383 chmod +x build/Release/node_sqlite3.node
384 chmod +x index.node
385 if: ${{ matrix.platform }} != 'win32'
386
387 # Run tests for binary
388 - name: Run binary tests
389 run: |
390 cd ../../binary
391 npm run test
392
393 - name: Upload logs
394 if: ${{ always() }}
395 uses: actions/upload-artifact@v4
396 with:
397 name: core-logs-${{ matrix.platform }}-${{ matrix.arch }}
398 path: ~/.continue/logs/core.log
399
400 # Run tests and upload a code coverage report
401 test:
402 name: Test
403 needs: [build]
404 runs-on: ubuntu-latest
405 steps:
406 # Check out current repository
407 - name: Fetch Sources
408 uses: actions/checkout@v4
409
410 # Set up Java environment for the next steps
411 - name: Setup Java
412 uses: actions/setup-java@v4
413 with:
414 distribution: zulu
415 java-version: 17
416
417 # Setup Gradle
418 - name: Setup Gradle
419 uses: gradle/actions/setup-gradle@v3
420 with:
421 gradle-home-cache-cleanup: true
422
423 # Run tests
424 - name: Run Tests
425 run: ./gradlew check
426
427 # Collect Tests Result of failed tests
428 - name: Collect Tests Result
429 if: ${{ failure() }}
430 uses: actions/upload-artifact@v4
431 with:
432 name: tests-result
433 path: ${{ github.workspace }}/extensions/intellij/build/reports/tests
434
435 # Upload the Kover report to CodeCov
436 # - name: Upload Code Coverage Report
437 # uses: codecov/codecov-action@v4
438 # with:
439 # files: ${{ github.workspace }}/build/reports/kover/report.xml
440
441 # Run Qodana inspections and provide report
442 inspectCode:
443 if: false
444 name: Inspect code
445 needs: [build]
446 runs-on: ubuntu-latest
447 permissions:
448 contents: write
449 checks: write
450 pull-requests: write
451 steps:
452 # Free GitHub Actions Environment Disk Space
453 - name: Maximize Build Space
454 uses: jlumbroso/free-disk-space@main
455 with:
456 tool-cache: false
457 large-packages: false
458
459 # Check out current repository
460 - name: Fetch Sources
461 uses: actions/checkout@v4
462
463 # Set up Java environment for the next steps
464 - name: Setup Java
465 uses: actions/setup-java@v4
466 with:
467 distribution: zulu
468 java-version: 17
469
470 # Run Qodana inspections
471 - name: Qodana - Code Inspection
472 uses: JetBrains/qodana-action@v2025.1.1
473 with:
474 cache-default-branch-only: true
475
476 # Run plugin structure verification along with IntelliJ Plugin Verifier
477 verify:
478 if: false
479 name: Verify plugin
480 needs: [build]
481 runs-on: ubuntu-latest
482 steps:
483 # Free GitHub Actions Environment Disk Space
484 - name: Maximize Build Space
485 uses: jlumbroso/free-disk-space@main
486 with:
487 tool-cache: false
488 large-packages: false
489
490 # Check out current repository
491 - name: Fetch Sources
492 uses: actions/checkout@v4
493
494 # Set up Java environment for the next steps
495 - name: Setup Java
496 uses: actions/setup-java@v4
497 with:
498 distribution: zulu
499 java-version: 17
500
501 # Setup Gradle
502 - name: Setup Gradle
503 uses: gradle/actions/setup-gradle@v3
504 with:
505 gradle-home-cache-cleanup: true
506
507 # Cache Plugin Verifier IDEs
508 - name: Setup Plugin Verifier IDEs Cache
509 uses: actions/cache@v4
510 with:
511 path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
512 key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
513
514 # Run Verify Plugin task and IntelliJ Plugin Verifier tool
515 - name: Run Plugin Verification tasks
516 run: ./gradlew runPluginVerifier -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}
517
518 # Collect Plugin Verifier Result
519 - name: Collect Plugin Verifier Result
520 if: ${{ always() }}
521 uses: actions/upload-artifact@v4
522 with:
523 name: pluginVerifier-result
524 path: ${{ github.workspace }}/build/reports/pluginVerifier
525
526 upload-release:
527 if: false
528 name: Upload Release
529 needs:
530 - build
531 - test-binaries
532 - test
533 runs-on: ubuntu-latest
534 steps:
535 # # Update Unreleased section with the current release note
536 # - name: Patch Changelog
537 # if: ${{ steps.properties.outputs.changelog != '' }}
538 # env:
539 # CHANGELOG: ${{ steps.properties.outputs.changelog }}
540 # run: |
541 # ./gradlew patchChangelog --release-note="$CHANGELOG"
542
543 - name: Download the plugin
544 uses: actions/download-artifact@v4
545 with:
546 name: ${{ steps.artifact.outputs.filename }}
547 path: ./build/distributions/
548
549 # Upload artifact as a release asset
550 # - name: Upload Release Asset
551 # env:
552 # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
553 # run: gh release upload ${{ github.event.release.tag_name }} ./build/distributions/*
554
555 # Publish the plugin to JetBrains Marketplace
556 - name: Publish Plugin
557 env:
558 PUBLISH_TOKEN: ${{ secrets.JETBRAINS_PUBLISH_TOKEN }}
559 CERTIFICATE_CHAIN: ${{ secrets.JETBRAINS_CERTIFICATE_CHAIN }}
560 PRIVATE_KEY: ${{ secrets.JETBRAINS_PRIVATE_KEY }}
561 PRIVATE_KEY_PASSWORD: ${{ secrets.JETBRAINS_PRIVATE_KEY_PASSWORD }}
562 run: ./gradlew publishPlugin
563
564 # Create a pull request
565 - name: Create Pull Request
566 if: ${{ steps.properties.outputs.changelog != '' }}
567 env:
568 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
569 run: |
570 VERSION="${{ github.event.release.tag_name }}"
571 BRANCH="changelog-update-$VERSION"
572 LABEL="release changelog"
573
574 git config user.email "action@github.com"
575 git config user.name "GitHub Action"
576
577 git checkout -b $BRANCH
578 git commit -am "Changelog update - $VERSION"
579 git push --set-upstream origin $BRANCH
580
581 gh label create "$LABEL" \
582 --description "Pull requests with release changelog update" \
583 --force \
584 || true
585
586 gh pr create \
587 --title "Changelog update - \`$VERSION\`" \
588 --body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
589 --label "$LABEL" \
590 --head $BRANCH