updated github actions workflow

This commit is contained in:
Vomitblood 2024-07-15 14:51:25 +08:00
parent 6d4701b36d
commit 64ca702103
3 changed files with 80 additions and 80 deletions

80
.github/workflows/build.yml vendored Normal file
View file

@ -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

View file

@ -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

View file

@ -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