From 76f16d863f90aa1165375dbc50a55e0dc0899efe Mon Sep 17 00:00:00 2001 From: donpat1to Date: Tue, 29 Jul 2025 10:42:58 +0200 Subject: [PATCH] buil.yml added --- .github/workflows/build.yml | 105 ++++++++++++++++++++++++++++++++++++ WatcherAgent/Cargo.toml | 6 +++ WatcherAgent/src/main.rs | 3 ++ 3 files changed, 114 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 WatcherAgent/Cargo.toml create mode 100644 WatcherAgent/src/main.rs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a9bf598 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,105 @@ +name: Rust Cross-Platform Build + +on: + workflow_dispatch: + push: + branches: [ "main", "feature-*" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + detect-project: + name: Detect Rust Project + runs-on: ubuntu-latest + outputs: + project-dir: ${{ steps.detect.outputs.project-dir }} + project-name: ${{ steps.detect.outputs.project-name }} + steps: + - uses: actions/checkout@v4 + + - name: Find Cargo.toml + id: detect + run: | + for dir in */; do + if [ -f "$dir/Cargo.toml" ]; then + PROJECT_DIR="$dir" + PROJECT_NAME=$(grep -m1 '^name =' "$dir/Cargo.toml" | cut -d'"' -f2) + echo "project-dir=${PROJECT_DIR%/}" >> $GITHUB_OUTPUT + echo "project-name=${PROJECT_NAME}" >> $GITHUB_OUTPUT + break + fi + done + if [ -z "$PROJECT_DIR" ]; then + echo "No Rust project found!" + exit 1 + fi + + native-build: + name: Native Linux Build + needs: detect-project + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: x86_64-unknown-linux-gnu + profile: minimal + override: true + + - name: Build Linux binary + id: build + working-directory: ${{ needs.detect-project.outputs.project-dir }} + run: | + cargo build --release --target x86_64-unknown-linux-gnu + echo "binary_name=$binary_name" >> $GITHUB_OUTPUT + + - name: Strip debug symbols + working-directory: ${{ needs.detect-project.outputs.project-dir }} + run: strip target/x86_64-unknown-linux-gnu/release/$(grep -m1 '^name =' Cargo.toml | cut -d'"' -f2) + + - name: Upload Linux artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ needs.detect-project.outputs.project-dir }}-linux + path: ${{ needs.detect-project.outputs.project-dir }}/target/x86_64-unknown-linux-gnu/release/${{ steps.build.outputs.binary_name }} + + windows-cross: + name: Windows Cross-Compile + needs: detect-project + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v3 + + - name: Install Rust and Windows target + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: x86_64-pc-windows-gnu + profile: minimal + override: true + + - name: Install mingw cross-compiler + run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64 + + - name: Build Windows binary + working-directory: ${{ needs.detect-project.outputs.project-dir }} + id: build + run: | + cargo build --release --target x86_64-pc-windows-gnu + binary_name=$(grep -m1 '^name =' Cargo.toml | cut -d'"' -f2) + x86_64-w64-mingw32-strip target/x86_64-pc-windows-gnu/release/$binary_name.exe + echo "binary_name=$binary_name" >> $GITHUB_OUTPUT + + - name: Upload Windows artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ needs.detect-project.outputs.project-dir }}-windows + path: ${{ needs.detect-project.outputs.project-dir }}/target/x86_64-pc-windows-gnu/release/${{ steps.build.outputs.binary_name }}.exe \ No newline at end of file diff --git a/WatcherAgent/Cargo.toml b/WatcherAgent/Cargo.toml new file mode 100644 index 0000000..a55dae7 --- /dev/null +++ b/WatcherAgent/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "WatcherAgent" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/WatcherAgent/src/main.rs b/WatcherAgent/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/WatcherAgent/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}