File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5151 - name : Install dependencies
5252 run : npm ci
5353
54- - name : Build
54+ - name : Build (non-Windows)
55+ if : matrix.os != 'windows-latest'
5556 run : npm run build
5657
58+ - name : Build (Windows)
59+ if : matrix.os == 'windows-latest'
60+ shell : powershell
61+ run : |
62+ # Compile TypeScript first
63+ npx tsc
64+
65+ # Create a Windows-compatible build script
66+ $buildScript = @"
67+ import * as esbuild from 'esbuild';
68+ import { readFileSync } from 'fs';
69+ import path from 'path';
70+
71+ async function build() {
72+ try {
73+ const pkg = JSON.parse(readFileSync('./package.json', 'utf8'));
74+
75+ // Bundle the application
76+ await esbuild.build({
77+ entryPoints: ['./dist/index.js'],
78+ bundle: true,
79+ platform: 'node',
80+ target: 'node20',
81+ outfile: './dist/index.js',
82+ banner: {
83+ js: '#!/usr/bin/env node',
84+ },
85+ external: Object.keys(pkg.dependencies || {}).concat(Object.keys(pkg.peerDependencies || {})),
86+ });
87+
88+ console.log('Build completed successfully');
89+ } catch (error) {
90+ console.error('Build failed:', error);
91+ process.exit(1);
92+ }
93+ }
94+
95+ build();
96+ "@
97+
98+ # Write the modified build script to a file
99+ $buildScript | Out-File -FilePath "windows-build.mjs" -Encoding utf8
100+
101+ # Run the modified build script
102+ node windows-build.mjs
103+
57104 - name : Package binaries
58105 run : |
59106 if [ "${{ matrix.os }}" == "windows-latest" ]; then
You can’t perform that action at this time.
0 commit comments