rust-microservice 0.1.3

A microservices framework in Rust whichs provides common functionalities for developing Web APIs.
Documentation
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] #[ubuntu-latest, macOS-latest, windows-latest]
        include:
        - os: ubuntu-latest
          target: x86_64-unknown-linux-musl
      # - os: macOS-latest
      #   target: x86_64-apple-darwin
      # - os: windows-latest
      #   target: x86_64-pc-windows-msvc

    steps:
      # Checkout the code
      - 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."

      # Compress the server example binary using UPX
      - 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."
      
      # Build Rust Microservices Crate
      - name: Build Rust Microservices
        run: |
          echo "ℹ️ Building Rust Microservices..."
          cargo build --verbose --release --all-features
          echo "✅ Rust Microservices build completed successfully."

      # Upload release artifacts
      - 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