name: Build & Release on: push: branches: [main] tags: ["v*"] pull_request: branches: [main] env: PYTHON_VERSION: "3.11" NODE_VERSION: "20" jobs: build-sidecar: name: Build sidecar (${{ matrix.target }}) runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: include: - runner: ubuntu-latest target: x86_64-unknown-linux-gnu platform: linux - runner: windows-latest target: x86_64-pc-windows-msvc platform: windows - runner: macos-latest target: aarch64-apple-darwin platform: macos steps: - uses: actions/checkout@v4 - name: Install uv (Unix) if: matrix.platform != 'windows' shell: bash run: | if command -v uv &> /dev/null; then echo "uv already installed: $(uv --version)" else curl -LsSf https://astral.sh/uv/install.sh | sh echo "$HOME/.local/bin" >> $GITHUB_PATH fi - name: Install uv (Windows) if: matrix.platform == 'windows' shell: powershell run: | if (Get-Command uv -ErrorAction SilentlyContinue) { Write-Host "uv already installed: $(uv --version)" } else { irm https://astral.sh/uv/install.ps1 | iex echo "$env:USERPROFILE\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append } - name: Install ffmpeg (macOS) if: matrix.platform == 'macos' run: brew install ffmpeg - name: Install ffmpeg (Linux) if: matrix.platform == 'linux' run: sudo apt-get update && sudo apt-get install -y ffmpeg - name: Install ffmpeg (Windows) if: matrix.platform == 'windows' shell: powershell run: choco install ffmpeg -y - name: Set up Python (Unix) if: matrix.platform != 'windows' run: uv python install ${{ env.PYTHON_VERSION }} - name: Set up Python (Windows) if: matrix.platform == 'windows' shell: powershell run: uv python install ${{ env.PYTHON_VERSION }} - name: Build sidecar (Unix) if: matrix.platform != 'windows' working-directory: python run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --cpu-only - name: Build sidecar (Windows) if: matrix.platform == 'windows' shell: powershell working-directory: python run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --cpu-only - name: Upload sidecar artifact uses: actions/upload-artifact@v3 with: name: sidecar-${{ matrix.target }} path: python/dist/voice-to-notes-sidecar/ retention-days: 7 build-tauri: name: Build app (${{ matrix.target }}) needs: build-sidecar runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: include: - runner: ubuntu-latest target: x86_64-unknown-linux-gnu platform: linux - runner: windows-latest target: x86_64-pc-windows-msvc platform: windows - runner: macos-latest target: aarch64-apple-darwin platform: macos steps: - uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} - name: Install Rust stable uses: dtolnay/rust-toolchain@stable - name: Install system dependencies (Linux) if: matrix.platform == 'linux' run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf - name: Install system dependencies (macOS) if: matrix.platform == 'macos' run: | brew install --quiet create-dmg || true - name: Download sidecar artifact uses: actions/download-artifact@v3 with: name: sidecar-${{ matrix.target }} path: src-tauri/binaries/ - name: Make sidecar executable (Unix) if: matrix.platform != 'windows' run: chmod +x src-tauri/binaries/voice-to-notes-sidecar-${{ matrix.target }} - name: Install npm dependencies run: npm ci - name: Build Tauri app run: npm run tauri build env: TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} TAURI_CONFIG: '{"bundle":{"externalBin":["binaries/voice-to-notes-sidecar"]}}' - name: Upload app artifacts (Linux) if: matrix.platform == 'linux' uses: actions/upload-artifact@v3 with: name: app-${{ matrix.target }} path: | src-tauri/target/release/bundle/deb/*.deb src-tauri/target/release/bundle/appimage/*.AppImage retention-days: 30 - name: Upload app artifacts (Windows) if: matrix.platform == 'windows' uses: actions/upload-artifact@v3 with: name: app-${{ matrix.target }} path: | src-tauri/target/release/bundle/msi/*.msi src-tauri/target/release/bundle/nsis/*.exe retention-days: 30 - name: Upload app artifacts (macOS) if: matrix.platform == 'macos' uses: actions/upload-artifact@v3 with: name: app-${{ matrix.target }} path: | src-tauri/target/release/bundle/dmg/*.dmg src-tauri/target/release/bundle/macos/*.app retention-days: 30 release: name: Create Release needs: build-tauri if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install required tools run: | sudo apt-get update sudo apt-get install -y jq curl - name: Download all app artifacts uses: actions/download-artifact@v3 with: path: artifacts/ - name: Generate release tag id: tag run: echo "tag=build-$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT - name: Create release env: BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }} TAG: ${{ steps.tag.outputs.tag }} run: | # Create the release RELEASE_ID=$(curl -s -X POST \ -H "Authorization: token ${BUILD_TOKEN}" \ -H "Content-Type: application/json" \ -d "{\"tag_name\": \"${TAG}\", \"name\": \"Voice to Notes ${TAG}\", \"body\": \"Automated build from main branch.\", \"draft\": false, \"prerelease\": true}" \ "${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases" | jq -r '.id') echo "Release ID: ${RELEASE_ID}" if [ "${RELEASE_ID}" = "null" ] || [ -z "${RELEASE_ID}" ]; then echo "ERROR: Failed to create release. Check BUILD_TOKEN permissions." exit 1 fi # Upload all artifacts find artifacts/ -type f \( -name "*.deb" -o -name "*.AppImage" -o -name "*.msi" -o -name "*.exe" -o -name "*.dmg" \) | while read file; do filename=$(basename "$file") echo "Uploading ${filename}..." curl -s -X POST \ -H "Authorization: token ${BUILD_TOKEN}" \ -H "Content-Type: application/octet-stream" \ --data-binary "@${file}" \ "${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${filename}" done