osynic_midi 0.1.0

A MIDI -> keyboard mapper for the Osynic
Documentation
name: Release

permissions:
  contents: write

on:
  push:
    tags:
      - "v*" 

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build for ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            ext: ""
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            ext: ".exe"
          - target: x86_64-apple-darwin
            os: macos-latest
            ext: ""

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install musl-gcc
        if: matrix.os == 'ubuntu-latest'
        run: sudo apt-get update && sudo apt-get install -y musl-tools
  
      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly
          profile: minimal
          target: ${{ matrix.target }}
          override: true

      - name: Get crate info
        id: crate_info
        run: echo "CRATE_NAME=$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].name')" >> $GITHUB_OUTPUT
        shell: bash

      - name: Build release binary
        run: cargo build --release --target ${{ matrix.target }}

      - name: Package release
        if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
        run: |

          BIN_NAME=osynic-dl${{ matrix.ext }}
          RELEASE_DIR=release-${{ matrix.target }}
          mkdir $RELEASE_DIR
          cp target/${{ matrix.target }}/release/$BIN_NAME $RELEASE_DIR/
          tar czvf $RELEASE_DIR.tar.gz $RELEASE_DIR

      - name: Package release for Windows
        if: matrix.os == 'windows-latest'
        run: |

          $env:BIN_NAME = "osynic-dl${{ matrix.ext }}"
          $env:RELEASE_DIR = "release-${{ matrix.target }}"
          mkdir $env:RELEASE_DIR
          cp target/${{ matrix.target }}/release/$env:BIN_NAME $env:RELEASE_DIR/
          Compress-Archive -Path "$env:RELEASE_DIR\*" -DestinationPath "$env:RELEASE_DIR.zip"
        shell: powershell

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: release-${{ matrix.target }}
          path: |

            release-${{ matrix.target }}.*
            !(*.*)

  release:
    name: Create Release
    runs-on: ubuntu-latest
    needs: [build]
    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts

      - name: Create Release
        uses: softprops/action-gh-release@v1
        with:
          name: ${{ github.ref_name }}
          body: "Automated release for ${{ github.ref_name }}"
          files: |

            artifacts/**/*
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}