name: 'Linux x86-64'
on: push

jobs:
  linux-sdk:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Get Date
        id: get-date
        run: |
          echo "::set-output name=date::$(/bin/date -u "+%Y-%m-%d-%H;%M;%S")"
        shell: bash
      - name: ccache cache files
        uses: actions/cache@v1.1.0
        with:
          path: ~/.ccache
          key: linux-x86-64-${{ runner.os }}-${{ steps.get-date.outputs.date }}
          restore-keys: |
              linux-x86-64-${{ runner.os }}-
      - name: Build Python 3.7 wheel
        shell: bash
        env:
          PYTHON_VERSION: 37
        run: |
          docker run --rm \
           -e CCACHE_COMPRESS=1 \
           -e CCACHE_MAXSIZE=10.0G \
           -e CCACHE_CPP2=1 \
           -e CCACHE_DIR=/ccache \
           -e PYTHON_VERSION=$PYTHON_VERSION \
           -e PYTHON_BINARY=/opt/python/cp37-cp37m/bin/python3.7 \
           -v $GITHUB_WORKSPACE:/src \
           -v $HOME/.ccache:/ccache \
           liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux.sh
      - name: Build Python 3.8 wheel
        shell: bash
        env:
          PYTHON_VERSION: 38
        run: |
          docker run --rm \
           -e CCACHE_COMPRESS=1 \
           -e CCACHE_MAXSIZE=10.0G \
           -e CCACHE_CPP2=1 \
           -e CCACHE_DIR=/ccache \
           -e PYTHON_VERSION=$PYTHON_VERSION \
           -e PYTHON_BINARY=/opt/python/cp38-cp38/bin/python3.8 \
           -v $GITHUB_WORKSPACE:/src \
           -v $HOME/.ccache:/ccache \
           liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux.sh
      - name: Build Python 3.9 wheel
        shell: bash
        env:
          PYTHON_VERSION: 39
        run: |
          docker run --rm \
           -e CCACHE_COMPRESS=1 \
           -e CCACHE_MAXSIZE=10.0G \
           -e CCACHE_CPP2=1 \
           -e CCACHE_DIR=/ccache \
           -e PYTHON_VERSION=$PYTHON_VERSION \
           -e PYTHON_BINARY=/opt/python/cp39-cp39/bin/python3.9 \
           -v $GITHUB_WORKSPACE:/src \
           -v $HOME/.ccache:/ccache \
           liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux.sh
      - name: Build SDK
        shell: bash
        run: |
          docker run --name lief_sdk --rm \
            -e PYTHON_BINARY=/opt/python/cp39-cp39/bin/python3.9 \
            -e CCACHE_COMPRESS=1 \
            -e CCACHE_MAXSIZE=10.0G \
            -e CCACHE_DIR=/ccache \
            -v $GITHUB_WORKSPACE:/src \
            -v $HOME/.ccache:/ccache \
            liefproject/manylinux1_x86_64 bash /src/scripts/docker/travis-linux-sdk.sh
      - name: Deploy
        env:
          LIEF_AUTOMATIC_BUILDS_KEY: ${{ secrets.LIEF_AUTOMATIC_BUILDS_KEY }}
          LIEF_AUTOMATIC_BUILDS_IV: ${{ secrets.LIEF_AUTOMATIC_BUILDS_IV }}
        shell: bash
        run: |
          docker run \
            -v $GITHUB_WORKSPACE:/src \
            -e GITHUB_ACTIONS="true" \
            -e GITHUB_WORKSPACE=$GITHUB_WORKSPACE \
            -e GITHUB_REF=$GITHUB_REF \
            -e GITHUB_REPOSITORY=$GITHUB_REPOSITORY \
            -e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
            -e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
            --rm \
            liefproject/deploy python3 /src/.github/deploy.py
      - name: Trigger documentation
        env:
          CIRCLE_CI_TOKEN: ${{ secrets.CIRCLE_CI_TOKEN }}
        shell: bash
        run: |
          docker run --rm \
            -e CIRCLE_CI_TOKEN=$CIRCLE_CI_TOKEN \
            liefproject/manylinux1_x86_64 \
            bash -c "curl --request POST --url https://circleci.com/api/v2/project/gh/lief-project/doc/pipeline --header 'Circle-Token: ${CIRCLE_CI_TOKEN}' --header 'content-type: application/json'";





