name: Release CPU miner

on:
  release:
    types: [created]

jobs:
  build:

    runs-on: ubuntu-latest
    
    steps:
    - name: Get release
      id: get_release
      uses: bruceadams/get-release@v1.2.3
      env:
        GITHUB_TOKEN: ${{ github.token }}
    - uses: actions/checkout@v1
    - name: Get libcurl-dev package
      run: sudo apt-get install libcurl4-openssl-dev
    - name: Set-up autoconf
      run: chmod +x ./autogen.sh && ./autogen.sh
    - name: configure
      run: chmod +x ./configure && ./configure --with-crypto --with-curl
    - name: make
      run: make
    - name: make check
      run: make check
    - name: CPU test
      run: ./nolambocoin-miner --help
    - name: Zips
      run: zip --junk-paths cpuminer nolambocoin-miner
    - name: Upload Release Asset
      id: upload-release-asset 
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ steps.get_release.outputs.upload_url }} 
        asset_path: ./cpuminer.zip
        asset_name: cpuminer.zip
        asset_content_type: application/zip
