From 64ca7021037674ef291f56049dd2b812ec9ca9c7 Mon Sep 17 00:00:00 2001 From: Vomitblood Date: Mon, 15 Jul 2024 14:51:25 +0800 Subject: [PATCH] updated github actions workflow --- .github/workflows/build.yml | 80 +++++++++++++++++++++++++++++++++ .github/workflows/build.yml.bak | 57 ----------------------- .github/workflows/cargo.yml | 23 ---------- 3 files changed, 80 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/build.yml.bak delete mode 100644 .github/workflows/cargo.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d9b1961 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,80 @@ +name: Build and Release + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: write + +jobs: + build-linux: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Add toolchains to Rustup + run: rustup target add x86_64-unknown-linux-gnu + + - name: Build for Linux + run: cargo build --release --target x86_64-unknown-linux-gnu + + - name: Upload rustmon artifact (Linux) + uses: actions/upload-artifact@v2 + with: + name: rustmon + path: ./target/x86_64-unknown-linux-gnu/release/rustmon + + - name: Upload minimon artifact (Linux) + uses: actions/upload-artifact@v2 + with: + name: minimon + path: ./target/x86_64-unknown-linux-gnu/release/minimon + + build-windows: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Install dependencies for cross-compilation + run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64 + + - name: Add toolchains to Rustup + run: rustup target add x86_64-pc-windows-gnu x86_64-apple-darwin + + - name: Build for Windows + run: cargo build --release --target x86_64-pc-windows-gnu + + - name: Get Variables + run: | + echo "TAG_NAME=commit-$(git rev-parse --short HEAD)" >> $GITHUB_ENV + + - name: Upload rustmon artifact (Windows) + uses: actions/upload-artifact@v2 + with: + name: rustmon.exe + path: ./target/x86_64-pc-windows-gnu/release/rustmon.exe + + - name: Upload minimon artifact (Windows) + uses: actions/upload-artifact@v2 + with: + name: minimon.exe + path: ./target/x86_64-pc-windows-gnu/release/minimon.exe diff --git a/.github/workflows/build.yml.bak b/.github/workflows/build.yml.bak deleted file mode 100644 index e19b169..0000000 --- a/.github/workflows/build.yml.bak +++ /dev/null @@ -1,57 +0,0 @@ -name: Build - -on: - push: - branches: - - '*' - pull_request: - branches: - - '*' - -jobs: - build-arch: - runs-on: ubuntu-latest - container: - image: archlinux:latest - steps: - - uses: actions/checkout@v2 - - - name: Install dependencies - run: | - pacman -Syu --noconfirm base-devel rust - useradd builder -m -G wheel - echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers - - - name: Build Arch package - run: | - chown -R builder:builder . - cd build/arch - sudo -u builder bash -c "makepkg -sf --noconfirm" - - - name: Print current directory - run: ls -la - - - name: Upload Arch package - uses: actions/upload-artifact@v2 - with: - name: rustmon.pkg.tar.zst - path: ./build/arch/*.pkg.tar - - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Install dependencies - run: sudo apt-get install -y dpkg-dev - - - name: Build Debian package - run: | - cd build/debian - sh debian.sh -y - - - name: Upload Debian package - uses: actions/upload-artifact@v2 - with: - name: rustmon.deb - path: build/debian/rustmon.deb diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml deleted file mode 100644 index a4cf8d1..0000000 --- a/.github/workflows/cargo.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Cargo Build - -on: - push: - branches: - - '*' - pull_request: - branches: - - '*' - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose