Elffuss BraidHub

kikocis/continue public

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