name: ci
on: [push, pull_request]
jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
    steps:
    - uses: actions/checkout@v2
    - name: Dependency packages (ubuntu)
      run: sudo apt-get -y install build-essential python3-pexpect python3-yaml libncurses-dev
      if: ${{ matrix.os == 'ubuntu-latest' }}
    - name: Dependency packages (macos)
      run: |
        brew install coreutils ncurses
        pip3 install pexpect pyyaml
      if: ${{ matrix.os == 'macos-latest' }}
    - name: configure
      run: ./configure
    - name: make
      run: ./tools/mmake
    - name: make install-target
      run: make install-target DESTDIR=${GITHUB_WORKSPACE}/destdir
    - name: Build artifact tarball
      run: |
        mkdir -p ${GITHUB_WORKSPACE}/artifacts
        tar zcvf ${GITHUB_WORKSPACE}/artifacts/${{ github.job }}-${{ github.run_id }}.${{ github.run_number }}-${{ matrix.os }}.tar.gz -C ${GITHUB_WORKSPACE}/destdir .
    - name: Upload artifacts
      uses: actions/upload-artifact@v2
      with:
        name: ci-${{ github.job }}-${{ github.run_id }}.${{ github.run_number }}-${{ matrix.os }}
        path: artifacts/*.tar.gz
