66 lines
1.8 KiB
YAML
66 lines
1.8 KiB
YAML
name: Rust Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: node-16
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: https://github.com/actions/checkout@v3
|
|
- name: Cache apt packages
|
|
uses: https://github.com/actions/cache@v2
|
|
with:
|
|
path: /var/cache/apt/archives
|
|
key: apt-${{ runner.os }}-${{ hashFiles('**/apt-packages.txt') }}
|
|
restore-keys: apt-${{ runner.os }}-
|
|
- name: Cache cargo build
|
|
uses: https://github.com/actions/cache@v2
|
|
with:
|
|
path: target
|
|
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: cargo-build-
|
|
|
|
# --- Cache apt packages ---
|
|
- name: Cache cargo registry
|
|
uses: https://github.com/actions/cache@v2
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: cargo-registry-
|
|
- name: Install Rust
|
|
uses: https://github.com/actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: nightly
|
|
profile: minimal
|
|
override: true
|
|
- name: install requirements for fast-build
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y lld clang
|
|
|
|
- name: Build release
|
|
run: cargo build --release
|
|
|
|
- name: Show binary
|
|
run: |
|
|
if [ -f target/release/rcc-bot ]; then
|
|
echo "Binary compiled successfully!"
|
|
ls -lh target/release/rcc-bot
|
|
else
|
|
echo "Compilation failed!"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Upload artifact
|
|
uses: https://github.com/actions/upload-artifact@v3
|
|
with:
|
|
name: rcc-bot
|
|
path: target/release/rcc-bot
|