Update ci.yml #7
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: CI/CD Pipeline | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| tags: ['v*'] | ||
| pull_request: | ||
| branches: [main] | ||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| RUST_BACKTRACE: 1 | ||
| jobs: | ||
| build-and-test: | ||
| name: Build & Test | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-22.04, macos-latest, windows-latest] | ||
| include: | ||
| - os: ubuntu-22.04 | ||
| target: wasm32-unknown-unknown | ||
| platform: web | ||
| - os: macos-latest | ||
| target: x86_64-apple-darwin | ||
| platform: desktop | ||
| - os: windows-latest | ||
| target: x86_64-pc-windows-msvc | ||
| platform: desktop | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Install Rust toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| profile: minimal | ||
| toolchain: stable | ||
| override: true | ||
| target: ${{ matrix.target }} | ||
| - name: Cache dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| opensvm-dioxus/target | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: ${{ runner.os }}-cargo- | ||
| - name: Install Dioxus CLI | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: install | ||
| args: dioxus-cli --force | ||
| - name: Install Linux dependencies | ||
| if: matrix.os == 'ubuntu-22.04' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf | ||
| - name: Install wasm-bindgen-cli | ||
| if: matrix.platform == 'web' | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: install | ||
| args: wasm-bindgen-cli | ||
| - name: Install wasm-opt | ||
| if: matrix.platform == 'web' | ||
| run: | | ||
| if [ "$RUNNER_OS" == "Linux" ]; then | ||
| curl -L https://github.com/WebAssembly/binaryen/releases/download/version_111/binaryen-version_111-x86_64-linux.tar.gz | tar xz | ||
| sudo cp binaryen-version_111/bin/wasm-opt /usr/local/bin/ | ||
| elif [ "$RUNNER_OS" == "macOS" ]; then | ||
| brew install binaryen | ||
| else | ||
| choco install binaryen | ||
| fi | ||
| shell: bash | ||
| - name: Build for Web | ||
| if: matrix.platform == 'web' | ||
| run: | | ||
| cd opensvm-dioxus | ||
| dioxus build --features web --profile wasm-release --platform web --release | ||
| - name: Build for Desktop (macOS/Linux) | ||
| if: matrix.platform == 'desktop' && matrix.os != 'windows-latest' | ||
| run: | | ||
| cd opensvm-dioxus | ||
| RUSTFLAGS="-C target-cpu=native" dioxus build --features desktop --profile desktop-release --platform desktop --release | ||
| shell: bash | ||
| - name: Build for Desktop (Windows) | ||
| if: matrix.platform == 'desktop' && matrix.os == 'windows-latest' | ||
| run: | | ||
| cd opensvm-dioxus | ||
| $env:RUSTFLAGS="-C target-cpu=native" | ||
| dioxus build --features desktop --profile desktop-release --platform desktop --release | ||
| shell: pwsh | ||
| - name: Run tests | ||
| run: | | ||
| cd opensvm-dioxus | ||
| cargo test --all-features | ||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: opensvm-dioxus-${{ matrix.os }}-${{ matrix.platform }} | ||
| path: | | ||
| opensvm-dioxus/dist/ | ||
| release: | ||
| name: Create Release | ||
| needs: build-and-test | ||
| if: startsWith(github.ref](#) | ||
| | ||