name: C/C++ CI linux

on: [push]

jobs:
  build:
    strategy:
      matrix:
        buildtype: [Debug, Release]

    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v3

    - name: pkg
      run: | 
        sudo apt-get update 
        sudo apt-get install -y --no-install-recommends ca-certificates g++ autoconf automake libtool xz-utils cmake make pkg-config git libjpeg-dev libssl-dev

    - name: build
      run: |
          cmake -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }}  .
          make

    - name: cpack 
      run: | 
          rm -f *.tar.gz
          cpack
          echo "artifactPath=$(ls *.tar.gz)" >> $GITHUB_ENV

    - uses: actions/upload-artifact@v3
      with:
        name: ${{ env.artifactPath }}
        path: ${{ env.artifactPath }}   

    - name: Release
      uses: softprops/action-gh-release@v1
      if: startsWith(github.ref, 'refs/tags/')
      with:
        files: ${{ env.artifactPath }}