Elffuss BraidHub

kikocis/continue public

main · 4.6 KiBRawPermalink
1name: 'Build VS Code Extension'
2description: 'Build VS Code extension for a specific platform'
3inputs:
4 platform:
5 description: 'Target platform (win32, linux, alpine, darwin)'
6 required: true
7 arch:
8 description: 'Target architecture (x64, arm64, armhf)'
9 required: true
10 npm_config_arch:
11 description: 'npm config arch (x64, arm64, arm)'
12 required: true
13 pre-release:
14 description: 'Whether to build as pre-release'
15 required: false
16 default: 'false'
17 commit-sha:
18 description: 'Commit SHA for version modification (optional, uses first 7 chars)'
19 required: false
20 default: ''
21 github-token:
22 description: 'GitHub token for downloading ripgrep'
23 required: true
24outputs:
25 target:
26 description: 'The target string used for the build'
27 value: ${{ steps.set-target.outputs.target }}
28 vsix-path:
29 description: 'Path to the generated VSIX file'
30 value: 'extensions/vscode/*.vsix'
31 build-path:
32 description: 'Path to the build artifacts'
33 value: 'extensions/vscode/build'
34
35runs:
36 using: 'composite'
37 steps:
38 - uses: actions/setup-node@v4
39 with:
40 node-version-file: ".nvmrc"
41
42 - name: Set target variable
43 id: set-target
44 shell: bash
45 run: echo "target=${{ inputs.platform }}-${{ inputs.arch }}" >> $GITHUB_OUTPUT
46
47 - name: Cache npm
48 uses: actions/cache@v4
49 with:
50 path: ~/.npm
51 key: ${{ runner.os }}-npm-cache-build-${{ hashFiles('**/package-lock.json') }}
52
53 - name: Cache extension node_modules
54 uses: actions/cache@v4
55 with:
56 path: extensions/vscode/node_modules
57 key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
58
59 - name: Cache core node_modules
60 uses: actions/cache@v4
61 with:
62 path: core/node_modules
63 key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
64
65 - name: Cache gui node_modules
66 uses: actions/cache@v4
67 with:
68 path: gui/node_modules
69 key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
70
71 - name: Cache packages node_modules
72 uses: actions/cache@v4
73 with:
74 path: |
75 packages/*/node_modules
76 key: ${{ runner.os }}-packages-node-modules-${{ hashFiles('packages/*/package-lock.json') }}
77
78 - name: Build packages
79 shell: bash
80 run: node ./scripts/build-packages.js
81
82 - name: Install extension dependencies
83 shell: bash
84 run: |
85 cd extensions/vscode
86 npm ci
87 env:
88 # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
89 GITHUB_TOKEN: ${{ inputs.github-token }}
90
91 - name: Install gui dependencies
92 shell: bash
93 run: |
94 cd gui
95 npm ci
96
97 - name: Install core dependencies
98 shell: bash
99 run: |
100 cd core
101 npm ci
102 npm i vectordb
103
104 - name: Build GUI
105 shell: bash
106 run: |
107 cd gui
108 npm run build --max-old-space-size=4096
109 env:
110 NODE_OPTIONS: "--max-old-space-size=4096"
111
112 - name: Prepackage the extension
113 shell: bash
114 run: |
115 cd extensions/vscode
116 npm run prepackage -- --target ${{ steps.set-target.outputs.target }}
117
118 - name: Re-install esbuild
119 shell: bash
120 run: |
121 cd extensions/vscode
122 npm install -f esbuild
123
124 - name: Modify package.json version with commit SHA
125 if: inputs.commit-sha != ''
126 shell: bash
127 run: |
128 cd extensions/vscode
129 # Get current version from package.json
130 CURRENT_VERSION=$(node -p "require('./package.json').version")
131
132 # Create new version with short commit SHA (first 7 chars)
133 COMMIT_SHORT="${{ inputs.commit-sha }}"
134 NEW_VERSION="${CURRENT_VERSION}-${COMMIT_SHORT:0:7}"
135
136 echo "📝 Updating package.json version from $CURRENT_VERSION to $NEW_VERSION"
137
138 # Update version in package.json
139 sed -i.bak "s/\"version\": \"$CURRENT_VERSION\"/\"version\": \"$NEW_VERSION\"/" package.json
140
141 # Remove backup file
142 rm -f package.json.bak
143
144 # Verify the change
145 echo "✅ New version: $(node -p "require('./package.json').version")"
146
147 - name: Package extension (build artifacts)
148 shell: bash
149 run: |
150 cd extensions/vscode
151 npm run package
152
153 - name: Package extension (.vsix files)
154 shell: bash
155 run: |
156 cd extensions/vscode
157 if [ "${{ inputs.pre-release }}" = "true" ]; then
158 npx vsce package --pre-release --no-dependencies --target ${{ steps.set-target.outputs.target }}
159 else
160 npx vsce package --no-dependencies --target ${{ steps.set-target.outputs.target }}
161 fi