Refactor: Modularized IdeLayout and centralized Rust workspace depend… #30
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 (PR Check) | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| # Se ejecuta en PRs y pushes a ramas principales (no en tags de release). | |
| # Solo compila para Windows. Linux se añadirá en el futuro. | |
| on: | |
| pull_request: | |
| branches: [main, master, develop] | |
| push: | |
| branches: [main, master, develop] | |
| tags-ignore: | |
| - 'v*' | |
| - '*.*.*' | |
| # Cancela el build anterior del mismo PR/branch si llega uno nuevo. | |
| # Así no se acumulan builds en cola mientras trabajas. | |
| concurrency: | |
| group: build-${{ github.ref }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-windows: | |
| name: Build — Windows x64 | |
| runs-on: windows-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| # ─── 1. CHECKOUT ──────────────────────────────────────────────────────── | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # ─── 2. VALIDAR VERSIONES ─────────────────────────────────────────────── | |
| # Comprueba que package.json, Cargo.toml y tauri.conf.json tienen el mismo semver. | |
| # Usa node --eval para evitar sed/grep frágiles. | |
| - name: Validate version consistency | |
| shell: pwsh | |
| run: | | |
| $cargoRaw = Get-Content src-tauri/Cargo.toml -Raw | |
| $pkgRaw = Get-Content package.json -Raw | |
| $tauriRaw = Get-Content src-tauri/tauri.conf.json -Raw | |
| $cargoVer = [regex]::Match($cargoRaw, '(?m)^version\s*=\s*"([^"]+)"').Groups[1].Value | |
| $pkgVer = ($pkgRaw | ConvertFrom-Json).version | |
| $tauriVer = ($tauriRaw | ConvertFrom-Json).package.version | |
| Write-Host "Cargo.toml: $cargoVer" | |
| Write-Host "package.json: $pkgVer" | |
| Write-Host "tauri.conf.json: $tauriVer" | |
| if ($cargoVer -ne $pkgVer) { | |
| Write-Error "Version mismatch: Cargo.toml ($cargoVer) != package.json ($pkgVer)" | |
| exit 1 | |
| } | |
| if ($cargoVer -ne $tauriVer) { | |
| Write-Error "Version mismatch: Cargo.toml ($cargoVer) != tauri.conf.json ($tauriVer)" | |
| exit 1 | |
| } | |
| Write-Host "✅ All versions match: $cargoVer" | |
| # ─── 3. TOOLCHAIN — NODE + PNPM ───────────────────────────────────────── | |
| - name: Setup Node.js 20 LTS | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Get pnpm store path | |
| id: pnpm-store | |
| shell: pwsh | |
| run: | | |
| $store = pnpm store path | |
| "path=$store" >> $env:GITHUB_OUTPUT | |
| - name: Cache pnpm store | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.pnpm-store.outputs.path }} | |
| key: windows-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| windows-pnpm- | |
| # ─── 4. TOOLCHAIN — RUST ──────────────────────────────────────────────── | |
| - name: Setup Rust stable (x86_64-pc-windows-msvc) | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: x86_64-pc-windows-msvc | |
| - name: Cache Cargo registry + build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~\.cargo\registry | |
| ~\.cargo\git | |
| src-tauri\target | |
| key: windows-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| windows-cargo- | |
| # ─── 5. VERIFICAR ACTIVOS NECESARIOS ──────────────────────────────────── | |
| - name: Verify required Windows icons | |
| shell: pwsh | |
| run: | | |
| $icons = @( | |
| "src-tauri/icons/icon.ico", | |
| "src-tauri/icons/32x32.png", | |
| "src-tauri/icons/128x128.png" | |
| ) | |
| $missing = $false | |
| foreach ($icon in $icons) { | |
| if (Test-Path $icon) { | |
| Write-Host "✓ Found: $icon" | |
| } else { | |
| Write-Error "✗ Missing: $icon" | |
| $missing = $true | |
| } | |
| } | |
| if ($missing) { exit 1 } | |
| # ─── 6. FRONTEND ──────────────────────────────────────────────────────── | |
| - name: Install frontend dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build frontend | |
| run: pnpm build | |
| # ─── 7. BUILD TAURI ───────────────────────────────────────────────────── | |
| # En PRs compilamos sin firmar ni crear release (solo verificar que compila). | |
| - name: Build Tauri app (Windows x64) | |
| uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| projectPath: . | |
| args: --target x86_64-pc-windows-msvc | |
| # ─── 8. VERIFICAR BINARIO Y REPORTAR TAMAÑO ───────────────────────────── | |
| - name: Verify binary and report size | |
| shell: pwsh | |
| run: | | |
| $releaseDirs = @( | |
| "target\x86_64-pc-windows-msvc\release", | |
| "src-tauri\target\x86_64-pc-windows-msvc\release" | |
| ) | |
| $foundBinary = $null | |
| foreach ($dir in $releaseDirs) { | |
| $candidate = Join-Path $dir "meacode-studio.exe" | |
| if (Test-Path $candidate) { | |
| $foundBinary = $candidate | |
| break | |
| } | |
| } | |
| if ($null -ne $foundBinary) { | |
| $size = (Get-Item $foundBinary).Length / 1MB | |
| Write-Host "✅ Binary found: $foundBinary ($([math]::Round($size, 2)) MB)" | |
| } else { | |
| Write-Error "❌ Binary not found in expected release dirs." | |
| foreach ($dir in $releaseDirs) { | |
| if (Test-Path $dir) { | |
| Write-Host "Checking: $dir" | |
| Get-ChildItem $dir -Filter "*.exe" -ErrorAction SilentlyContinue | |
| } | |
| } | |
| exit 1 | |
| } | |
| $bundleDirs = @( | |
| "target\x86_64-pc-windows-msvc\release\bundle", | |
| "src-tauri\target\x86_64-pc-windows-msvc\release\bundle" | |
| ) | |
| $foundBundle = $bundleDirs | Where-Object { Test-Path $_ } | Select-Object -First 1 | |
| if ($foundBundle) { | |
| Write-Host "" | |
| Write-Host "Bundle artifacts:" | |
| Get-ChildItem $foundBundle -Recurse -File | ForEach-Object { | |
| $sizeMB = [math]::Round($_.Length / 1MB, 2) | |
| Write-Host " $($_.Name) ($sizeMB MB)" | |
| } | |
| } | |
| # ─── 9. ARTEFACTOS EN CASO DE FALLO ───────────────────────────────────── | |
| - name: Upload build logs on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-logs-windows-${{ github.run_number }} | |
| path: | | |
| target\**\*.log | |
| target\**\build.log | |
| src-tauri\target\**\*.log | |
| src-tauri\target\**\build.log | |
| retention-days: 7 | |
| if-no-files-found: ignore |