Build & Release #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Release | |
| # Runs when you push a version tag like v0.5.0 | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| # Allow the workflow to create GitHub Releases | |
| permissions: | |
| contents: write | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| label: win-x64 | |
| - platform: macos-latest | |
| target: aarch64-apple-darwin | |
| label: mac-arm64 | |
| - platform: macos-13 | |
| target: x86_64-apple-darwin | |
| label: mac-x64 | |
| - platform: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| label: linux-x64 | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # --- System dependencies (Linux only) --- | |
| - name: Install Linux dependencies | |
| if: matrix.platform == 'ubuntu-22.04' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libwebkit2gtk-4.1-dev \ | |
| libappindicator3-dev \ | |
| librsvg2-dev \ | |
| patchelf \ | |
| libgtk-3-dev \ | |
| libsoup-3.0-dev \ | |
| libjavascriptcoregtk-4.1-dev | |
| # --- Node.js --- | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install npm dependencies | |
| run: npm ci | |
| # --- Rust --- | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache Rust build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| src-tauri/target | |
| key: ${{ matrix.target }}-cargo-${{ hashFiles('src-tauri/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ matrix.target }}-cargo- | |
| # --- Build --- | |
| - name: Build Tauri app | |
| uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tagName: ${{ github.ref_name }} | |
| releaseName: "Video Analytics ${{ github.ref_name }}" | |
| releaseBody: | | |
| ## Downloads | |
| **Try it first (no install needed):** | |
| Download the portable zip for your platform, extract, and run. | |
| **Or install:** | |
| Download the installer for a full installation. | |
| | Platform | Portable (no install) | Installer | | |
| |----------|-----------------------|-----------| | |
| | Windows | `*-portable-win-x64.zip` | `*-setup.exe` | | |
| | macOS (Apple Silicon) | `*-portable-mac-arm64.zip` | `.dmg` | | |
| | macOS (Intel) | `*-portable-mac-x64.zip` | `.dmg` | | |
| | Linux | `*-portable-linux-x64.zip` | `.deb` / `.AppImage` | | |
| ### Data location | |
| - **Windows**: `%APPDATA%\com.pc-video-analytics.desktop\` | |
| - **macOS**: `~/Library/Application Support/com.pc-video-analytics.desktop/` | |
| - **Linux**: `~/.local/share/com.pc-video-analytics.desktop/` | |
| releaseDraft: true | |
| prerelease: false | |
| args: --target ${{ matrix.target }} | |
| # --- Create portable zip --- | |
| - name: Create portable zip (Windows) | |
| if: matrix.platform == 'windows-latest' | |
| shell: pwsh | |
| run: | | |
| $version = "${{ github.ref_name }}".TrimStart("v") | |
| $exeDir = "src-tauri/target/${{ matrix.target }}/release" | |
| $exe = Get-ChildItem $exeDir -Filter "*.exe" | | |
| Where-Object { $_.Name -notmatch "build-script|xtask" } | | |
| Select-Object -First 1 | |
| $outDir = "portable" | |
| New-Item -ItemType Directory -Path $outDir -Force | Out-Null | |
| Copy-Item $exe.FullName (Join-Path $outDir "Video Analytics.exe") | |
| @" | |
| Video Analytics $version - Portable Edition | |
| ============================================= | |
| Double-click "Video Analytics.exe" to launch. | |
| Requires Windows 10 (1803+) or Windows 11 with WebView2. | |
| Data stored in: %APPDATA%\com.pc-video-analytics.desktop\ | |
| "@ | Out-File (Join-Path $outDir "README.txt") -Encoding UTF8 | |
| $zipName = "VideoAnalytics-${version}-portable-${{ matrix.label }}.zip" | |
| Compress-Archive -Path "$outDir/*" -DestinationPath $zipName | |
| echo "PORTABLE_ZIP=$zipName" >> $env:GITHUB_ENV | |
| - name: Create portable zip (macOS) | |
| if: startsWith(matrix.platform, 'macos') | |
| run: | | |
| version="${{ github.ref_name }}" | |
| version="${version#v}" | |
| exe="src-tauri/target/${{ matrix.target }}/release/pc-video-analytics" | |
| if [ ! -f "$exe" ]; then | |
| exe=$(find "src-tauri/target/${{ matrix.target }}/release" -maxdepth 1 -type f -perm +111 ! -name "*.d" ! -name "build-script*" | head -1) | |
| fi | |
| outdir="portable" | |
| mkdir -p "$outdir" | |
| cp "$exe" "$outdir/Video Analytics" | |
| chmod +x "$outdir/Video Analytics" | |
| cat > "$outdir/README.txt" << EOF | |
| Video Analytics $version - Portable Edition | |
| ============================================= | |
| Run "./Video Analytics" from Terminal, or double-click. | |
| Requires macOS 10.15+. | |
| Data stored in: ~/Library/Application Support/com.pc-video-analytics.desktop/ | |
| EOF | |
| zipname="VideoAnalytics-${version}-portable-${{ matrix.label }}.zip" | |
| cd "$outdir" && zip -r "../$zipname" . && cd .. | |
| echo "PORTABLE_ZIP=$zipname" >> $GITHUB_ENV | |
| - name: Create portable zip (Linux) | |
| if: matrix.platform == 'ubuntu-22.04' | |
| run: | | |
| version="${{ github.ref_name }}" | |
| version="${version#v}" | |
| exe="src-tauri/target/${{ matrix.target }}/release/pc-video-analytics" | |
| if [ ! -f "$exe" ]; then | |
| exe=$(find "src-tauri/target/${{ matrix.target }}/release" -maxdepth 1 -type f -executable ! -name "*.d" ! -name "build-script*" | head -1) | |
| fi | |
| outdir="portable" | |
| mkdir -p "$outdir" | |
| cp "$exe" "$outdir/video-analytics" | |
| chmod +x "$outdir/video-analytics" | |
| cat > "$outdir/README.txt" << EOF | |
| Video Analytics $version - Portable Edition | |
| ============================================= | |
| Run: ./video-analytics | |
| Requires: libwebkit2gtk-4.1-0, libgtk-3-0 | |
| Data stored in: ~/.local/share/com.pc-video-analytics.desktop/ | |
| EOF | |
| zipname="VideoAnalytics-${version}-portable-${{ matrix.label }}.zip" | |
| cd "$outdir" && zip -r "../$zipname" . && cd .. | |
| echo "PORTABLE_ZIP=$zipname" >> $GITHUB_ENV | |
| - name: Upload portable zip to release | |
| if: env.PORTABLE_ZIP != '' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ${{ env.PORTABLE_ZIP }} | |
| draft: true | |
| tag_name: ${{ github.ref_name }} |