buil.yml added
This commit is contained in:
105
.github/workflows/build.yml
vendored
Normal file
105
.github/workflows/build.yml
vendored
Normal file
@@ -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
|
6
WatcherAgent/Cargo.toml
Normal file
6
WatcherAgent/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "WatcherAgent"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
3
WatcherAgent/src/main.rs
Normal file
3
WatcherAgent/src/main.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
Reference in New Issue
Block a user