From 0bb876915b853e4f79165490489e0d75ac89f47b Mon Sep 17 00:00:00 2001 From: Kirill Date: Mon, 30 Mar 2026 14:42:04 +0300 Subject: [PATCH] ci: Added Ci to github --- .github/workflows/main.yaml | 171 +++++++++++++++++---------------- .github/workflows/release.yaml | 83 ++++++++++++++++ 2 files changed, 169 insertions(+), 85 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 52053f7..8925cd8 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,100 +1,101 @@ -name: Rust CI -on: [push, pull_request] +name: Rust CI (Native Install + Cache) +on: + push: + branches-ignore: + - release + pull_request: + branches-ignore: + - release env: CARGO_TERM_COLOR: always jobs: - check: + build_and_check: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - - name: Verify Rust installation - run: | - rustc --version - cargo --version - - - name: Build - run: cargo check --verbose - - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - - name: Verify Rust installation - run: | - rustc --version - cargo --version - - - name: Build - run: cargo build --verbose + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + run: | + if ! command -v rustc &> /dev/null; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + fi + + - name: Cache Cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + + - name: Cargo Check & Build + run: | + cargo check --verbose + cargo build --verbose test: - needs: [check, build] + needs: build_and_check runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - - name: Verify Rust installation - run: | - rustc --version - cargo --version - - - name: Test - run: cargo test --verbose + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + run: | + if ! command -v rustc &> /dev/null; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + fi + + - name: Cache Cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run Tests + run: cargo test --verbose docs: - needs: [check, build] + needs: build_and_check runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Rust - run: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal - echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - - name: Verify Rust installation - run: | - rustc --version - cargo --version - - - name: Build documentation - run: cargo doc --no-deps --document-private-items - - - name: Create docs directory - run: mkdir -p ./docs-output && cp -r target/doc/* ./docs-output/ - - - name: Upload documentation as artifact - uses: actions/upload-artifact@v4 - with: - name: rust-documentation - path: ./docs-output/ - retention-days: 30 - if-no-files-found: error - + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + run: | + if ! command -v rustc &> /dev/null; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + fi + + - name: Cache Cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Build docs + run: | + cargo doc --no-deps --document-private-items + mkdir -p ./docs-output && cp -r target/doc/* ./docs-output/ + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: rust-documentation + path: ./docs-output/ + retention-days: 7 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..876fc70 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,83 @@ +name: Release Build +on: + push: + branches: + - release + pull_request: + branches: + - release + +env: + CARGO_TERM_COLOR: always + # Название вашего приложения из Cargo.toml + APP_NAME: "UIrclone" + +jobs: + build: + name: Build for ${{ matrix.target }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-gnu + suffix: "" + binary_path: "target/x86_64-unknown-linux-gnu/release" + - target: x86_64-pc-windows-gnu + suffix: ".exe" + binary_path: "target/x86_64-pc-windows-gnu/release" + - target: x86_64-apple-darwin + suffix: "" + binary_path: "target/x86_64-apple-darwin/release" + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install System Dependencies + run: | + sudo apt-get update + # Зависимости для egui/eframe на Linux + sudo apt-get install -y libwayland-dev libxkbcommon-dev libegl1-mesa-dev libgbm-dev + # Инструменты кросс-компиляции + if [[ "${{ matrix.target }}" == *"windows"* ]]; then + sudo apt-get install -y gcc-mingw-w64 + fi + + - name: Install Rust & Target + run: | + if ! command -v rustc &> /dev/null; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + source $HOME/.cargo/env + fi + rustup target add ${{ matrix.target }} + + - name: Cache Cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ matrix.target }}-release-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ matrix.target }}-release- + + - name: Build Binary + run: cargo build --release --target ${{ matrix.target }} + + - name: Prepare Artifact + run: | + mkdir -p ./out + # Копируем бинарник + cp "${{ matrix.binary_path }}/${{ env.APP_NAME }}${{ matrix.suffix }}" ./out/ + # Копируем ассеты (шрифты), так как они нужны приложению в рантайме + cp -r assets ./out/assets + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ env.APP_NAME }}-${{ matrix.target }} + path: ./out/ + retention-days: 5