name: Rust Build
description: Build Rust microservices for multiple platforms
on:
workflow_call:
env:
CARGO_TERM_COLOR: always
jobs:
rust-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest] include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v6
- name: Validate tag name
uses: ./.github/actions/check-tag
with:
target: ${{ matrix.target }}
tag: ${{ github.ref_name }}
- name: Install Rust Environment
uses: ./.github/actions/rust-env
with:
os: ${{ matrix.target }}
target: ${{ matrix.target }}
- name: Build Example Server
run: |
echo "ℹ️ Running cargo build for package 'server'..."
cargo build -p server --target ${{ matrix.target }} --release
echo "✅ Server build completed successfully."
- name: Rename server binary
run: |
echo "ℹ️ Renaming server binary..."
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
mv ./target/${{ matrix.target }}/release/server.exe ./target/${{ matrix.target }}/release/server-${{ matrix.target }}.exe
else
mv ./target/${{ matrix.target }}/release/server ./target/${{ matrix.target }}/release/server-${{ matrix.target }}
fi
echo "✅ Server binary renamed successfully."
- name: Compress binary
run: |
echo "ℹ️ Compressing binary..."
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
upx --best --lzma --brute ./target/${{ matrix.target }}/release/server-${{ matrix.target }}.exe
else
upx --best --lzma --brute ./target/${{ matrix.target }}/release/server-${{ matrix.target }}
fi
echo "✅ Binary compression completed successfully."
- name: Build Rust Microservices
run: |
echo "ℹ️ Building Rust Microservices..."
cargo build --verbose --release --all-features
echo "✅ Rust Microservices build completed successfully."
- name: Upload Release Artifacts
uses: actions/upload-artifact@v5
with:
name: bundle-${{ github.ref_name }}-${{ matrix.target }}
path: |
./target/${{ matrix.target }}/release/server-${{ matrix.target }}
./target/${{ matrix.target }}/release/server-${{ matrix.target }}.exe
retention-days: 1