tesohh-bricks 1.0.4

build system and package manager for C/C++
Documentation
name: Build
on:
  push:
    tags: ["v*"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:
env:
  # The project name specified in your Cargo.toml
  PROJECT_NAME: bricks

permissions:
  contents: write

jobs:
  build:
    # Set the job to run on the platform specified by the matrix below
    runs-on: ${{ matrix.runner }}
 
    # Define the build matrix for cross-compilation
    strategy:
      matrix:
        include:
          - name: linux-amd64
            runner: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - name: win-amd64
            runner: windows-latest
            target: x86_64-pc-windows-msvc
          - name: macos-amd64
            runner: macos-13
            target: x86_64-apple-darwin
          - name: macos-arm64
            runner: macos-latest
            target: aarch64-apple-darwin
 
    # The steps to run for each matrix item
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install openssl on macos
        if: runner.os == 'macOS'
        run: |
            brew install pkg-config openssl@3
            echo "OPENSSL_DIR=$(brew --prefix openssl)" >> $GITHUB_ENV
            echo "OPENSSL_INCLUDE_DIR=$(brew --prefix openssl)/include" >> $GITHUB_ENV
            echo "OPENSSL_LIB_DIR=$(brew --prefix openssl)/lib" >> $GITHUB_ENV
            echo "PKG_CONFIG_PATH=$(brew --prefix openssl)/lib/pkgconfig" >> $GITHUB_ENV

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: "${{ matrix.target }}"
 
      - name: Setup Cache
        uses: Swatinem/rust-cache@v2
 
      - name: Build Binary
        run: cargo build --verbose --locked --release --target ${{ matrix.target }}
 
      - name: Release Binary
        shell: bash
        run: |
          BIN_SUFFIX=""
          if [[ "${{ matrix.runner }}" == "windows-latest" ]]; then
            BIN_SUFFIX=".exe"
          fi
 
          # The built binary output location
          BIN_OUTPUT="target/${{ matrix.target }}/release/${PROJECT_NAME}${BIN_SUFFIX}"
 
          # Define a better name for the final binary
          BIN_RELEASE="${PROJECT_NAME}-${{ matrix.name }}${BIN_SUFFIX}"
          BIN_RELEASE_VERSIONED="${PROJECT_NAME}-${{ github.ref_name }}-${{ matrix.name }}${BIN_SUFFIX}"
 
          # Move the built binary where you want it
          mkdir release
          mv "${BIN_OUTPUT}" "./release/${BIN_RELEASE}"
      - name: Upload Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: "release-binaries-${{ matrix.name }}"
          path: release/*

  release:
    needs: build  # Ensure this runs after all builds finish
    runs-on: ubuntu-latest
    steps:
      - name: Download Built Binaries
        uses: actions/download-artifact@v4
        with:
          path: release

      - name: List Downloaded Files (Debugging)
        run: ls -R release

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v1
        with:
          tag_name: ${{ github.ref_name }}
          name: Release ${{ github.ref_name }}
          draft: true
          prerelease: false
          files: release/**
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}