Files

190 lines
4.7 KiB
YAML

name: CI/CD
on:
push:
tags:
- '*'
env:
CARGO_TERM_COLOR: always
CMAKE_POLICY_VERSION_MINIMUM: 3.5
jobs:
# Test job
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
steps:
- uses: actions/checkout@v6
with:
submodules: false
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
cmake \
pkg-config \
libopus-dev \
libssl-dev \
libasound2-dev
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: brew install opus pkg-config
- name: Cache cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
src/target
key: ${{ runner.os }}-cargo-${{ hashFiles('src/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Check
working-directory: src
run: cargo check -p re-teamspeak
- name: Test
working-directory: src
run: cargo test -p re-teamspeak
- name: Clippy
working-directory: src
run: cargo clippy -p re-teamspeak -- -D warnings
continue-on-error: true
# Build desktop apps
build-desktop:
name: Build Desktop (${{ matrix.platform }})
needs: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: linux
target: x86_64-unknown-linux-gnu
artifact: linux-amd64
- os: windows-latest
platform: windows
target: x86_64-pc-windows-msvc
artifact: windows-amd64
- os: macos-latest
platform: macos
target: x86_64-apple-darwin
artifact: macos-amd64
steps:
- uses: actions/checkout@v6
with:
submodules: false
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install system dependencies (Linux)
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y \
cmake \
pkg-config \
libopus-dev \
libssl-dev \
libasound2-dev
- name: Install system dependencies (macOS)
if: matrix.platform == 'macos'
run: brew install opus pkg-config
- name: Cache cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
src/target
key: ${{ runner.os }}-cargo-${{ hashFiles('src/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
working-directory: src
run: cargo build --release -p re-teamspeak
- name: Package (Linux)
if: matrix.platform == 'linux'
run: |
mkdir -p dist
cp src/target/release/re-teamspeak dist/
tar -czf re-teamspeak-${{ matrix.artifact }}.tar.gz -C dist .
- name: Package (Windows)
if: matrix.platform == 'windows'
run: |
mkdir dist
copy src\target\release\re-teamspeak.exe dist\
Compress-Archive -Path dist\* -DestinationPath re-teamspeak-${{ matrix.artifact }}.zip
- name: Package (macOS)
if: matrix.platform == 'macos'
run: |
mkdir -p dist
cp src/target/release/re-teamspeak dist/
tar -czf re-teamspeak-${{ matrix.artifact }}.tar.gz -C dist .
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: re-teamspeak-${{ matrix.artifact }}
path: re-teamspeak-${{ matrix.artifact }}.*
# Release
release:
name: Release
needs: build-desktop
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: artifacts/
- name: Create release
uses: softprops/action-gh-release@v3
with:
files: artifacts/**/*
tag_name: ${{ github.ref_name }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}