Compare commits
23 Commits
perf/pipel
...
v0.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9033881274 | ||
|
|
1ed34e0bbb | ||
|
|
b7a00af2e0 | ||
|
|
2d0d4cfc50 | ||
|
|
b99613f452 | ||
|
|
ec7e364165 | ||
|
|
a0cb034ab5 | ||
|
|
52d7d06d84 | ||
|
|
462a4b80f6 | ||
|
|
12869e3757 | ||
|
|
bf6fb471d9 | ||
|
|
50baa7284e | ||
|
|
a3c39a2069 | ||
|
|
f023bf02a9 | ||
|
|
caf854ccbb | ||
|
|
b0d566f2d6 | ||
|
|
a65ac439dd | ||
|
|
b8d70539ec | ||
|
|
760b5dc90e | ||
|
|
9cec3c3858 | ||
|
|
4f19ae5287 | ||
|
|
4701b578fc | ||
| 5b7f30c4b2 |
120
.gitea/workflows/build-linux.yml
Normal file
120
.gitea/workflows/build-linux.yml
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
name: Build Linux
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ["v*"]
|
||||||
|
|
||||||
|
env:
|
||||||
|
PYTHON_VERSION: "3.11"
|
||||||
|
NODE_VERSION: "20"
|
||||||
|
TARGET: x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build (Linux)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# ── Python sidecar ──
|
||||||
|
- name: Install uv
|
||||||
|
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 ffmpeg
|
||||||
|
run: sudo apt-get update && sudo apt-get install -y ffmpeg
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
run: uv python install ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
|
- name: Build sidecar
|
||||||
|
working-directory: python
|
||||||
|
run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --cpu-only
|
||||||
|
|
||||||
|
- name: Package sidecar for Tauri
|
||||||
|
run: |
|
||||||
|
cd python/dist/voice-to-notes-sidecar && zip -r ../../../src-tauri/sidecar.zip .
|
||||||
|
|
||||||
|
# ── Tauri app ──
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Rust stable
|
||||||
|
run: |
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
||||||
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils
|
||||||
|
|
||||||
|
- name: Install npm dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Build Tauri app
|
||||||
|
run: npm run tauri build
|
||||||
|
|
||||||
|
# ── Release ──
|
||||||
|
- name: Upload to release
|
||||||
|
env:
|
||||||
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y jq
|
||||||
|
REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||||
|
|
||||||
|
TAG="${GITHUB_REF_NAME}"
|
||||||
|
RELEASE_NAME="Voice to Notes ${TAG}"
|
||||||
|
echo "Release tag: ${TAG}"
|
||||||
|
|
||||||
|
# Wait for release to be created by the release workflow
|
||||||
|
for i in 1 2 3 4 5; do
|
||||||
|
RELEASE_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
"${REPO_API}/releases/tags/${TAG}" | jq -r '.id // empty')
|
||||||
|
if [ -n "${RELEASE_ID}" ] && [ "${RELEASE_ID}" != "null" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Release not found yet, waiting 10s... (attempt $i)"
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
|
||||||
|
# Fallback: create release if it still doesn't exist
|
||||||
|
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
|
||||||
|
RELEASE_ID=$(curl -s -X POST \
|
||||||
|
-H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${RELEASE_NAME}\", \"body\": \"Automated build.\", \"draft\": false, \"prerelease\": false}" \
|
||||||
|
"${REPO_API}/releases" | jq -r '.id')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Release ID: ${RELEASE_ID}"
|
||||||
|
if [ "${RELEASE_ID}" = "null" ] || [ -z "${RELEASE_ID}" ]; then
|
||||||
|
echo "ERROR: Failed to create/find release."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
find src-tauri/target/release/bundle -type f -name "*.deb" | while IFS= read -r file; do
|
||||||
|
filename=$(basename "$file")
|
||||||
|
encoded_name=$(echo "$filename" | sed 's/ /%20/g')
|
||||||
|
echo "Uploading ${filename} ($(du -h "$file" | cut -f1))..."
|
||||||
|
|
||||||
|
ASSET_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
"${REPO_API}/releases/${RELEASE_ID}/assets" | jq -r ".[] | select(.name == \"${filename}\") | .id // empty")
|
||||||
|
if [ -n "${ASSET_ID}" ]; then
|
||||||
|
curl -s -X DELETE -H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
"${REPO_API}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
|
||||||
|
-H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
-T "$file" \
|
||||||
|
"${REPO_API}/releases/${RELEASE_ID}/assets?name=${encoded_name}")
|
||||||
|
echo "Upload response: HTTP ${HTTP_CODE}"
|
||||||
|
done
|
||||||
121
.gitea/workflows/build-macos.yml
Normal file
121
.gitea/workflows/build-macos.yml
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
name: Build macOS
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ["v*"]
|
||||||
|
|
||||||
|
env:
|
||||||
|
PYTHON_VERSION: "3.11"
|
||||||
|
NODE_VERSION: "20"
|
||||||
|
TARGET: aarch64-apple-darwin
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build (macOS)
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# ── Python sidecar ──
|
||||||
|
- name: Install uv
|
||||||
|
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 ffmpeg
|
||||||
|
run: brew install ffmpeg
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
run: uv python install ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
|
- name: Build sidecar
|
||||||
|
working-directory: python
|
||||||
|
run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --cpu-only
|
||||||
|
|
||||||
|
- name: Package sidecar for Tauri
|
||||||
|
run: |
|
||||||
|
cd python/dist/voice-to-notes-sidecar && zip -r ../../../src-tauri/sidecar.zip .
|
||||||
|
|
||||||
|
# ── Tauri app ──
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Rust stable
|
||||||
|
run: |
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
||||||
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: brew install --quiet create-dmg || true
|
||||||
|
|
||||||
|
- name: Install npm dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Build Tauri app
|
||||||
|
run: npm run tauri build
|
||||||
|
|
||||||
|
# ── Release ──
|
||||||
|
- name: Upload to release
|
||||||
|
env:
|
||||||
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||||
|
run: |
|
||||||
|
# Ensure jq is available
|
||||||
|
which jq || brew install jq
|
||||||
|
|
||||||
|
REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||||
|
|
||||||
|
TAG="${GITHUB_REF_NAME}"
|
||||||
|
RELEASE_NAME="Voice to Notes ${TAG}"
|
||||||
|
echo "Release tag: ${TAG}"
|
||||||
|
|
||||||
|
# Wait for release to be created by the release workflow
|
||||||
|
for i in 1 2 3 4 5; do
|
||||||
|
RELEASE_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
"${REPO_API}/releases/tags/${TAG}" | jq -r '.id // empty')
|
||||||
|
if [ -n "${RELEASE_ID}" ] && [ "${RELEASE_ID}" != "null" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Release not found yet, waiting 10s... (attempt $i)"
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
|
||||||
|
# Fallback: create release if it still doesn't exist
|
||||||
|
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
|
||||||
|
RELEASE_ID=$(curl -s -X POST \
|
||||||
|
-H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${RELEASE_NAME}\", \"body\": \"Automated build.\", \"draft\": false, \"prerelease\": false}" \
|
||||||
|
"${REPO_API}/releases" | jq -r '.id')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Release ID: ${RELEASE_ID}"
|
||||||
|
if [ "${RELEASE_ID}" = "null" ] || [ -z "${RELEASE_ID}" ]; then
|
||||||
|
echo "ERROR: Failed to create/find release."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
find src-tauri/target/release/bundle -type f -name "*.dmg" | while IFS= read -r file; do
|
||||||
|
filename=$(basename "$file")
|
||||||
|
encoded_name=$(echo "$filename" | sed 's/ /%20/g')
|
||||||
|
echo "Uploading ${filename} ($(du -h "$file" | cut -f1))..."
|
||||||
|
|
||||||
|
ASSET_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
"${REPO_API}/releases/${RELEASE_ID}/assets" | jq -r ".[] | select(.name == \"${filename}\") | .id // empty")
|
||||||
|
if [ -n "${ASSET_ID}" ]; then
|
||||||
|
curl -s -X DELETE -H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
"${REPO_API}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
|
||||||
|
-H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
-H "Content-Type: application/octet-stream" \
|
||||||
|
-T "$file" \
|
||||||
|
"${REPO_API}/releases/${RELEASE_ID}/assets?name=${encoded_name}")
|
||||||
|
echo "Upload response: HTTP ${HTTP_CODE}"
|
||||||
|
done
|
||||||
141
.gitea/workflows/build-windows.yml
Normal file
141
.gitea/workflows/build-windows.yml
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
name: Build Windows
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ["v*"]
|
||||||
|
|
||||||
|
env:
|
||||||
|
PYTHON_VERSION: "3.11"
|
||||||
|
NODE_VERSION: "20"
|
||||||
|
TARGET: x86_64-pc-windows-msvc
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build (Windows)
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# ── Python sidecar ──
|
||||||
|
- name: Install uv
|
||||||
|
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
|
||||||
|
shell: powershell
|
||||||
|
run: choco install ffmpeg -y
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
shell: powershell
|
||||||
|
run: uv python install ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
|
- name: Build sidecar
|
||||||
|
shell: powershell
|
||||||
|
working-directory: python
|
||||||
|
run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --cpu-only
|
||||||
|
|
||||||
|
- name: Package sidecar for Tauri
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
Compress-Archive -Path python\dist\voice-to-notes-sidecar\* -DestinationPath src-tauri\sidecar.zip
|
||||||
|
|
||||||
|
# ── Tauri app ──
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install Rust stable
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
if (Get-Command rustup -ErrorAction SilentlyContinue) {
|
||||||
|
rustup default stable
|
||||||
|
} else {
|
||||||
|
Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
|
||||||
|
.\rustup-init.exe -y --default-toolchain stable
|
||||||
|
echo "$env:USERPROFILE\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Install npm dependencies
|
||||||
|
shell: powershell
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Build Tauri app
|
||||||
|
shell: powershell
|
||||||
|
run: npm run tauri build
|
||||||
|
|
||||||
|
# ── Release ──
|
||||||
|
- name: Upload to release
|
||||||
|
shell: powershell
|
||||||
|
env:
|
||||||
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||||
|
run: |
|
||||||
|
$REPO_API = "${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
|
||||||
|
$Headers = @{ "Authorization" = "token $env:BUILD_TOKEN" }
|
||||||
|
|
||||||
|
$TAG = "${{ github.ref_name }}"
|
||||||
|
$RELEASE_NAME = "Voice to Notes ${TAG}"
|
||||||
|
Write-Host "Release tag: ${TAG}"
|
||||||
|
|
||||||
|
# Wait for release to be created by the release workflow
|
||||||
|
$RELEASE_ID = $null
|
||||||
|
for ($i = 1; $i -le 5; $i++) {
|
||||||
|
try {
|
||||||
|
$release = Invoke-RestMethod -Uri "${REPO_API}/releases/tags/${TAG}" -Headers $Headers -ErrorAction Stop
|
||||||
|
$RELEASE_ID = $release.id
|
||||||
|
break
|
||||||
|
} catch {
|
||||||
|
Write-Host "Release not found yet, waiting 10s... (attempt $i)"
|
||||||
|
Start-Sleep -Seconds 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fallback: create release if it still doesn't exist
|
||||||
|
if (-not $RELEASE_ID) {
|
||||||
|
$body = @{
|
||||||
|
tag_name = $TAG
|
||||||
|
name = $RELEASE_NAME
|
||||||
|
body = "Automated build."
|
||||||
|
draft = $false
|
||||||
|
prerelease = $false
|
||||||
|
} | ConvertTo-Json
|
||||||
|
$release = Invoke-RestMethod -Uri "${REPO_API}/releases" -Method Post -Headers $Headers -ContentType "application/json" -Body $body
|
||||||
|
$RELEASE_ID = $release.id
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Release ID: ${RELEASE_ID}"
|
||||||
|
|
||||||
|
Get-ChildItem -Path src-tauri\target\release\bundle -Recurse -Include *.msi,*-setup.exe | ForEach-Object {
|
||||||
|
$filename = $_.Name
|
||||||
|
$encodedName = [System.Uri]::EscapeDataString($filename)
|
||||||
|
$size = [math]::Round($_.Length / 1MB, 1)
|
||||||
|
Write-Host "Uploading ${filename} (${size} MB)..."
|
||||||
|
|
||||||
|
try {
|
||||||
|
$assets = Invoke-RestMethod -Uri "${REPO_API}/releases/${RELEASE_ID}/assets" -Headers $Headers
|
||||||
|
$existing = $assets | Where-Object { $_.name -eq $filename }
|
||||||
|
if ($existing) {
|
||||||
|
Invoke-RestMethod -Uri "${REPO_API}/releases/${RELEASE_ID}/assets/$($existing.id)" -Method Delete -Headers $Headers
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
# Use curl for streaming upload (Invoke-RestMethod fails on large files)
|
||||||
|
$uploadUrl = "${REPO_API}/releases/${RELEASE_ID}/assets?name=${encodedName}"
|
||||||
|
$result = curl.exe --fail --silent --show-error `
|
||||||
|
-X POST `
|
||||||
|
-H "Authorization: token $env:BUILD_TOKEN" `
|
||||||
|
-H "Content-Type: application/octet-stream" `
|
||||||
|
--data-binary "@$($_.FullName)" `
|
||||||
|
"$uploadUrl" 2>&1
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
Write-Host "Upload successful: ${filename}"
|
||||||
|
} else {
|
||||||
|
Write-Host "WARNING: Upload failed for ${filename}: ${result}"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
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: Set up Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: ${{ env.PYTHON_VERSION }}
|
|
||||||
env:
|
|
||||||
AGENT_TOOLSDIRECTORY: ${{ runner.temp }}/toolcache
|
|
||||||
|
|
||||||
- name: Install Python build tools
|
|
||||||
run: python -m pip install --upgrade pip setuptools wheel
|
|
||||||
|
|
||||||
- name: Build sidecar
|
|
||||||
working-directory: python
|
|
||||||
run: 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
|
|
||||||
77
.gitea/workflows/release.yml
Normal file
77
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bump-version:
|
||||||
|
name: Bump version and tag
|
||||||
|
# Skip if this is a version-bump commit (avoid infinite loop)
|
||||||
|
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "Gitea Actions"
|
||||||
|
git config user.email "actions@gitea.local"
|
||||||
|
|
||||||
|
- name: Bump patch version
|
||||||
|
run: |
|
||||||
|
# Read current version from package.json
|
||||||
|
CURRENT=$(grep '"version"' package.json | head -1 | sed 's/.*"version": *"\([^"]*\)".*/\1/')
|
||||||
|
echo "Current version: ${CURRENT}"
|
||||||
|
|
||||||
|
# Increment patch number
|
||||||
|
MAJOR=$(echo "${CURRENT}" | cut -d. -f1)
|
||||||
|
MINOR=$(echo "${CURRENT}" | cut -d. -f2)
|
||||||
|
PATCH=$(echo "${CURRENT}" | cut -d. -f3)
|
||||||
|
NEW_PATCH=$((PATCH + 1))
|
||||||
|
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
|
||||||
|
echo "New version: ${NEW_VERSION}"
|
||||||
|
|
||||||
|
# Update package.json
|
||||||
|
sed -i "s/\"version\": \"${CURRENT}\"/\"version\": \"${NEW_VERSION}\"/" package.json
|
||||||
|
|
||||||
|
# Update src-tauri/tauri.conf.json
|
||||||
|
sed -i "s/\"version\": \"${CURRENT}\"/\"version\": \"${NEW_VERSION}\"/" src-tauri/tauri.conf.json
|
||||||
|
|
||||||
|
# Update src-tauri/Cargo.toml (match version = "x.y.z" in [package] section)
|
||||||
|
sed -i "s/^version = \"${CURRENT}\"/version = \"${NEW_VERSION}\"/" src-tauri/Cargo.toml
|
||||||
|
|
||||||
|
# Update python/pyproject.toml
|
||||||
|
sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" python/pyproject.toml
|
||||||
|
|
||||||
|
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Commit and tag
|
||||||
|
env:
|
||||||
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||||
|
run: |
|
||||||
|
git add package.json src-tauri/tauri.conf.json src-tauri/Cargo.toml python/pyproject.toml
|
||||||
|
git commit -m "chore: bump version to ${NEW_VERSION} [skip ci]"
|
||||||
|
git tag "v${NEW_VERSION}"
|
||||||
|
|
||||||
|
# Push using token for authentication
|
||||||
|
REMOTE_URL=$(git remote get-url origin | sed "s|://|://gitea-actions:${BUILD_TOKEN}@|")
|
||||||
|
git push "${REMOTE_URL}" HEAD:main
|
||||||
|
git push "${REMOTE_URL}" "v${NEW_VERSION}"
|
||||||
|
|
||||||
|
- name: Create Gitea release
|
||||||
|
env:
|
||||||
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||||
|
run: |
|
||||||
|
REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||||
|
TAG="v${NEW_VERSION}"
|
||||||
|
RELEASE_NAME="Voice to Notes ${TAG}"
|
||||||
|
|
||||||
|
curl -s -X POST \
|
||||||
|
-H "Authorization: token ${BUILD_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${RELEASE_NAME}\", \"body\": \"Automated build.\", \"draft\": false, \"prerelease\": false}" \
|
||||||
|
"${REPO_API}/releases"
|
||||||
|
echo "Created release: ${RELEASE_NAME}"
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -50,5 +50,6 @@ Thumbs.db
|
|||||||
# Sidecar build artifacts
|
# Sidecar build artifacts
|
||||||
src-tauri/binaries/*
|
src-tauri/binaries/*
|
||||||
!src-tauri/binaries/.gitkeep
|
!src-tauri/binaries/.gitkeep
|
||||||
|
src-tauri/sidecar.zip
|
||||||
python/dist/
|
python/dist/
|
||||||
python/build/
|
python/build/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "voice-to-notes",
|
"name": "voice-to-notes",
|
||||||
"version": "0.1.0",
|
"version": "0.2.1",
|
||||||
"description": "Desktop app for transcribing audio/video with speaker identification",
|
"description": "Desktop app for transcribing audio/video with speaker identification",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -59,42 +59,72 @@ def get_target_triple() -> str:
|
|||||||
return f"{arch}-unknown-{system}"
|
return f"{arch}-unknown-{system}"
|
||||||
|
|
||||||
|
|
||||||
|
def _has_uv() -> bool:
|
||||||
|
"""Check if uv is available."""
|
||||||
|
try:
|
||||||
|
subprocess.run(["uv", "--version"], capture_output=True, check=True)
|
||||||
|
return True
|
||||||
|
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def create_venv_and_install(cpu_only: bool) -> Path:
|
def create_venv_and_install(cpu_only: bool) -> Path:
|
||||||
"""Create a fresh venv and install dependencies."""
|
"""Create a fresh venv and install dependencies.
|
||||||
|
|
||||||
|
Uses uv if available (much faster), falls back to standard venv + pip.
|
||||||
|
"""
|
||||||
venv_dir = BUILD_DIR / "sidecar-venv"
|
venv_dir = BUILD_DIR / "sidecar-venv"
|
||||||
if venv_dir.exists():
|
if venv_dir.exists():
|
||||||
shutil.rmtree(venv_dir)
|
shutil.rmtree(venv_dir)
|
||||||
|
|
||||||
print(f"[build] Creating venv at {venv_dir}")
|
use_uv = _has_uv()
|
||||||
subprocess.run([sys.executable, "-m", "venv", str(venv_dir)], check=True)
|
|
||||||
|
|
||||||
# Determine python path inside venv — use `python -m pip` instead of
|
if use_uv:
|
||||||
# calling pip directly to avoid permission errors on Windows
|
print(f"[build] Creating venv with uv at {venv_dir}")
|
||||||
|
subprocess.run(
|
||||||
|
["uv", "venv", "--python", f"{sys.version_info.major}.{sys.version_info.minor}",
|
||||||
|
str(venv_dir)],
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
print(f"[build] Creating venv at {venv_dir}")
|
||||||
|
subprocess.run([sys.executable, "-m", "venv", str(venv_dir)], check=True)
|
||||||
|
|
||||||
|
# Determine python path inside venv
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
python = str(venv_dir / "Scripts" / "python")
|
python = str(venv_dir / "Scripts" / "python.exe")
|
||||||
else:
|
else:
|
||||||
python = str(venv_dir / "bin" / "python")
|
python = str(venv_dir / "bin" / "python")
|
||||||
|
|
||||||
def pip_install(*args: str) -> None:
|
def pip_install(*args: str) -> None:
|
||||||
subprocess.run([python, "-m", "pip", *args], check=True)
|
"""Install packages. Pass package names and flags only, not 'install'."""
|
||||||
|
if use_uv:
|
||||||
|
# Use --python with the venv directory (not the python binary) for uv
|
||||||
|
subprocess.run(
|
||||||
|
["uv", "pip", "install", "--python", str(venv_dir), *args],
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
subprocess.run([python, "-m", "pip", "install", *args], check=True)
|
||||||
|
|
||||||
# Upgrade pip
|
if not use_uv:
|
||||||
pip_install("install", "--upgrade", "pip", "setuptools", "wheel")
|
# Upgrade pip (uv doesn't need this)
|
||||||
|
pip_install("--upgrade", "pip", "setuptools", "wheel")
|
||||||
|
|
||||||
# Install torch (CPU-only to avoid bundling ~2GB of CUDA libs)
|
# Install torch (CPU-only to avoid bundling ~2GB of CUDA libs)
|
||||||
if cpu_only:
|
if cpu_only:
|
||||||
print("[build] Installing PyTorch (CPU-only)")
|
print("[build] Installing PyTorch (CPU-only)")
|
||||||
pip_install(
|
pip_install(
|
||||||
"install", "torch", "torchaudio",
|
"torch", "torchaudio",
|
||||||
"--index-url", "https://download.pytorch.org/whl/cpu",
|
"--index-url", "https://download.pytorch.org/whl/cpu",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
print("[build] Installing PyTorch (default, may include CUDA)")
|
print("[build] Installing PyTorch (default, may include CUDA)")
|
||||||
pip_install("install", "torch", "torchaudio")
|
pip_install("torch", "torchaudio")
|
||||||
|
|
||||||
# Install project and dev deps (includes pyinstaller)
|
# Install project and dev deps (includes pyinstaller)
|
||||||
print("[build] Installing project dependencies")
|
print("[build] Installing project dependencies")
|
||||||
pip_install("install", "-e", f"{SCRIPT_DIR}[dev]")
|
pip_install("-e", f"{SCRIPT_DIR}[dev]")
|
||||||
|
|
||||||
return Path(python)
|
return Path(python)
|
||||||
|
|
||||||
@@ -206,10 +236,9 @@ def main() -> None:
|
|||||||
python = create_venv_and_install(cpu_only)
|
python = create_venv_and_install(cpu_only)
|
||||||
output_dir = run_pyinstaller(python)
|
output_dir = run_pyinstaller(python)
|
||||||
download_ffmpeg(output_dir)
|
download_ffmpeg(output_dir)
|
||||||
rename_binary(output_dir, target_triple)
|
|
||||||
|
|
||||||
print(f"\n[build] Done! Sidecar built at: {output_dir}")
|
print(f"\n[build] Done! Sidecar built at: {output_dir}")
|
||||||
print(f"[build] Copy contents to src-tauri/binaries/ for Tauri bundling")
|
print(f"[build] Copy directory to src-tauri/sidecar/ for Tauri resource bundling")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "voice-to-notes"
|
name = "voice-to-notes"
|
||||||
version = "0.1.0"
|
version = "0.2.1"
|
||||||
description = "Python sidecar for Voice to Notes — transcription, diarization, and AI services"
|
description = "Python sidecar for Voice to Notes — transcription, diarization, and AI services"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "voice-to-notes"
|
name = "voice-to-notes"
|
||||||
version = "0.1.0"
|
version = "0.2.1"
|
||||||
description = "Voice to Notes — desktop transcription with speaker identification"
|
description = "Voice to Notes — desktop transcription with speaker identification"
|
||||||
authors = ["Voice to Notes Contributors"]
|
authors = ["Voice to Notes Contributors"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@@ -20,6 +20,7 @@ serde = { version = "1", features = ["derive"] }
|
|||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
rusqlite = { version = "0.31", features = ["bundled"] }
|
rusqlite = { version = "0.31", features = ["bundled"] }
|
||||||
uuid = { version = "1", features = ["v4", "serde"] }
|
uuid = { version = "1", features = ["v4", "serde"] }
|
||||||
|
zip = { version = "2", default-features = false, features = ["deflate"] }
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
tauri-plugin-dialog = "2.6.0"
|
tauri-plugin-dialog = "2.6.0"
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
|
// Ensure sidecar.zip exists so tauri-build doesn't fail.
|
||||||
|
// CI replaces this placeholder with the real PyInstaller sidecar archive.
|
||||||
|
let zip_path = std::path::Path::new("sidecar.zip");
|
||||||
|
if !zip_path.exists() {
|
||||||
|
// Minimal valid zip (empty archive): end-of-central-directory record
|
||||||
|
let empty_zip: [u8; 22] = [
|
||||||
|
0x50, 0x4b, 0x05, 0x06, // EOCD signature
|
||||||
|
0x00, 0x00, // disk number
|
||||||
|
0x00, 0x00, // disk with central dir
|
||||||
|
0x00, 0x00, // entries on this disk
|
||||||
|
0x00, 0x00, // total entries
|
||||||
|
0x00, 0x00, 0x00, 0x00, // central dir size
|
||||||
|
0x00, 0x00, 0x00, 0x00, // central dir offset
|
||||||
|
0x00, 0x00, // comment length
|
||||||
|
];
|
||||||
|
std::fs::write(zip_path, empty_zip).expect("Failed to create placeholder sidecar.zip");
|
||||||
|
}
|
||||||
|
|
||||||
tauri_build::build()
|
tauri_build::build()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,14 @@ pub fn run() {
|
|||||||
.plugin(tauri_plugin_dialog::init())
|
.plugin(tauri_plugin_dialog::init())
|
||||||
.manage(app_state)
|
.manage(app_state)
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
|
// Tell the sidecar manager where Tauri placed bundled resources
|
||||||
|
// and where to extract the sidecar archive
|
||||||
|
if let (Ok(resource_dir), Ok(data_dir)) =
|
||||||
|
(app.path().resource_dir(), app.path().app_local_data_dir())
|
||||||
|
{
|
||||||
|
sidecar::init_dirs(resource_dir, data_dir);
|
||||||
|
}
|
||||||
|
|
||||||
// Set the webview background to match the app's dark theme
|
// Set the webview background to match the app's dark theme
|
||||||
if let Some(window) = app.get_webview_window("main") {
|
if let Some(window) = app.get_webview_window("main") {
|
||||||
let _ = window.set_background_color(Some(Color(10, 10, 35, 255)));
|
let _ = window.set_background_color(Some(Color(10, 10, 35, 255)));
|
||||||
|
|||||||
@@ -2,11 +2,24 @@ pub mod ipc;
|
|||||||
pub mod messages;
|
pub mod messages;
|
||||||
|
|
||||||
use std::io::{BufRead, BufReader, Write};
|
use std::io::{BufRead, BufReader, Write};
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{Child, ChildStdin, Command, Stdio};
|
use std::process::{Child, ChildStdin, Command, Stdio};
|
||||||
use std::sync::{Mutex, OnceLock};
|
use std::sync::{Mutex, OnceLock};
|
||||||
|
|
||||||
use crate::sidecar::messages::IPCMessage;
|
use crate::sidecar::messages::IPCMessage;
|
||||||
|
|
||||||
|
/// Resource directory set by the Tauri app during setup.
|
||||||
|
static RESOURCE_DIR: OnceLock<PathBuf> = OnceLock::new();
|
||||||
|
/// App data directory for extracting the sidecar archive.
|
||||||
|
static DATA_DIR: OnceLock<PathBuf> = OnceLock::new();
|
||||||
|
|
||||||
|
/// Initialize directories for sidecar resolution.
|
||||||
|
/// Must be called from the Tauri setup before any sidecar operations.
|
||||||
|
pub fn init_dirs(resource_dir: PathBuf, data_dir: PathBuf) {
|
||||||
|
RESOURCE_DIR.set(resource_dir).ok();
|
||||||
|
DATA_DIR.set(data_dir).ok();
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the global sidecar manager singleton.
|
/// Get the global sidecar manager singleton.
|
||||||
pub fn sidecar() -> &'static SidecarManager {
|
pub fn sidecar() -> &'static SidecarManager {
|
||||||
static INSTANCE: OnceLock<SidecarManager> = OnceLock::new();
|
static INSTANCE: OnceLock<SidecarManager> = OnceLock::new();
|
||||||
@@ -41,37 +54,131 @@ impl SidecarManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Resolve the frozen sidecar binary path (production mode).
|
/// Resolve the frozen sidecar binary path (production mode).
|
||||||
fn resolve_sidecar_path() -> Result<std::path::PathBuf, String> {
|
///
|
||||||
let exe = std::env::current_exe().map_err(|e| format!("Cannot get current exe: {e}"))?;
|
/// First checks if the sidecar is already extracted to the app data directory.
|
||||||
let exe_dir = exe
|
/// If not, looks for `sidecar.zip` in the Tauri resource directory and extracts it.
|
||||||
.parent()
|
fn resolve_sidecar_path() -> Result<PathBuf, String> {
|
||||||
.ok_or_else(|| "Cannot get exe parent directory".to_string())?;
|
|
||||||
|
|
||||||
let binary_name = if cfg!(target_os = "windows") {
|
let binary_name = if cfg!(target_os = "windows") {
|
||||||
"voice-to-notes-sidecar.exe"
|
"voice-to-notes-sidecar.exe"
|
||||||
} else {
|
} else {
|
||||||
"voice-to-notes-sidecar"
|
"voice-to-notes-sidecar"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tauri places externalBin next to the app binary
|
// Versioned extraction directory prevents stale sidecar after app updates
|
||||||
let path = exe_dir.join(binary_name);
|
let extract_dir = DATA_DIR
|
||||||
if path.exists() {
|
.get()
|
||||||
return Ok(path);
|
.ok_or("App data directory not initialized")?
|
||||||
|
.join(format!("sidecar-{}", env!("CARGO_PKG_VERSION")));
|
||||||
|
|
||||||
|
let binary_path = extract_dir.join(binary_name);
|
||||||
|
|
||||||
|
// Already extracted — use it directly
|
||||||
|
if binary_path.exists() {
|
||||||
|
return Ok(binary_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also check inside a subdirectory (onedir PyInstaller output)
|
// Find sidecar.zip in resource dir or next to exe
|
||||||
let subdir_path = exe_dir.join("voice-to-notes-sidecar").join(binary_name);
|
let zip_path = Self::find_sidecar_zip()?;
|
||||||
if subdir_path.exists() {
|
Self::extract_zip(&zip_path, &extract_dir)?;
|
||||||
return Ok(subdir_path);
|
|
||||||
|
if !binary_path.exists() {
|
||||||
|
return Err(format!(
|
||||||
|
"Sidecar binary not found after extraction at {}",
|
||||||
|
binary_path.display()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make executable on Unix
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
if let Ok(meta) = std::fs::metadata(&binary_path) {
|
||||||
|
let mut perms = meta.permissions();
|
||||||
|
perms.set_mode(0o755);
|
||||||
|
let _ = std::fs::set_permissions(&binary_path, perms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(binary_path)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Locate the bundled sidecar.zip archive.
|
||||||
|
fn find_sidecar_zip() -> Result<PathBuf, String> {
|
||||||
|
let mut candidates: Vec<PathBuf> = Vec::new();
|
||||||
|
|
||||||
|
if let Some(resource_dir) = RESOURCE_DIR.get() {
|
||||||
|
candidates.push(resource_dir.join("sidecar.zip"));
|
||||||
|
}
|
||||||
|
if let Ok(exe) = std::env::current_exe() {
|
||||||
|
if let Some(exe_dir) = exe.parent() {
|
||||||
|
candidates.push(exe_dir.join("sidecar.zip"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for path in &candidates {
|
||||||
|
if path.exists() {
|
||||||
|
return Ok(path.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(format!(
|
Err(format!(
|
||||||
"Sidecar binary not found. Looked for:\n {}\n {}",
|
"Sidecar archive not found. Checked:\n{}",
|
||||||
path.display(),
|
candidates
|
||||||
subdir_path.display(),
|
.iter()
|
||||||
|
.map(|p| format!(" {}", p.display()))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n"),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extract a zip archive to the given directory.
|
||||||
|
fn extract_zip(zip_path: &Path, dest: &Path) -> Result<(), String> {
|
||||||
|
eprintln!(
|
||||||
|
"[sidecar-rs] Extracting sidecar from {} to {}",
|
||||||
|
zip_path.display(),
|
||||||
|
dest.display()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Clean destination so we don't mix old and new files
|
||||||
|
if dest.exists() {
|
||||||
|
std::fs::remove_dir_all(dest)
|
||||||
|
.map_err(|e| format!("Failed to clean extraction dir: {e}"))?;
|
||||||
|
}
|
||||||
|
std::fs::create_dir_all(dest)
|
||||||
|
.map_err(|e| format!("Failed to create extraction dir: {e}"))?;
|
||||||
|
|
||||||
|
let file =
|
||||||
|
std::fs::File::open(zip_path).map_err(|e| format!("Cannot open sidecar zip: {e}"))?;
|
||||||
|
let mut archive =
|
||||||
|
zip::ZipArchive::new(file).map_err(|e| format!("Invalid sidecar zip: {e}"))?;
|
||||||
|
|
||||||
|
for i in 0..archive.len() {
|
||||||
|
let mut entry = archive
|
||||||
|
.by_index(i)
|
||||||
|
.map_err(|e| format!("Zip entry error: {e}"))?;
|
||||||
|
|
||||||
|
let name = entry.name().to_string();
|
||||||
|
let outpath = dest.join(&name);
|
||||||
|
|
||||||
|
if entry.is_dir() {
|
||||||
|
std::fs::create_dir_all(&outpath)
|
||||||
|
.map_err(|e| format!("Cannot create dir {}: {e}", outpath.display()))?;
|
||||||
|
} else {
|
||||||
|
if let Some(parent) = outpath.parent() {
|
||||||
|
std::fs::create_dir_all(parent)
|
||||||
|
.map_err(|e| format!("Cannot create dir {}: {e}", parent.display()))?;
|
||||||
|
}
|
||||||
|
let mut outfile = std::fs::File::create(&outpath)
|
||||||
|
.map_err(|e| format!("Cannot create {}: {e}", outpath.display()))?;
|
||||||
|
std::io::copy(&mut entry, &mut outfile)
|
||||||
|
.map_err(|e| format!("Write error for {}: {e}", name))?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eprintln!("[sidecar-rs] Sidecar extracted successfully");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Find a working Python command for the current platform.
|
/// Find a working Python command for the current platform.
|
||||||
fn find_python_command() -> &'static str {
|
fn find_python_command() -> &'static str {
|
||||||
if cfg!(target_os = "windows") {
|
if cfg!(target_os = "windows") {
|
||||||
@@ -114,15 +221,8 @@ impl SidecarManager {
|
|||||||
if Self::is_dev_mode() {
|
if Self::is_dev_mode() {
|
||||||
self.start_python_dev()
|
self.start_python_dev()
|
||||||
} else {
|
} else {
|
||||||
match Self::resolve_sidecar_path() {
|
let path = Self::resolve_sidecar_path()?;
|
||||||
Ok(path) => self.start_binary(&path),
|
self.start_binary(&path)
|
||||||
Err(e) => {
|
|
||||||
eprintln!(
|
|
||||||
"[sidecar-rs] Frozen binary not found ({e}), falling back to dev mode"
|
|
||||||
);
|
|
||||||
self.start_python_dev()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Voice to Notes",
|
"productName": "Voice to Notes",
|
||||||
"version": "0.1.0",
|
"version": "0.2.1",
|
||||||
"identifier": "com.voicetonotes.app",
|
"identifier": "com.voicetonotes.app",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
},
|
},
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"active": true,
|
"active": true,
|
||||||
"targets": "all",
|
"targets": ["deb", "nsis", "msi", "dmg"],
|
||||||
"icon": [
|
"icon": [
|
||||||
"icons/32x32.png",
|
"icons/32x32.png",
|
||||||
"icons/128x128.png",
|
"icons/128x128.png",
|
||||||
@@ -42,14 +42,12 @@
|
|||||||
"category": "Utility",
|
"category": "Utility",
|
||||||
"shortDescription": "Transcribe audio/video with speaker identification",
|
"shortDescription": "Transcribe audio/video with speaker identification",
|
||||||
"longDescription": "Voice to Notes is a desktop application that transcribes audio and video recordings with speaker identification, synchronized playback, and AI-powered analysis. Export to SRT, WebVTT, ASS captions, or plain text.",
|
"longDescription": "Voice to Notes is a desktop application that transcribes audio and video recordings with speaker identification, synchronized playback, and AI-powered analysis. Export to SRT, WebVTT, ASS captions, or plain text.",
|
||||||
|
"resources": ["sidecar.zip"],
|
||||||
"copyright": "Voice to Notes Contributors",
|
"copyright": "Voice to Notes Contributors",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"linux": {
|
"linux": {
|
||||||
"deb": {
|
"deb": {
|
||||||
"depends": []
|
"depends": []
|
||||||
},
|
|
||||||
"appimage": {
|
|
||||||
"bundleMediaFramework": true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"windows": {
|
"windows": {
|
||||||
|
|||||||
Reference in New Issue
Block a user