From 9250ff25c3d56f8166fde5f7322ff97ba4ff5047 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Mar 2026 11:55:53 -0700 Subject: [PATCH] Consolidate CI into single release workflow Pushes from within a workflow don't trigger other workflows in Gitea, so the separate tag-triggered build files never ran. Moved all 3 platform build jobs into release.yml with needs: bump-version so they run directly after the version bump, tag, and release creation. Co-Authored-By: Claude Opus 4.6 --- .gitea/workflows/build-linux.yml | 120 ----------- .gitea/workflows/build-macos.yml | 121 ----------- .gitea/workflows/build-windows.yml | 141 ------------- .gitea/workflows/release.yml | 322 ++++++++++++++++++++++++++++- 4 files changed, 320 insertions(+), 384 deletions(-) delete mode 100644 .gitea/workflows/build-linux.yml delete mode 100644 .gitea/workflows/build-macos.yml delete mode 100644 .gitea/workflows/build-windows.yml diff --git a/.gitea/workflows/build-linux.yml b/.gitea/workflows/build-linux.yml deleted file mode 100644 index 7581e7d..0000000 --- a/.gitea/workflows/build-linux.yml +++ /dev/null @@ -1,120 +0,0 @@ -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 diff --git a/.gitea/workflows/build-macos.yml b/.gitea/workflows/build-macos.yml deleted file mode 100644 index fa1e8ff..0000000 --- a/.gitea/workflows/build-macos.yml +++ /dev/null @@ -1,121 +0,0 @@ -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 diff --git a/.gitea/workflows/build-windows.yml b/.gitea/workflows/build-windows.yml deleted file mode 100644 index 1f94d3a..0000000 --- a/.gitea/workflows/build-windows.yml +++ /dev/null @@ -1,141 +0,0 @@ -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}" - } - } diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index f503ac7..67cfb2b 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -10,6 +10,9 @@ jobs: # Skip if this is a version-bump commit (avoid infinite loop) if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-latest + outputs: + new_version: ${{ steps.bump.outputs.new_version }} + tag: ${{ steps.bump.outputs.tag }} steps: - uses: actions/checkout@v4 with: @@ -21,6 +24,7 @@ jobs: git config user.email "actions@gitea.local" - name: Bump patch version + id: bump run: | # Read current version from package.json CURRENT=$(grep '"version"' package.json | head -1 | sed 's/.*"version": *"\([^"]*\)".*/\1/') @@ -46,12 +50,14 @@ jobs: # Update python/pyproject.toml sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" python/pyproject.toml - echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV + echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT + echo "tag=v${NEW_VERSION}" >> $GITHUB_OUTPUT - name: Commit and tag env: BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }} run: | + NEW_VERSION="${{ steps.bump.outputs.new_version }}" 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}" @@ -66,7 +72,7 @@ jobs: BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }} run: | REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" - TAG="v${NEW_VERSION}" + TAG="${{ steps.bump.outputs.tag }}" RELEASE_NAME="Voice to Notes ${TAG}" curl -s -X POST \ @@ -75,3 +81,315 @@ jobs: -d "{\"tag_name\": \"${TAG}\", \"name\": \"${RELEASE_NAME}\", \"body\": \"Automated build.\", \"draft\": false, \"prerelease\": false}" \ "${REPO_API}/releases" echo "Created release: ${RELEASE_NAME}" + + # ── Platform builds (run after version bump) ── + + build-linux: + name: Build (Linux) + needs: bump-version + runs-on: ubuntu-latest + env: + PYTHON_VERSION: "3.11" + NODE_VERSION: "20" + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.bump-version.outputs.tag }} + + # ── 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="${{ needs.bump-version.outputs.tag }}" + RELEASE_NAME="Voice to Notes ${TAG}" + echo "Release tag: ${TAG}" + + RELEASE_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \ + "${REPO_API}/releases/tags/${TAG}" | jq -r '.id // empty') + + if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then + echo "ERROR: Failed to find release for tag ${TAG}." + exit 1 + fi + + echo "Release ID: ${RELEASE_ID}" + + 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 + + build-windows: + name: Build (Windows) + needs: bump-version + runs-on: windows-latest + env: + PYTHON_VERSION: "3.11" + NODE_VERSION: "20" + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.bump-version.outputs.tag }} + + # ── 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 = "${{ needs.bump-version.outputs.tag }}" + $RELEASE_NAME = "Voice to Notes ${TAG}" + Write-Host "Release tag: ${TAG}" + + $release = Invoke-RestMethod -Uri "${REPO_API}/releases/tags/${TAG}" -Headers $Headers -ErrorAction Stop + $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}" + } + } + + build-macos: + name: Build (macOS) + needs: bump-version + runs-on: macos-latest + env: + PYTHON_VERSION: "3.11" + NODE_VERSION: "20" + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.bump-version.outputs.tag }} + + # ── 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: | + which jq || brew install jq + + REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" + + TAG="${{ needs.bump-version.outputs.tag }}" + RELEASE_NAME="Voice to Notes ${TAG}" + echo "Release tag: ${TAG}" + + RELEASE_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \ + "${REPO_API}/releases/tags/${TAG}" | jq -r '.id // empty') + + if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then + echo "ERROR: Failed to find release for tag ${TAG}." + exit 1 + fi + + echo "Release ID: ${RELEASE_ID}" + + 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