mirror of
https://github.com/Deathemonic/BA-AD.git
synced 2025-07-25 15:37:33 +02:00
177 lines
4.8 KiB
YAML
177 lines
4.8 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
release:
|
|
types: [published]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-linux:
|
|
name: Build for Linux (x86_64)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: x86_64-unknown-linux-gnu
|
|
|
|
- name: Cache Cargo dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-x86_64-unknown-linux-gnu-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Build release binary
|
|
run: cargo build --release --target x86_64-unknown-linux-gnu
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: baad-linux-x86_64
|
|
path: target/x86_64-unknown-linux-gnu/release/baad
|
|
|
|
build-windows:
|
|
name: Build for Windows (x86_64)
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: x86_64-pc-windows-msvc
|
|
|
|
- name: Cache Cargo dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-x86_64-pc-windows-msvc-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Build release binary
|
|
run: cargo build --release --target x86_64-pc-windows-msvc
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: baad-windows-x86_64
|
|
path: target/x86_64-pc-windows-msvc/release/baad.exe
|
|
|
|
build-macos-x86:
|
|
name: Build for macOS (x86_64)
|
|
runs-on: macos-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: x86_64-apple-darwin
|
|
|
|
- name: Cache Cargo dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-x86_64-apple-darwin-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Build release binary
|
|
run: cargo build --release --target x86_64-apple-darwin
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: baad-macos-x86_64
|
|
path: target/x86_64-apple-darwin/release/baad
|
|
|
|
build-macos-aarch64:
|
|
name: Build for macOS (aarch64)
|
|
runs-on: macos-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: aarch64-apple-darwin
|
|
|
|
- name: Cache Cargo dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-cargo-aarch64-apple-darwin-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Build release binary
|
|
run: cargo build --release --target aarch64-apple-darwin
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: baad-macos-aarch64
|
|
path: target/aarch64-apple-darwin/release/baad
|
|
|
|
deploy:
|
|
name: Deploy to Release
|
|
needs: [build-linux, build-windows, build-macos-x86, build-macos-aarch64]
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
|
|
permissions:
|
|
contents: write
|
|
actions: read
|
|
|
|
steps:
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: ./artifacts
|
|
run-id: ${{ github.run_id }}
|
|
|
|
- name: Create release assets
|
|
run: |
|
|
if [ ! -d "artifacts" ] || [ -z "$(ls -A artifacts)" ]; then
|
|
echo "::error::No artifacts were found to package. Aborting."
|
|
exit 1
|
|
fi
|
|
|
|
cd artifacts
|
|
for dir in */; do
|
|
if [ -d "$dir" ]; then
|
|
local_dir_name=${dir%/}
|
|
cd "$dir"
|
|
if [[ "$local_dir_name" == *"windows"* ]]; then
|
|
zip "../${local_dir_name}.zip" ./*
|
|
else
|
|
tar -czf "../${local_dir_name}.tar.gz" ./*
|
|
fi
|
|
cd ..
|
|
fi
|
|
done
|
|
|
|
- name: Upload release assets
|
|
uses: softprops/action-gh-release@v2
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
files: artifacts/*.zip
|
|
generate_release_notes: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|