1+ name : Build Windows App
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - ' feature/**'
8+ paths-ignore :
9+ - ' .github/**'
10+ - ' !.github/workflows/build-windows.yml'
11+ pull_request :
12+ branches :
13+ - main
14+ workflow_dispatch :
15+
16+ permissions :
17+ contents : write
18+
19+ jobs :
20+ build :
21+ name : Build Windows App
22+ runs-on : windows-latest
23+ strategy :
24+ matrix :
25+ arch : [x64]
26+
27+ steps :
28+ - name : Checkout code
29+ uses : actions/checkout@v4
30+
31+ - name : Setup PHP
32+ uses : shivammathur/setup-php@v2
33+ with :
34+ php-version : ' 8.3'
35+ extensions : mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, json, mbstring, pdo
36+ tools : composer:v2
37+ coverage : none
38+
39+ - name : Setup Node.js
40+ uses : actions/setup-node@v4
41+ with :
42+ node-version : ' 22'
43+
44+ - name : Get version
45+ id : version
46+ shell : bash
47+ run : |
48+ VERSION=$(grep "'version' =>" config/nativephp.php | sed -E "s/.*'([0-9]+\.[0-9]+\.[0-9]+)'.*/\1/")
49+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
50+ echo "Building version: $VERSION"
51+
52+ - name : Cache Composer dependencies
53+ uses : actions/cache@v4
54+ with :
55+ path : vendor
56+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
57+ restore-keys : |
58+ ${{ runner.os }}-composer-
59+
60+ - name : Install Composer dependencies
61+ run : composer install --no-interaction --no-dev --prefer-dist --optimize-autoloader
62+
63+ - name : Clean npm cache and node_modules
64+ shell : cmd
65+ run : |
66+ if exist node_modules rmdir /s /q node_modules
67+ if exist package-lock.json del package-lock.json
68+ npm cache clean --force
69+
70+ - name : Install NPM dependencies (Windows-specific)
71+ shell : cmd
72+ run : |
73+ echo Installing npm dependencies for Windows...
74+ npm install --omit=dev --no-optional
75+ echo Dependencies installed successfully
76+
77+ - name : Copy .env file
78+ run : cp .env.example .env
79+
80+ - name : Generate application key
81+ run : php artisan key:generate
82+
83+ - name : Build frontend assets
84+ run : npm run build
85+
86+ - name : Generate Ziggy routes
87+ run : php artisan ziggy:generate
88+
89+ - name : Install Electron dependencies
90+ working-directory : vendor/nativephp/electron/resources/js
91+ shell : cmd
92+ run : |
93+ if exist node_modules rmdir /s /q node_modules
94+ npm install --no-optional
95+
96+ - name : Rebuild Electron native modules
97+ working-directory : vendor/nativephp/electron/resources/js
98+ run : npx electron-rebuild
99+
100+ - name : Build NativePHP application
101+ env :
102+ NATIVEPHP_APP_VERSION : ${{ steps.version.outputs.VERSION }}
103+ run : |
104+ php artisan native:build win ${{ matrix.arch }}
105+
106+ - name : Upload artifacts
107+ uses : actions/upload-artifact@v4
108+ with :
109+ name : Clueless-${{ steps.version.outputs.VERSION }}-win-${{ matrix.arch }}
110+ path : dist/*.exe
111+ retention-days : 5
112+
113+ release :
114+ name : Create Windows Release
115+ needs : build
116+ runs-on : ubuntu-latest
117+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
118+
119+ steps :
120+ - name : Checkout code
121+ uses : actions/checkout@v4
122+
123+ - name : Get version
124+ id : version
125+ run : |
126+ VERSION=$(grep "'version' =>" config/nativephp.php | sed -E "s/.*'([0-9]+\.[0-9]+\.[0-9]+)'.*/\1/")
127+ echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
128+
129+ - name : Download x64 artifact
130+ uses : actions/download-artifact@v4
131+ with :
132+ name : Clueless-${{ steps.version.outputs.VERSION }}-win-x64
133+ path : ./artifacts/win-x64
134+
135+ - name : Upload Windows Release Assets
136+ env :
137+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
138+ run : |
139+ # Find the existing release for v${{ steps.version.outputs.VERSION }}
140+ RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/v${{ steps.version.outputs.VERSION }} --jq '.id' || echo "")
141+
142+ if [ -z "$RELEASE_ID" ]; then
143+ echo "No release found for v${{ steps.version.outputs.VERSION }}. Windows build will be added when release is created."
144+ exit 0
145+ fi
146+
147+ # Upload the Windows executables
148+ gh release upload v${{ steps.version.outputs.VERSION }} \
149+ ./artifacts/win-x64/Clueless-${{ steps.version.outputs.VERSION }}-win-x64.exe \
150+ --clobber
0 commit comments