name: Build on: push: branches: - main workflow_dispatch: jobs: build: name: Build - ${{ matrix.platform }} runs-on: gitea-runner container: image: ${{ matrix.docker_image }} strategy: matrix: include: - platform: linux docker_image: gitea.staspast.click/stas/rust-node-builder:latest target: x86_64-unknown-linux-gnu artifact_name: rlogg-linux-x86_64 binary_extension: "" setup_cmd: "" # - platform: macos # docker_image: messense/cargo-zigbuild:latest # target: x86_64-apple-darwin # artifact_name: rlogg-macos-x86_64 # binary_extension: "" # setup_cmd: "" # - platform: windows # docker_image: rust:latest # target: x86_64-pc-windows-gnu # artifact_name: rlogg-windows-x86_64 # binary_extension: ".exe" # setup_cmd: "apt-get update && apt-get install -y mingw-w64" steps: - name: Checkout code uses: actions/checkout@v4 - name: Cache Cargo Dependencies uses: actions/cache@v3 with: # Path to cache: The 'target' directory contains all compiled libraries path: | ~/.cargo/bin/ ~/.cargo/registry/ target/ # Key: Changes if OS, Rust toolchain, or dependencies change key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.target }} # Restore Keys: Use for finding a cache from a slightly older lock file restore-keys: | ${{ runner.os }}-cargo-${{ matrix.target }}- ${{ runner.os }}-cargo- - name: Setup cross-compilation tools if: matrix.setup_cmd != '' run: ${{ matrix.setup_cmd }} - name: Add Rust target run: rustup target add ${{ matrix.target }} - name: Build release binary run: | if [ "${{ matrix.platform }}" = "macos" ]; then # macOS uses cargo-zigbuild cargo zigbuild --release --target ${{ matrix.target }} else # Linux/Windows targets (running in the Rust container) # Apply RUSTFLAGS inline to fix the Alpine/Musl linker issue RUSTFLAGS="-C link-arg=-Wl,--compress-debug-sections=none" cargo build --release --target ${{ matrix.target }} fi - name: Prepare artifact shell: bash run: | mkdir -p dist cp target/${{ matrix.target }}/release/rlogg${{ matrix.binary_extension }} dist/${{ matrix.artifact_name }}${{ matrix.binary_extension }} - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact_name }} path: dist/${{ matrix.artifact_name }}${{ matrix.binary_extension }} retention-days: 14