name: "Build glibc & make"

on:
  workflow_dispatch:

jobs:
  Building:
    name: "Build on CentOS 7"
    runs-on: ubuntu-latest
    container: docker.io/centos:7
    steps:
    - uses: actions/checkout@v2

    - name: Install dependencies
      run: |
        yum -y install gcc bison make centos-release-scl wget
        yum -y install devtoolset-8-gcc
        yum -y install devtoolset-8-gcc-c++
        yum -y install devtoolset-8-binutils
        mkdir -p /opt/release/

    - name: Build make v4.3
      run: |
        wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz
        tar -xzf make-4.3.tar.gz
        cd make-4.3
        ./configure
        make
        make install
        echo y | cp -f ./make /usr/bin/
        cp ./make /opt/release/
        cd ~

    - name: Build glibc v2.28
      run: |
        source /opt/rh/devtoolset-8/enable
        wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
        tar -zxf glibc-2.28.tar.gz
        mkdir -p ./glibc-2.28/build
        cd ./glibc-2.28/build
        ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
        make
        make install
        cd ..; cd ..
        tar -czf /opt/release/glibc-2.28.tar.gz ./glibc-2.28
    
    - name: Test install
      run: |
        rpm -ivh http://pkg.cloudflareclient.com/cloudflare-release-el8.rpm
        sed -i "s/\$releasever/8/g" /etc/yum.repos.d/cloudflare.repo
        yum -y update
        yum -y install cloudflare-warp
        [[ $(systemctl is-active warp-svc) != active ]] && ( systemctl start warp-svc; sleep 2 )
        warp-cli --accept-tos register
        warp-cli --accept-tos set-mode proxy
        warp-cli --accept-tos connect
        warp-cli --accept-tos enable-always-on
        sleep 2
        ss -nltp | grep 'warp-svc' 

    - name: Release binaries 
      uses: softprops/action-gh-release@v1
      with:
          tag_name: Glibc v2.28
          files: /opt/release/*
      env:
          GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
