update build workflow #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Desktop Applications | |
| on: | |
| push: | |
| branches: | |
| - 'master' | |
| - 'feat/lib' | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| inputs: | |
| publish: | |
| description: 'Publish to GitHub Releases' | |
| required: false | |
| default: 'false' | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| platform: linux | |
| - os: macos-latest | |
| platform: mac | |
| - os: windows-latest | |
| platform: windows | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Fix app-builder permissions (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| find node_modules/app-builder-bin -type f -name 'app-builder' -exec chmod +x {} \; | |
| ls -la node_modules/app-builder-bin/linux/x64/ | |
| ls -la node_modules/app-builder-bin/linux/arm64/ | |
| - name: Build main application | |
| run: npm run build | |
| - name: Install icon builder (Ubuntu/macOS) | |
| if: runner.os != 'Windows' | |
| run: npm install -g electron-icon-builder | |
| - name: Install icon builder (Windows) | |
| if: runner.os == 'Windows' | |
| run: npm install -g electron-icon-builder | |
| shell: powershell | |
| - name: Generate icons | |
| run: | | |
| mkdir -p electron/build/icons | |
| cd electron/build | |
| electron-icon-builder --flatten --input=../../LiaScript/resources/icon.png --output=. | |
| shell: bash | |
| - name: Build Electron app (Linux) | |
| if: matrix.platform == 'linux' | |
| run: npm run electron:build:linux | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Electron app (macOS) | |
| if: matrix.platform == 'mac' | |
| run: | | |
| # Retry logic for macOS DMG creation (disk busy issues) | |
| max_attempts=3 | |
| attempt=0 | |
| until [ $attempt -ge $max_attempts ] | |
| do | |
| attempt=$((attempt+1)) | |
| echo "Build attempt $attempt of $max_attempts" | |
| if npm run electron:build:mac; then | |
| echo "Build succeeded on attempt $attempt" | |
| break | |
| else | |
| if [ $attempt -lt $max_attempts ]; then | |
| echo "Build failed, waiting 10 seconds before retry..." | |
| sleep 10 | |
| # Clean up any mounted disks | |
| hdiutil detach /Volumes/LiaScript* 2>/dev/null || true | |
| sleep 5 | |
| else | |
| echo "Build failed after $max_attempts attempts" | |
| exit 1 | |
| fi | |
| fi | |
| done | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # For code signing (optional): | |
| # CSC_LINK: ${{ secrets.MAC_CERT }} | |
| # CSC_KEY_PASSWORD: ${{ secrets.MAC_CERT_PASSWORD }} | |
| # APPLE_ID: ${{ secrets.APPLE_ID }} | |
| # APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} | |
| - name: Build Electron app (Windows) | |
| if: matrix.platform == 'windows' | |
| run: npm run electron:build:win | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # For code signing (optional): | |
| # CSC_LINK: ${{ secrets.WIN_CERT }} | |
| # CSC_KEY_PASSWORD: ${{ secrets.WIN_CERT_PASSWORD }} | |
| - name: List build artifacts | |
| run: ls -R release/ | |
| shell: bash | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.platform }}-builds | |
| path: | | |
| release/*.exe | |
| release/*.zip | |
| release/*.dmg | |
| release/*.AppImage | |
| release/*.deb | |
| release/*.rpm | |
| release/*.tar.gz | |
| release/*.yml | |
| retention-days: 30 | |
| - name: Upload to Release (on tag) | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| release/*.exe | |
| release/*.zip | |
| release/*.dmg | |
| release/*.AppImage | |
| release/*.deb | |
| release/*.rpm | |
| release/*.tar.gz | |
| release/*.yml | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Summary job | |
| build-summary: | |
| name: Build Summary | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Check build status | |
| run: | | |
| echo "Build completed!" | |
| echo "Linux: ${{ needs.build.result }}" | |
| echo "macOS: ${{ needs.build.result }}" | |
| echo "Windows: ${{ needs.build.result }}" |