182 lines
4.5 KiB
YAML
182 lines
4.5 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, master ]
|
|
pull_request:
|
|
branches: [ main, master ]
|
|
release:
|
|
types: [ created ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
# Test job
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Install Rust
|
|
shell: bash
|
|
run: |
|
|
if ! command -v rustup >/dev/null 2>&1; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
fi
|
|
rustup toolchain install stable --profile minimal --target x86_64-unknown-linux-gnu
|
|
rustup default stable
|
|
|
|
- name: Install system dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
libdbus-1-dev \
|
|
pkg-config \
|
|
libgtk-3-dev \
|
|
libwebkit2gtk-4.1-dev \
|
|
libayatana-appindicator3-dev \
|
|
librsvg2-dev \
|
|
libssl-dev \
|
|
libasound2-dev
|
|
|
|
- name: Cache cargo
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
src/target
|
|
key: linux-cargo-${{ hashFiles('src/Cargo.lock') }}
|
|
restore-keys: linux-cargo-
|
|
|
|
- name: Check
|
|
working-directory: src
|
|
run: cargo check -p shared -p tscore -p tsaudio -p tsdb
|
|
|
|
- name: Test
|
|
working-directory: src
|
|
run: cargo test -p shared -p tscore -p tsaudio -p tsdb
|
|
|
|
- name: Clippy
|
|
working-directory: src
|
|
run: cargo clippy -p shared -p tscore -p tsaudio -p tsdb -- -D warnings
|
|
continue-on-error: true
|
|
|
|
# Build frontend
|
|
build-frontend:
|
|
name: Build Frontend
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '22'
|
|
|
|
- name: Install dependencies
|
|
working-directory: src/tauri-app/frontend
|
|
run: npm install
|
|
|
|
- name: Build
|
|
working-directory: src/tauri-app/frontend
|
|
run: npm run build
|
|
|
|
- name: Upload frontend artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: frontend-dist
|
|
path: src/tauri-app/frontend/dist/
|
|
|
|
# Build desktop app (Linux only)
|
|
build-desktop:
|
|
name: Build Desktop (Linux)
|
|
needs: [test, build-frontend]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Install Rust
|
|
shell: bash
|
|
run: |
|
|
if ! command -v rustup >/dev/null 2>&1; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
fi
|
|
rustup toolchain install stable --profile minimal --target x86_64-unknown-linux-gnu
|
|
rustup default stable
|
|
|
|
- name: Install system dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
libdbus-1-dev \
|
|
pkg-config \
|
|
libgtk-3-dev \
|
|
libwebkit2gtk-4.1-dev \
|
|
libayatana-appindicator3-dev \
|
|
librsvg2-dev \
|
|
libssl-dev \
|
|
libasound2-dev
|
|
|
|
- name: Download frontend artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: frontend-dist
|
|
path: src/tauri-app/frontend/dist/
|
|
|
|
- name: Cache cargo
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
src/target
|
|
key: linux-cargo-${{ hashFiles('src/Cargo.lock') }}
|
|
restore-keys: linux-cargo-
|
|
|
|
- name: Build
|
|
working-directory: src
|
|
run: cargo build --release
|
|
|
|
- name: Package
|
|
run: |
|
|
mkdir -p dist
|
|
cp src/target/release/re-teamspeak dist/ || true
|
|
tar -czf re-teamspeak-linux-amd64.tar.gz -C dist .
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: re-teamspeak-linux-amd64
|
|
path: re-teamspeak-linux-amd64.*
|
|
|
|
# Release
|
|
release:
|
|
name: Release
|
|
needs: build-desktop
|
|
if: github.event_name == 'release'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
path: artifacts/
|
|
|
|
- name: Create release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
files: artifacts/**/*
|
|
draft: true
|
|
generate_release_notes: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|