1+ name : Build Executables
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ tags : [ 'v*' ]
7+ pull_request :
8+ branches : [ main ]
9+
10+ jobs :
11+ build :
12+ name : Build ${{ matrix.target }}
13+ runs-on : ${{ matrix.os }}
14+ strategy :
15+ matrix :
16+ include :
17+ - os : ubuntu-latest
18+ target : linux-x64
19+ bun-target : bun-linux-x64
20+ artifact-name : wallet-generator-linux-x64
21+ executable-ext : " "
22+ - os : windows-latest
23+ target : windows-x64
24+ bun-target : bun-windows-x64
25+ artifact-name : wallet-generator-windows-x64
26+ executable-ext : " .exe"
27+ - os : macos-13
28+ target : macos-x64
29+ bun-target : bun-darwin-x64
30+ artifact-name : wallet-generator-macos-x64
31+ executable-ext : " "
32+ - os : macos-latest
33+ target : macos-arm64
34+ bun-target : bun-darwin-arm64
35+ artifact-name : wallet-generator-macos-arm64
36+ executable-ext : " "
37+
38+ steps :
39+ - name : Checkout code
40+ uses : actions/checkout@v4
41+
42+ - name : Setup Bun
43+ uses : oven-sh/setup-bun@v1
44+ with :
45+ bun-version : latest
46+
47+ - name : Install dependencies
48+ run : bun install
49+
50+ - name : Workaround for Bun cache issue on Windows
51+ if : runner.os == 'Windows'
52+ run : |
53+ # Create temporary project on C:\ to initialize Bun cache for target platform
54+ # This works around https://github.com/oven-sh/bun/issues/11198
55+ mkdir C:\temp-bun-cache-init
56+ cd C:\temp-bun-cache-init
57+ echo 'console.log("cache init");' > index.js
58+ bun build --compile --target=${{ matrix.bun-target }}-baseline --outfile=cache-init${{ matrix.executable-ext }} ./index.js
59+ cd ${{ github.workspace }}
60+ Remove-Item -Recurse -Force C:\temp-bun-cache-init
61+
62+ - name : Build executable
63+ run : bun build --compile --target=${{ matrix.bun-target }}-baseline --outfile=wallet-generator${{ matrix.executable-ext }} ./wallet_generator.ts
64+
65+ - name : Test executable (Linux/macOS)
66+ if : runner.os != 'Windows'
67+ run : |
68+ chmod +x ./wallet-generator${{ matrix.executable-ext }}
69+ # Start server in background
70+ ./wallet-generator${{ matrix.executable-ext }} &
71+ SERVER_PID=$!
72+ echo "Started server with PID: $SERVER_PID"
73+
74+ # Wait for server to start
75+ sleep 3
76+
77+ # Test that server is responding
78+ if curl -f http://localhost:8888/ > /dev/null 2>&1; then
79+ echo "✓ Server is responding correctly"
80+ else
81+ echo "✗ Server failed to respond"
82+ kill $SERVER_PID 2>/dev/null || true
83+ exit 1
84+ fi
85+
86+ # Test embedded assets
87+ if curl -f http://localhost:8888/logo.svg > /dev/null 2>&1; then
88+ echo "✓ Embedded assets are working"
89+ else
90+ echo "✗ Embedded assets failed"
91+ kill $SERVER_PID 2>/dev/null || true
92+ exit 1
93+ fi
94+
95+ # Clean up
96+ kill $SERVER_PID 2>/dev/null || true
97+ echo "✓ Executable test completed successfully"
98+
99+ - name : Test executable (Windows)
100+ if : runner.os == 'Windows'
101+ run : |
102+ # Start server in background
103+ Start-Process -FilePath ".\wallet-generator${{ matrix.executable-ext }}" -WindowStyle Hidden
104+
105+ # Wait for server to start
106+ Start-Sleep -Seconds 5
107+
108+ # Test that server is responding
109+ try {
110+ $response = Invoke-WebRequest -Uri "http://localhost:8888/" -TimeoutSec 10
111+ if ($response.StatusCode -eq 200) {
112+ Write-Host "✓ Server is responding correctly"
113+ } else {
114+ Write-Host "✗ Server returned status code: $($response.StatusCode)"
115+ Get-Process -Name "wallet-generator*" | Stop-Process -Force
116+ exit 1
117+ }
118+ } catch {
119+ Write-Host "✗ Server failed to respond: $_"
120+ Get-Process -Name "wallet-generator*" | Stop-Process -Force
121+ exit 1
122+ }
123+
124+ # Test embedded assets
125+ try {
126+ $response = Invoke-WebRequest -Uri "http://localhost:8888/logo.svg" -TimeoutSec 10
127+ if ($response.StatusCode -eq 200) {
128+ Write-Host "✓ Embedded assets are working"
129+ } else {
130+ Write-Host "✗ Assets returned status code: $($response.StatusCode)"
131+ Get-Process -Name "wallet-generator*" | Stop-Process -Force
132+ exit 1
133+ }
134+ } catch {
135+ Write-Host "✗ Embedded assets failed: $_"
136+ Get-Process -Name "wallet-generator*" | Stop-Process -Force
137+ exit 1
138+ }
139+
140+ # Clean up
141+ Get-Process -Name "wallet-generator*" | Stop-Process -Force
142+ Write-Host "✓ Executable test completed successfully"
143+
144+ - name : Upload artifact
145+ uses : actions/upload-artifact@v4
146+ with :
147+ name : ${{ matrix.artifact-name }}
148+ path : wallet-generator${{ matrix.executable-ext }}
149+ retention-days : 30
150+
151+ release :
152+ name : Create Release
153+ runs-on : ubuntu-latest
154+ needs : build
155+ if : startsWith(github.ref, 'refs/tags/')
156+
157+ steps :
158+ - name : Checkout code
159+ uses : actions/checkout@v4
160+
161+ - name : Download all artifacts
162+ uses : actions/download-artifact@v4
163+ with :
164+ path : ./artifacts
165+
166+ - name : Display structure of downloaded files
167+ run : ls -la ./artifacts/
168+
169+ - name : Create release archives
170+ run : |
171+ cd ./artifacts
172+ for dir in */; do
173+ artifact_name=${dir%/}
174+ cd "$dir"
175+ if [[ "$artifact_name" == *"windows"* ]]; then
176+ zip "../${artifact_name}.zip" wallet-generator.exe
177+ else
178+ tar -czf "../${artifact_name}.tar.gz" wallet-generator
179+ fi
180+ cd ..
181+ done
182+ ls -la
183+
184+ - name : Create Release
185+ uses : softprops/action-gh-release@v1
186+ with :
187+ files : |
188+ ./artifacts/*.zip
189+ ./artifacts/*.tar.gz
190+ generate_release_notes : true
191+ draft : false
192+ prerelease : false
193+ env :
194+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments