shithub: m8c

ref: 7cdf8d5d6236426d1c12eb7776bf5583e71f077c
dir: /.github/workflows/build.yml/

View raw version
name: m8c build

on:
  push:
  pull_request:
  workflow_dispatch:

jobs:
  build-win:
    runs-on: windows-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - { sys: mingw32, env: i686, win: win32 }
          - { sys: mingw64, env: x86_64, win: win64 }
    name: ${{ matrix.win }}
    defaults:
      run:
        shell: msys2 {0}
    env:
      MINGW_ARCH: ${{ matrix.sys }}
    steps:

    - name: 'git config'
      run: git config --global core.autocrlf input
      shell: bash

    - name: 'Checkout'
      uses: actions/checkout@v2
      with:
        fetch-depth: 0

    - name: 'Setup MSYS2'
      uses: msys2/setup-msys2@v2
      with:
        msystem: ${{ matrix.sys }}
        update: true
        install: mingw-w64-${{ matrix.env }}-toolchain make mingw-w64-${{ matrix.env }}-SDL2 mingw-w64-${{ matrix.env }}-libserialport zip dos2unix
  
    - name: 'Get current date'
      id: date
      run: echo "::set-output name=date::$(date +%Y%m%d)"

    - name: 'Build package'
      run: |
        make
        strip -g m8c.exe
        if [ ${{ matrix.win }} == "win32" ]
        then        
          cp /mingw32/bin/SDL2.dll .
          cp /mingw32/bin/libgcc_s_dw2-1.dll .
          cp /mingw32/bin/libserialport-0.dll .
          cp /mingw32/bin/libwinpthread-1.dll .
        else
          cp /mingw64/bin/SDL2.dll .
          cp /mingw64/bin/libserialport-0.dll .
        fi
        unix2dos README.md config.ini.sample LICENSE AUDIOGUIDE.md
    - name: 'Upload artifact (win32)'
      if: matrix.win == 'win32'
      uses: actions/upload-artifact@v2
      with:
        name: m8c-${{ steps.date.outputs.date }}-${{ matrix.win }}
        path: |
          m8c.exe
          SDL2.dll
          libserialport-0.dll
          libgcc_s_dw2-1.dll
          libwinpthread-1.dll
          gamecontrollerdb.txt
          LICENSE
          README.md
          AUDIOGUIDE.md
          config.ini.sample
    - name: 'Upload artifact (win64)'
      if: matrix.win == 'win64'
      uses: actions/upload-artifact@v2
      with:
        name: m8c-${{ steps.date.outputs.date }}-${{ matrix.win }}
        path: |
          m8c.exe
          SDL2.dll
          libserialport-0.dll
          gamecontrollerdb.txt
          LICENSE
          README.md
          AUDIOGUIDE.md
          config.ini.sample

  build-linux:
    runs-on: ubuntu-latest
    name: linux-x86_64
    steps:
      - name: 'Install dependencies'
        run: |
          sudo apt-get update
          sudo apt-get install --fix-missing build-essential libsdl2-dev libserialport-dev zip
      - name: 'Checkout'
        uses: actions/checkout@v2

      - name: 'Get current date'
        id: date
        run: echo "::set-output name=date::$(date +%Y%m%d)"

      - name: 'Build package'
        run: |
          make
      - name: 'Upload artifact'
        uses: actions/upload-artifact@v2
        with:
          name: m8c-${{ steps.date.outputs.date }}-linux
          path: |
            LICENSE
            README.md
            AUDIOGUIDE.md
            m8c
            gamecontrollerdb.txt
            config.ini.sample
      
  build-macos:
    runs-on: macos-latest
    
    steps:
      - name: 'Install dependencies'
        run: brew install sdl2 libserialport pkg-config

      - name: 'Checkout'
        uses: actions/checkout@v2

      - name: 'Get current date'
        id: date
        run: echo "::set-output name=date::$(date +%Y%m%d)"

      - name: 'Build package'
        run: |
          make
          chmod 755 m8c
          cd macos/m8c.app/Contents/
          mkdir MacOS
          cd MacOS
          cp ../../../../m8c .
          cp /usr/local/opt/sdl2/lib/libSDL2* .
          cp /usr/local/opt/libserialport/lib/libserialport.* .
          install_name_tool -change /usr/local/opt/libserialport/lib/libserialport.0.dylib @executable_path/libserialport.0.dylib m8c
          install_name_tool -change /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib @executable_path/libSDL2-2.0.0.dylib m8c
          cd ../../../../
          cp -r macos/m8c.app .
          zip -r m8c.zip m8c.app LICENSE README.md AUDIOGUIDE.md config.ini.sample gamecontrollerdb.txt
      - name: 'Upload artifact'
        uses: actions/upload-artifact@v2
        with:
          name: m8c-${{ steps.date.outputs.date }}-macos
          path: m8c.zip