template-rust-project 0.2.4

A template for Rust projects
Documentation
name: Build and Release

on:
  workflow_dispatch: { } # Allow manual execution
  push:
    tags:
      - 'v*' # Trigger on version tags

jobs:
  build-windows:
    runs-on: windows-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Set up Rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable

      - name: Install Dependencies
        run: |
          choco install make -y
          make test

      - name: Build Windows Binary
        run: |
          make build

      - name: Upload Windows Artifact
        uses: actions/upload-artifact@v4
        with:
          name: template-rust-project-windows
          path: target/release/template-rust-project.exe

  build-linux:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Set up Rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable

      - name: Install Dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y make
          make test

      - name: Build Linux Binary
        run: |
          make build

      - name: Upload Linux Artifact
        uses: actions/upload-artifact@v4
        with:
          name: template-rust-project-linux
          path: target/release/template-rust-project

  build-macos:
    runs-on: macos-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Set up Rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable

      - name: Install Dependencies
        run: |
          brew install make
          make test

      - name: Build macOS Binary
        run: |
          make build

      - name: Upload macOS Artifact
        uses: actions/upload-artifact@v4
        with:
          name: template-rust-project-macos
          path: target/release/template-rust-project

  release:
    runs-on: ubuntu-latest
    needs: [ build-windows, build-linux, build-macos ]
    steps:
      - name: Download Windows Artifact
        uses: actions/download-artifact@v4
        with:
          name: template-rust-project-windows
          path: ./windows

      - name: Download Linux Artifact
        uses: actions/download-artifact@v4
        with:
          name: template-rust-project-linux
          path: ./linux

      - name: Download macOS Artifact
        uses: actions/download-artifact@v4
        with:
          name: template-rust-project-macos
          path: ./macos

      - name: List Downloaded Files (for debugging)
        run: ls -R .

      - name: Rename Extracted Binaries
        run: |
          cd windows && zip -r9 ../template-rust-project-windows-amd64.zip template-rust-project.exe && cd ..
          cd linux && zip -r9 ../template-rust-project-linux-amd64.zip template-rust-project && cd ..
          cd macos && zip -r9 ../template-rust-project-macos-amd64.zip template-rust-project && cd ..

      - name: Create GitHub Release
        uses: ncipollo/release-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          name: ${{ github.ref_name }}
          tag: ${{ github.ref_name }}
          body: |
            Release version ${{ github.ref_name }}
            - Builds for Windows, Linux, and macOS
          artifacts: |
            template-rust-project-windows-amd64.zip
            template-rust-project-linux-amd64.zip
            template-rust-project-macos-amd64.zip
          draft: false
          prerelease: false