diff --git a/.gitea/workflows/build-sidecar-linux.yml b/.gitea/workflows/build-sidecar-linux.yml index c73ed87..e1a413f 100644 --- a/.gitea/workflows/build-sidecar-linux.yml +++ b/.gitea/workflows/build-sidecar-linux.yml @@ -41,10 +41,11 @@ jobs: sudo apt-get install -y portaudio19-dev - name: Build sidecar (CPU) - env: - UV_NO_SOURCES: "1" run: | - uv sync + uv sync --no-sources + # PyPI's default torch on Linux includes CUDA (~800MB). + # Replace with CPU-only torch from the dedicated index. + uv pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu --force-reinstall .venv/bin/pyinstaller local-transcription-headless.spec - name: Package sidecar (CPU) diff --git a/.gitea/workflows/build-sidecar-windows.yml b/.gitea/workflows/build-sidecar-windows.yml index ade356f..3c4ae1c 100644 --- a/.gitea/workflows/build-sidecar-windows.yml +++ b/.gitea/workflows/build-sidecar-windows.yml @@ -56,10 +56,11 @@ jobs: - name: Build sidecar (CPU) shell: powershell - env: - UV_NO_SOURCES: "1" run: | + $env:UV_NO_SOURCES = "1" uv sync + # PyPI's default torch includes CUDA. Replace with CPU-only. + uv pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu --force-reinstall .venv\Scripts\pyinstaller.exe local-transcription-headless.spec - name: Package sidecar (CPU) diff --git a/.gitea/workflows/cleanup-releases.yml b/.gitea/workflows/cleanup-releases.yml new file mode 100644 index 0000000..6fb1b48 --- /dev/null +++ b/.gitea/workflows/cleanup-releases.yml @@ -0,0 +1,102 @@ +name: Cleanup Old Releases + +on: + workflow_dispatch: + inputs: + keep_app_releases: + description: 'Number of app releases to keep' + required: false + default: '3' + keep_sidecar_releases: + description: 'Number of sidecar releases to keep' + required: false + default: '2' + dry_run: + description: 'Dry run (show what would be deleted without deleting)' + required: false + default: 'true' + +jobs: + cleanup: + name: Cleanup Old Releases + runs-on: ubuntu-latest + steps: + - name: Cleanup releases + env: + BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }} + run: | + REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" + KEEP_APP="${{ inputs.keep_app_releases }}" + KEEP_SIDECAR="${{ inputs.keep_sidecar_releases }}" + DRY_RUN="${{ inputs.dry_run }}" + + echo "=== Cleanup Configuration ===" + echo "Keep app releases: ${KEEP_APP}" + echo "Keep sidecar releases: ${KEEP_SIDECAR}" + echo "Dry run: ${DRY_RUN}" + echo "" + + # Fetch all releases + ALL_RELEASES=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \ + "${REPO_API}/releases?limit=50") + + # ── App releases (v* tags, not sidecar-v*) ── + echo "=== App Releases ===" + APP_RELEASES=$(echo "$ALL_RELEASES" | jq -c '[.[] | select(.tag_name | startswith("v")) | select(.tag_name | startswith("sidecar") | not)]') + APP_TOTAL=$(echo "$APP_RELEASES" | jq 'length') + echo "Found ${APP_TOTAL} app releases, keeping ${KEEP_APP}" + + if [ "$APP_TOTAL" -gt "$KEEP_APP" ]; then + echo "$APP_RELEASES" | jq -c ".[$KEEP_APP:][]" | while read -r release; do + ID=$(echo "$release" | jq -r '.id') + TAG=$(echo "$release" | jq -r '.tag_name') + SIZE=$(echo "$release" | jq '[.assets[]?.size // 0] | add // 0') + SIZE_MB=$(echo "scale=1; $SIZE / 1048576" | bc 2>/dev/null || echo "?") + + # Protect v1.4.0 (last pre-Tauri release) + if [ "$TAG" = "v1.4.0" ]; then + echo " PROTECT ${TAG} (${SIZE_MB} MB)" + continue + fi + + if [ "$DRY_RUN" = "true" ]; then + echo " WOULD DELETE ${TAG} (ID: ${ID}, ${SIZE_MB} MB)" + else + echo " DELETING ${TAG} (ID: ${ID}, ${SIZE_MB} MB)..." + curl -s -X DELETE -H "Authorization: token ${BUILD_TOKEN}" \ + "${REPO_API}/releases/${ID}" + fi + done + else + echo " Nothing to clean up" + fi + + echo "" + + # ── Sidecar releases (sidecar-v* tags) ── + echo "=== Sidecar Releases ===" + SIDECAR_RELEASES=$(echo "$ALL_RELEASES" | jq -c '[.[] | select(.tag_name | startswith("sidecar-v"))]') + SIDECAR_TOTAL=$(echo "$SIDECAR_RELEASES" | jq 'length') + echo "Found ${SIDECAR_TOTAL} sidecar releases, keeping ${KEEP_SIDECAR}" + + if [ "$SIDECAR_TOTAL" -gt "$KEEP_SIDECAR" ]; then + echo "$SIDECAR_RELEASES" | jq -c ".[$KEEP_SIDECAR:][]" | while read -r release; do + ID=$(echo "$release" | jq -r '.id') + TAG=$(echo "$release" | jq -r '.tag_name') + SIZE=$(echo "$release" | jq '[.assets[]?.size // 0] | add // 0') + SIZE_MB=$(echo "scale=1; $SIZE / 1048576" | bc 2>/dev/null || echo "?") + + if [ "$DRY_RUN" = "true" ]; then + echo " WOULD DELETE ${TAG} (ID: ${ID}, ${SIZE_MB} MB)" + else + echo " DELETING ${TAG} (ID: ${ID}, ${SIZE_MB} MB)..." + curl -s -X DELETE -H "Authorization: token ${BUILD_TOKEN}" \ + "${REPO_API}/releases/${ID}" + fi + done + else + echo " Nothing to clean up" + fi + + echo "" + echo "=== Done ==="