From 0f5ba572b7c67dd1024de7a08d27ade8bc7b1ca0 Mon Sep 17 00:00:00 2001 From: DigHuang <114602213+DigHuang@users.noreply.github.com> Date: Mon, 24 Nov 2025 11:02:02 +0800 Subject: [PATCH 1/3] chore: update macOS build workflow for platform matrix Refactored the GitHub Actions workflow to support a platform matrix, including Windows. MacOS build targets are now commented out, and the workflow runs on the platform specified in the matrix. Also added pull request trigger for the main branch. --- .github/workflows/mac_build.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/mac_build.yml b/.github/workflows/mac_build.yml index ec76bd00f..96194235c 100644 --- a/.github/workflows/mac_build.yml +++ b/.github/workflows/mac_build.yml @@ -4,21 +4,28 @@ on: push: branches: - "release" -permissions: - contents: write + pull_request: + branches: + - "main" jobs: build-macos: strategy: matrix: include: - - args: --target aarch64-apple-darwin - target: 'aarch64-apple-darwin' + # - platform: macos-latest + # args: --target aarch64-apple-darwin + # target: 'aarch64-apple-darwin' - - args: --target x86_64-apple-darwin - target: 'x86_64-apple-darwin' + # - platform: macos-latest + # args: --target x86_64-apple-darwin + # target: 'x86_64-apple-darwin' - runs-on: macos-latest + - platform: windows-latest + args: "" + target: 'windows' + + runs-on: ${{ matrix.platform }} env: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} @@ -109,7 +116,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. - targets: aarch64-apple-darwin,x86_64-apple-darwin + targets: ${{matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin'}} - uses: tauri-apps/tauri-action@v0 env: From 087b753ba53d3f9dbcb0f42c93aad29adc286090 Mon Sep 17 00:00:00 2001 From: DigHuang <114602213+DigHuang@users.noreply.github.com> Date: Mon, 24 Nov 2025 11:08:43 +0800 Subject: [PATCH 2/3] chore: refactor CI workflows for macOS and Windows builds Updated macOS build workflow to remove Windows build steps and streamline matrix configuration. Added a dedicated Windows build workflow with steps for setting up dependencies, downloading UV, and building Tauri app for Windows. This improves separation of platform-specific build logic and simplifies maintenance. --- .github/workflows/mac_build.yml | 23 +++----- .github/workflows/win_build.yml | 100 ++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/win_build.yml diff --git a/.github/workflows/mac_build.yml b/.github/workflows/mac_build.yml index 96194235c..ec76bd00f 100644 --- a/.github/workflows/mac_build.yml +++ b/.github/workflows/mac_build.yml @@ -4,28 +4,21 @@ on: push: branches: - "release" - pull_request: - branches: - - "main" +permissions: + contents: write jobs: build-macos: strategy: matrix: include: - # - platform: macos-latest - # args: --target aarch64-apple-darwin - # target: 'aarch64-apple-darwin' + - args: --target aarch64-apple-darwin + target: 'aarch64-apple-darwin' - # - platform: macos-latest - # args: --target x86_64-apple-darwin - # target: 'x86_64-apple-darwin' + - args: --target x86_64-apple-darwin + target: 'x86_64-apple-darwin' - - platform: windows-latest - args: "" - target: 'windows' - - runs-on: ${{ matrix.platform }} + runs-on: macos-latest env: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} @@ -116,7 +109,7 @@ jobs: uses: dtolnay/rust-toolchain@stable with: # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. - targets: ${{matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin'}} + targets: aarch64-apple-darwin,x86_64-apple-darwin - uses: tauri-apps/tauri-action@v0 env: diff --git a/.github/workflows/win_build.yml b/.github/workflows/win_build.yml new file mode 100644 index 000000000..3af7691fc --- /dev/null +++ b/.github/workflows/win_build.yml @@ -0,0 +1,100 @@ +name: Tauri build on Windows + +on: + push: + branches: + - "release" + pull_request: + branches: + - "main" + +jobs: + build-windows: + strategy: + matrix: + include: + - args: "" + target: 'x86_64-pc-windows-msvc' + + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Add UV Package Manager To Tauri Project + shell: pwsh + run: | + cd frontend/src-tauri + New-Item -ItemType Directory -Force -Path binaries | Out-Null + $ARCH = $env:PROCESSOR_ARCHITECTURE + Write-Host "Current runner architecture: $ARCH" + Write-Host "Matrix target: ${{ matrix.args }}" + + # Download Windows version of uv + $UV_VERSION = "0.9.9" + $UV_ARCH = "x86_64-pc-windows-msvc" + Write-Host "Downloading uv for ${UV_ARCH}..." + + $UV_URL = "https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/uv-${UV_ARCH}.zip" + $UV_ZIP = "uv-${UV_ARCH}.zip" + $TEMP_DIR = "temp_${UV_ARCH}" + + Invoke-WebRequest -Uri $UV_URL -OutFile $UV_ZIP + + # Extract zip file + New-Item -ItemType Directory -Force -Path ${TEMP_DIR} | Out-Null + Expand-Archive -Path $UV_ZIP -DestinationPath ${TEMP_DIR} -Force + + # Find uv.exe after extraction + $UV_PATH = Get-ChildItem -Path ${TEMP_DIR} -Filter "uv.exe" -Recurse | Select-Object -First 1 + if (-not $UV_PATH) { + Write-Host "Error: uv.exe not found for ${UV_ARCH} after extraction" + Write-Host "Contents of ${TEMP_DIR}:" + Get-ChildItem -Path ${TEMP_DIR} -Recurse + exit 1 + } + Write-Host "Found uv at: $($UV_PATH.FullName)" + + # Move uv.exe to binaries directory + Copy-Item $UV_PATH.FullName "binaries/uv-${UV_ARCH}.exe" + + # Clean up + Remove-Item -Recurse -Force ${TEMP_DIR} + Remove-Item -Force $UV_ZIP + + # Debug: List all files in binaries directory + Write-Host "Contents of binaries directory:" + Get-ChildItem -Path binaries -Recurse + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version-file: "./frontend/package.json" + + - name: Install Dependencies + run: | + cd frontend + bun install + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # tagName: v__VERSION__ + # releaseName: ValueCell-${{ matrix.target }}-__VERSION__ + # releaseDraft: true + # prerelease: false + args: ${{ matrix.args }} + + - name: Upload Artifacts + uses: actions/upload-artifact@v5 + with: + path: | + frontend/src-tauri/target/release/bundle/msi/*.msi + frontend/src-tauri/target/release/bundle/nsis/*.exe + name: ValueCell-${{ matrix.target }}-${{ github.sha }} + retention-days: 3 + From f37e0e40923a231f7bba9f1d96f15db347290db7 Mon Sep 17 00:00:00 2001 From: DigHuang <114602213+DigHuang@users.noreply.github.com> Date: Mon, 24 Nov 2025 14:43:42 +0800 Subject: [PATCH 3/3] chore: set stdout encoding to UTF-8 in server main Added code to wrap sys.stdout with UTF-8 encoding to ensure proper output of Unicode characters. This change helps avoid encoding issues when running the ValueCell server backend. --- .github/workflows/win_build.yml | 3 --- python/valuecell/server/main.py | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/win_build.yml b/.github/workflows/win_build.yml index 3af7691fc..bb8ed1b79 100644 --- a/.github/workflows/win_build.yml +++ b/.github/workflows/win_build.yml @@ -4,9 +4,6 @@ on: push: branches: - "release" - pull_request: - branches: - - "main" jobs: build-windows: diff --git a/python/valuecell/server/main.py b/python/valuecell/server/main.py index 4a391231e..54f4b802c 100644 --- a/python/valuecell/server/main.py +++ b/python/valuecell/server/main.py @@ -1,10 +1,15 @@ """Main entry point for ValueCell Server Backend.""" +import io +import sys + import uvicorn from valuecell.server.api.app import create_app from valuecell.server.config.settings import get_settings +# Set stdout encoding to utf-8 +sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8") # Create app instance for uvicorn app = create_app()