name: Build and Release on: push: branches: - main - master - develop workflow_dispatch: env: TAURI_VERSION: "2.9.4" jobs: build: permissions: contents: write strategy: fail-fast: false matrix: include: - platform: 'windows-latest' target: 'x86_64-pc-windows-msvc' bundle: 'msi' - platform: 'macos-latest' target: 'aarch64-apple-darwin' bundle: 'dmg' - platform: 'macos-latest' target: 'x86_64-apple-darwin' bundle: 'dmg' - platform: 'ubuntu-latest' target: 'x86_64-unknown-linux-gnu' bundle: 'appimage' runs-on: ${{ matrix.platform }} steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install pnpm uses: pnpm/action-setup@v4 with: version: 9 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'pnpm' - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable targets: ${{ matrix.target }} - name: Rust cache uses: swatinem/rust-cache@v2 with: workspaces: './src-tauri -> target' - name: Install Tauri CLI run: cargo install tauri-cli --version "^2.9" --locked - name: Install dependencies (Ubuntu only) if: matrix.platform == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev patchelf - name: Install frontend dependencies shell: bash run: | if [ -f pnpm-lock.yaml ]; then pnpm install --frozen-lockfile else pnpm install fi - name: Generate changelog run: pnpm generate-changelog - name: Build frontend (Next.js) shell: bash env: NODE_OPTIONS: ${{ matrix.platform == 'macos-latest' && matrix.target == 'aarch64-apple-darwin' && '--max-old-space-size=4096' || '--max-old-space-size=2048' }} run: | echo "Building Next.js frontend with NODE_OPTIONS=${NODE_OPTIONS}" pnpm build if [ ! -d "out" ]; then echo "Error: Frontend build failed - 'out' directory not found" exit 1 fi echo "Frontend build successful - 'out' directory exists" <<<<<<< HEAD - name: Prepare bundle resources (Windows only) if: matrix.platform == 'windows-latest' shell: powershell run: | # Criar diretórios New-Item -ItemType Directory -Force -Path "src-tauri/bundle/ollama" | Out-Null New-Item -ItemType Directory -Force -Path "src-tauri/bundle/models/embeddings" | Out-Null # Baixar instalador do Ollama (se não existir) $ollamaPath = "src-tauri/bundle/ollama/OllamaSetup.exe" if (!(Test-Path $ollamaPath)) { Write-Host "Downloading Ollama installer..." Invoke-WebRequest -Uri "https://ollama.com/download/OllamaSetup.exe" -OutFile $ollamaPath -UseBasicParsing } # Baixar modelos de embeddings (se não existirem) $modelPath = "src-tauri/bundle/models/embeddings/all-MiniLM-L6-v2.onnx" if (!(Test-Path $modelPath)) { Write-Host "Downloading ONNX embedding model (~90MB, this may take a while)..." Invoke-WebRequest -Uri "https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2/resolve/main/onnx/model.onnx" -OutFile $modelPath -UseBasicParsing } $tokenizerPath = "src-tauri/bundle/models/embeddings/tokenizer.json" if (!(Test-Path $tokenizerPath)) { Write-Host "Downloading tokenizer..." Invoke-WebRequest -Uri "https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2/resolve/main/tokenizer.json" -OutFile $tokenizerPath -UseBasicParsing } # Baixar e extrair ONNX Runtime DLL $ortDllPath = "src-tauri/bundle/models/embeddings/onnxruntime.dll" if (!(Test-Path $ortDllPath)) { $ortZipPath = "src-tauri/bundle/models/embeddings/onnxruntime.zip" if (!(Test-Path $ortZipPath)) { Write-Host "Downloading ONNX Runtime library (~50MB)..." Invoke-WebRequest -Uri "https://github.com/microsoft/onnxruntime/releases/download/v1.20.1/onnxruntime-win-x64-1.20.1.zip" -OutFile $ortZipPath -UseBasicParsing } Write-Host "Extracting ONNX Runtime DLL..." Add-Type -AssemblyName System.IO.Compression.FileSystem $zip = [System.IO.Compression.ZipFile]::OpenRead($ortZipPath) foreach ($entry in $zip.Entries) { if ($entry.Name -eq "onnxruntime.dll") { [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $ortDllPath, $true) Write-Host "Extracted onnxruntime.dll" break } } $zip.Dispose() Remove-Item $ortZipPath -ErrorAction SilentlyContinue } Write-Host "Bundle resources prepared successfully" ======= >>>>>>> 593efd42e091a845dea82ee6646e027bce1e18c5 - name: Build Tauri app run: | cd src-tauri cargo build --release --target ${{ matrix.target }} - name: Build Tauri bundle shell: bash env: TAURI_PRIVATE_KEY: ${{ secrets.TAURI_UPDATER_PRIVATE_KEY }} NODE_OPTIONS: ${{ matrix.platform == 'macos-latest' && matrix.target == 'aarch64-apple-darwin' && '--max-old-space-size=4096' || '--max-old-space-size=2048' }} run: | cd src-tauri if [ -n "$TAURI_PRIVATE_KEY" ]; then echo "$TAURI_PRIVATE_KEY" > /tmp/private.key cargo tauri build --target ${{ matrix.target }} --config '{"updater":{"active":true}}' rm /tmp/private.key else cargo tauri build --target ${{ matrix.target }} fi - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: ${{ matrix.platform }}-${{ matrix.target }} path: | src-tauri/target/${{ matrix.target }}/release/bundle/**/*.${{ matrix.bundle }} src-tauri/target/${{ matrix.target }}/release/bundle/**/*.exe src-tauri/target/${{ matrix.target }}/release/bundle/**/*.AppImage src-tauri/target/${{ matrix.target }}/release/bundle/**/*.deb retention-days: 7 create-release: needs: build if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') runs-on: ubuntu-latest permissions: contents: write steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install pnpm uses: pnpm/action-setup@v4 with: version: 9 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'pnpm' - name: Install frontend dependencies shell: bash run: | if [ -f pnpm-lock.yaml ]; then pnpm install --frozen-lockfile else pnpm install fi - name: Get version id: get_version run: | VERSION=$(node -p "require('./package.json').version") echo "version=$VERSION" >> $GITHUB_OUTPUT echo "tag=v$VERSION" >> $GITHUB_OUTPUT - name: Generate changelog for release run: pnpm generate-changelog - name: Download all artifacts uses: actions/download-artifact@v4 with: path: artifacts - name: Extract release notes id: extract_notes shell: bash run: | if [ -f "data/changelog.json" ]; then NOTES=$(node -e " const fs = require('fs'); try { const changelog = JSON.parse(fs.readFileSync('data/changelog.json', 'utf-8')); const latestRelease = changelog.releases[0]; if (latestRelease) { let notes = '## ' + (latestRelease.version === 'unreleased' ? 'Próxima Versão' : 'v' + latestRelease.version) + '\\n\\n'; notes += '**Data:** ' + latestRelease.date + '\\n\\n'; notes += '### Mudanças\\n\\n'; latestRelease.commits.forEach(commit => { const icon = commit.type === 'feat' ? '✨' : '🐛'; notes += '- ' + icon + ' **' + (commit.type === 'feat' ? 'Nova Funcionalidade' : 'Correção') + ':** ' + commit.message + '\\n'; }); console.log(notes); } else { console.log('## Release ${{ steps.get_version.outputs.version }}'); } } catch (e) { console.log('## Release ${{ steps.get_version.outputs.version }}'); } ") echo "notes<> $GITHUB_OUTPUT echo "$NOTES" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT else echo "notes=## Release ${{ steps.get_version.outputs.version }}" >> $GITHUB_OUTPUT fi - name: Create Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.get_version.outputs.tag }} name: Release ${{ steps.get_version.outputs.tag }} body: | ${{ steps.extract_notes.outputs.notes }} ## Downloads Baixe o instalador para sua plataforma nos assets abaixo. draft: false files: artifacts/**/* generate_release_notes: false