Skip to content

Commit 96b5c02

Browse files
committed
chore: run windows cli build on windows runner [codecane]
1 parent 5b2de4c commit 96b5c02

File tree

1 file changed

+142
-5
lines changed

1 file changed

+142
-5
lines changed

.github/workflows/cli-release-build.yml

Lines changed: 142 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ jobs:
5454
bun_target: bun-darwin-arm64
5555
platform: darwin
5656
arch: arm64
57-
- os: windows-latest
58-
target: win32-x64
59-
bun_target: bun-windows-x64
60-
platform: win32
61-
arch: x64
6257
runs-on: ${{ matrix.os }}
6358
steps:
6459
- uses: actions/checkout@v4
@@ -207,3 +202,145 @@ jobs:
207202
with:
208203
limit-access-to-actor: true
209204
timeout-minutes: 15
205+
206+
build-windows-binary:
207+
runs-on: windows-latest
208+
steps:
209+
- uses: actions/checkout@v4
210+
with:
211+
ref: ${{ inputs.checkout-ref || github.sha }}
212+
213+
- uses: ./.github/actions/setup-project
214+
215+
- name: Download staging metadata
216+
if: inputs.artifact-name != ''
217+
uses: actions/download-artifact@v4
218+
with:
219+
name: ${{ inputs.artifact-name }}
220+
path: cli/release-staging/
221+
222+
- name: Ensure CLI dependencies
223+
run: bun install --frozen-lockfile --cwd cli
224+
225+
- name: Fix OpenTUI module symlinks
226+
shell: bash
227+
run: |
228+
set -euo pipefail
229+
bun - <<'BUN'
230+
import fs from 'fs';
231+
import path from 'path';
232+
233+
const rootDir = process.cwd();
234+
const rootOpenTui = path.join(rootDir, 'node_modules', '@opentui');
235+
const cliNodeModules = path.join(rootDir, 'cli', 'node_modules');
236+
const cliOpenTui = path.join(cliNodeModules, '@opentui');
237+
238+
if (!fs.existsSync(rootOpenTui)) {
239+
console.log('Root @opentui packages missing; skipping fix');
240+
process.exit(0);
241+
}
242+
243+
fs.mkdirSync(cliOpenTui, { recursive: true });
244+
245+
const packages = ['core', 'react'];
246+
for (const pkg of packages) {
247+
const target = path.join(rootOpenTui, pkg);
248+
const link = path.join(cliOpenTui, pkg);
249+
250+
if (!fs.existsSync(target)) {
251+
console.log(`Target ${target} missing; skipping ${pkg}`);
252+
continue;
253+
}
254+
255+
let linkStats = null;
256+
try {
257+
linkStats = fs.lstatSync(link);
258+
} catch (error) {
259+
if (error?.code !== 'ENOENT') {
260+
throw error;
261+
}
262+
}
263+
264+
if (linkStats) {
265+
let alreadyLinked = false;
266+
try {
267+
const actual = fs.realpathSync(link);
268+
alreadyLinked = actual === target;
269+
} catch {
270+
// Broken symlink or unreadable target; we'll replace it.
271+
}
272+
273+
if (alreadyLinked) {
274+
continue;
275+
}
276+
277+
fs.rmSync(link, { recursive: true, force: true });
278+
}
279+
280+
const type = process.platform === 'win32' ? 'junction' : 'dir';
281+
try {
282+
fs.symlinkSync(target, link, type);
283+
console.log(`Linked ${link} -> ${target}`);
284+
} catch (error) {
285+
if (error?.code === 'EEXIST') {
286+
fs.rmSync(link, { recursive: true, force: true });
287+
fs.symlinkSync(target, link, type);
288+
console.log(`Re-linked ${link} -> ${target}`);
289+
} else {
290+
throw error;
291+
}
292+
}
293+
}
294+
BUN
295+
296+
- name: Configure environment variables
297+
env:
298+
SECRETS_CONTEXT: ${{ toJSON(secrets) }}
299+
ENV_OVERRIDES: ${{ inputs.env-overrides }}
300+
shell: bash
301+
run: |
302+
VAR_NAMES=$(bun scripts/generate-ci-env.js --prefix NEXT_PUBLIC_)
303+
304+
echo "$SECRETS_CONTEXT" | jq -r --argjson vars "$VAR_NAMES" '
305+
to_entries | .[] | select(.key as $k | $vars | index($k)) | .key + "=" + .value
306+
' >> $GITHUB_ENV
307+
echo "CODEBUFF_GITHUB_ACTIONS=true" >> $GITHUB_ENV
308+
echo "CODEBUFF_GITHUB_TOKEN=${{ secrets.CODEBUFF_GITHUB_TOKEN }}" >> $GITHUB_ENV
309+
if [ "$ENV_OVERRIDES" != "{}" ]; then
310+
echo "$ENV_OVERRIDES" | jq -r 'to_entries | .[] | .key + "=" + .value' >> $GITHUB_ENV
311+
fi
312+
313+
- name: Build binary
314+
run: bun run scripts/build-binary.ts ${{ inputs.binary-name }} ${{ inputs.new-version }}
315+
working-directory: cli
316+
shell: bash
317+
env:
318+
VERBOSE: true
319+
OVERRIDE_TARGET: bun-windows-x64
320+
OVERRIDE_PLATFORM: win32
321+
OVERRIDE_ARCH: x64
322+
323+
- name: Smoke test binary
324+
shell: bash
325+
run: |
326+
cd cli/bin
327+
./${{ inputs.binary-name }}.exe --version
328+
329+
- name: Create tarball
330+
shell: bash
331+
run: |
332+
BINARY_FILE="${{ inputs.binary-name }}.exe"
333+
tar -czf codecane-win32-x64.tar.gz -C cli/bin "$BINARY_FILE"
334+
335+
- name: Upload binary artifact
336+
uses: actions/upload-artifact@v4
337+
with:
338+
name: codecane-win32-x64
339+
path: codecane-win32-x64.tar.gz
340+
341+
- name: Open debug shell on failure
342+
if: failure()
343+
uses: mxschmitt/action-tmate@v3
344+
with:
345+
limit-access-to-actor: true
346+
timeout-minutes: 15

0 commit comments

Comments
 (0)