Elffuss BraidHub

kikocis/continue public

f433400a74a4 · 4.5 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
109
110 - name: Prepackage the extension
111 shell: bash
112 run: |
113 cd extensions/vscode
114 npm run prepackage -- --target ${{ steps.set-target.outputs.target }}
115
116 - name: Re-install esbuild
117 shell: bash
118 run: |
119 cd extensions/vscode
120 npm install -f esbuild
121
122 - name: Modify package.json version with commit SHA
123 if: inputs.commit-sha != ''
124 shell: bash
125 run: |
126 cd extensions/vscode
127 # Get current version from package.json
128 CURRENT_VERSION=$(node -p "require('./package.json').version")
129
130 # Create new version with short commit SHA (first 7 chars)
131 COMMIT_SHORT="${{ inputs.commit-sha }}"
132 NEW_VERSION="${CURRENT_VERSION}-${COMMIT_SHORT:0:7}"
133
134 echo "📝 Updating package.json version from $CURRENT_VERSION to $NEW_VERSION"
135
136 # Update version in package.json
137 sed -i.bak "s/\"version\": \"$CURRENT_VERSION\"/\"version\": \"$NEW_VERSION\"/" package.json
138
139 # Remove backup file
140 rm -f package.json.bak
141
142 # Verify the change
143 echo "✅ New version: $(node -p "require('./package.json').version")"
144
145 - name: Package extension (build artifacts)
146 shell: bash
147 run: |
148 cd extensions/vscode
149 npm run package
150
151 - name: Package extension (.vsix files)
152 shell: bash
153 run: |
154 cd extensions/vscode
155 if [ "${{ inputs.pre-release }}" = "true" ]; then
156 npx vsce package --pre-release --no-dependencies --target ${{ steps.set-target.outputs.target }}
157 else
158 npx vsce package --no-dependencies --target ${{ steps.set-target.outputs.target }}
159 fi