name: Build

on:
  push:
    branches: [ master, dev ]
  pull_request:
    branches: [ master, dev ]

jobs:
  build:
    if: "!contains(github.event.head_commit.message, 'skip ci')"

    runs-on: ubuntu-latest
    container:
      image: crystallang/crystal:0.35.1-alpine

    steps:
    - uses: actions/checkout@v2
    - name: Install dependencies
      run: apk add --no-cache yarn yaml sqlite-static libarchive-dev libarchive-static acl-static expat-static zstd-static lz4-static bzip2-static libjpeg-turbo-dev libpng-dev tiff-dev
    - name: Build
      run: make static || make static
    - name: Linter
      run: make check
    - name: Run tests
      run: make test
    - name: Upload binary
      uses: actions/upload-artifact@v2
      with:
        name: mango
        path: mango
    - name: build arm32v7 object file
      run: make arm32v7 || make arm32v7
    - name: build arm64v8 object file
      run: make arm64v8 || make arm64v8
    - name: Upload object files
      uses: actions/upload-artifact@v2
      with:
        name: object files
        path: ./*.o
