name: Universal CI/CD Release Matrix on: push: tags: - "v*" workflow_dispatch: permissions: contents: write jobs: publish-release-matrix: name: Release for ${{ matrix.target }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: # ========================================== # 🏁 WINDOWS ECOSYSTEM # ========================================== - os: windows-latest target: x86_64-pc-windows-msvc artifact_name: ostp.exe release_name: ostp-windows-amd64.zip tun2socks_arch: windows-amd64 wintun_arch: amd64 - os: windows-latest target: i686-pc-windows-msvc artifact_name: ostp.exe release_name: ostp-windows-386.zip tun2socks_arch: windows-386 wintun_arch: x86 - os: windows-latest target: aarch64-pc-windows-msvc artifact_name: ostp.exe release_name: ostp-windows-arm64.zip tun2socks_arch: windows-arm64 wintun_arch: arm64 # ========================================== # 🍏 APPLE DARWIN (macOS) # ========================================== - os: macos-latest target: x86_64-apple-darwin artifact_name: ostp release_name: ostp-darwin-amd64.tar.gz tun2socks_arch: darwin-amd64 - os: macos-latest target: aarch64-apple-darwin artifact_name: ostp release_name: ostp-darwin-arm64.tar.gz tun2socks_arch: darwin-arm64 # ========================================== # 🐧 LINUX & FreeBSD STANDARD # ========================================== - os: ubuntu-latest target: x86_64-unknown-linux-musl artifact_name: ostp release_name: ostp-linux-amd64.tar.gz tun2socks_arch: linux-amd64 - os: ubuntu-latest target: i686-unknown-linux-musl artifact_name: ostp release_name: ostp-linux-386.tar.gz tun2socks_arch: linux-386 - os: ubuntu-latest target: aarch64-unknown-linux-musl artifact_name: ostp release_name: ostp-linux-arm64.tar.gz tun2socks_arch: linux-arm64 use_cross: true - os: ubuntu-latest target: armv7-unknown-linux-musleabihf artifact_name: ostp release_name: ostp-linux-armv7.tar.gz tun2socks_arch: linux-armv7 use_cross: true - os: ubuntu-latest target: x86_64-unknown-freebsd artifact_name: ostp release_name: ostp-freebsd-amd64.tar.gz tun2socks_arch: freebsd-amd64 use_cross: true # ========================================== # 🛰️ ROUTER & SPECIAL ARCHITECTURES (Cross) # ========================================== - os: ubuntu-latest target: mipsel-unknown-linux-musl artifact_name: ostp release_name: ostp-linux-mipsle.tar.gz tun2socks_arch: linux-mipsle-softfloat use_cross: true toolchain: nightly - os: ubuntu-latest target: riscv64gc-unknown-linux-gnu artifact_name: ostp release_name: ostp-linux-riscv64.tar.gz tun2socks_arch: linux-riscv64 use_cross: true # ========================================== # 🤖 MOBILE & EMBEDDED SUITE (Cross) # ========================================== - os: ubuntu-latest target: aarch64-linux-android artifact_name: ostp release_name: ostp-android-arm64.tar.gz tun2socks_arch: linux-arm64 use_cross: true steps: - name: Checkout code uses: actions/checkout@v4 - name: Initialize Rust ecosystem (Native Host) if: ${{ !matrix.use_cross }} uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.toolchain || 'stable' }} targets: ${{ matrix.target }} - name: Initialize Rust ecosystem (Cross Container Host) if: ${{ matrix.use_cross }} uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.toolchain || 'stable' }} - name: Activate rust compilation caching if: ${{ !matrix.use_cross }} uses: swatinem/rust-cache@v2 - name: Setup local MUSL linker dependencies if: ${{ matrix.os == 'ubuntu-latest' && !matrix.use_cross }} run: sudo apt-get update && sudo apt-get install -y musl-tools - name: Pre-flight compilation check if: ${{ !matrix.use_cross }} shell: bash run: | cargo check --target ${{ matrix.target }} --bin ostp 2>&1 echo "Pre-flight check passed." - name: Execute Standard Native Compilation (Windows) if: ${{ !matrix.use_cross && matrix.os == 'windows-latest' }} run: | cargo build --release --target ${{ matrix.target }} --bin ostp - name: Execute Standard Native Compilation (Unix) if: ${{ !matrix.use_cross && matrix.os != 'windows-latest' }} shell: bash run: | cargo build --release --target ${{ matrix.target }} --bin ostp - name: Execute Specialized Cross-Compilation if: ${{ matrix.use_cross }} run: | cargo install cross --git https://github.com/cross-rs/cross.git cross build --release --target ${{ matrix.target }} --bin ostp - name: Inject Win32 Driver Dependencies (Windows) if: ${{ matrix.os == 'windows-latest' && matrix.tun2socks_arch }} shell: pwsh run: | cd target/${{ matrix.target }}/release $ProgressPreference = 'SilentlyContinue' # 1. Acquire tun2socks Invoke-WebRequest -Uri "https://github.com/xjasonlyu/tun2socks/releases/download/v2.6.0/tun2socks-${{ matrix.tun2socks_arch }}.zip" -OutFile "tun2socks.zip" Expand-Archive -Path "tun2socks.zip" -DestinationPath "tun_temp" -Force Get-ChildItem -Path "tun_temp" -Filter "*.exe" -Recurse | Copy-Item -Destination "tun2socks.exe" -Force # 2. Acquire wintun Invoke-WebRequest -Uri "https://www.wintun.net/builds/wintun-0.14.1.zip" -OutFile "wintun.zip" Expand-Archive -Path "wintun.zip" -DestinationPath "wintun_temp" -Force Get-ChildItem -Path "wintun_temp" -Filter "wintun.dll" -Recurse | Where-Object { $_.FullName -match 'bin[\\/]${{ matrix.wintun_arch }}[\\/]' } | Copy-Item -Destination "." -Force # Cleanup Remove-Item "tun2socks.zip", "tun_temp", "wintun.zip", "wintun_temp" -Recurse -Force - name: Inject Unix Driver Dependencies (Unix) if: ${{ matrix.os != 'windows-latest' && matrix.tun2socks_arch }} shell: bash run: | cd target/${{ matrix.target }}/release # All platforms in tun2socks v2.6.0 use .zip packaging URL="https://github.com/xjasonlyu/tun2socks/releases/download/v2.6.0/tun2socks-${{ matrix.tun2socks_arch }}.zip" curl -f -L "$URL" -o "tun2socks.zip" || { echo "Failed to download tun2socks"; exit 0; } unzip -o "tun2socks.zip" find . -maxdepth 2 -name "tun2socks*" ! -name "*.zip" -type f -exec mv {} ./tun2socks \; rm -f "tun2socks.zip" chmod +x tun2socks || true - name: Package release artifact (Windows) if: ${{ matrix.os == 'windows-latest' }} shell: pwsh run: | cd target/${{ matrix.target }}/release $files = @("ostp.exe") if (Test-Path "tun2socks.exe") { $files += "tun2socks.exe" } if (Test-Path "wintun.dll") { $files += "wintun.dll" } Compress-Archive -Path $files -DestinationPath ../../../${{ matrix.release_name }} -Force - name: Package release artifact (Unix Systems) if: ${{ matrix.os != 'windows-latest' }} run: | cd target/${{ matrix.target }}/release FILES="${{ matrix.artifact_name }}" if [ -f "tun2socks" ]; then FILES="$FILES tun2socks" fi tar -czf ../../../${{ matrix.release_name }} $FILES - name: Inject artifact to Global GitHub Release Assets if: ${{ startsWith(github.ref, 'refs/tags/') }} uses: softprops/action-gh-release@v2 with: files: ${{ matrix.release_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # ========================================== # Windows GUI (Tauri) Build # ========================================== publish-gui: name: GUI for Windows ${{ matrix.arch_label }} runs-on: windows-latest strategy: fail-fast: false matrix: include: - target: x86_64-pc-windows-msvc arch_label: x64 tun2socks_arch: windows-amd64 wintun_arch: amd64 - target: aarch64-pc-windows-msvc arch_label: arm64 tun2socks_arch: windows-arm64 wintun_arch: arm64 steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Rust uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Activate Rust caching uses: swatinem/rust-cache@v2 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 20 - name: Install Tauri CLI run: cargo install tauri-cli --version "^2" - name: Build Tauri application shell: pwsh run: | cd ostp-gui cargo tauri build --target ${{ matrix.target }} - name: Package GUI release shell: pwsh run: | $ProgressPreference = 'SilentlyContinue' $dist = "ostp-gui-dist" New-Item -ItemType Directory -Force -Path $dist # 1. Copy the Tauri executable $exePath = Get-ChildItem -Path "ostp-gui/src-tauri/target/${{ matrix.target }}/release" -Filter "ostp-gui.exe" | Select-Object -First 1 Copy-Item $exePath.FullName -Destination "$dist/ostp-gui.exe" # 2. Download tun2socks Invoke-WebRequest -Uri "https://github.com/xjasonlyu/tun2socks/releases/download/v2.6.0/tun2socks-${{ matrix.tun2socks_arch }}.zip" -OutFile "tun2socks.zip" Expand-Archive -Path "tun2socks.zip" -DestinationPath "tun_temp" -Force Get-ChildItem -Path "tun_temp" -Filter "*.exe" -Recurse | Copy-Item -Destination "$dist/tun2socks.exe" -Force # 3. Download wintun Invoke-WebRequest -Uri "https://www.wintun.net/builds/wintun-0.14.1.zip" -OutFile "wintun.zip" Expand-Archive -Path "wintun.zip" -DestinationPath "wintun_temp" -Force Get-ChildItem -Path "wintun_temp" -Filter "wintun.dll" -Recurse | Where-Object { $_.FullName -match 'bin[\\/]${{ matrix.wintun_arch }}[\\/]' } | Copy-Item -Destination "$dist/wintun.dll" -Force # 4. Create zip archive Compress-Archive -Path "$dist/*" -DestinationPath "ostp-windows-gui-${{ matrix.arch_label }}.zip" -Force # Cleanup Remove-Item "tun2socks.zip", "tun_temp", "wintun.zip", "wintun_temp", $dist -Recurse -Force - name: Upload GUI artifact to release if: ${{ startsWith(github.ref, 'refs/tags/') }} uses: softprops/action-gh-release@v2 with: files: ostp-windows-gui-${{ matrix.arch_label }}.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}