name: Release Binaries

on:
  push:
    paths-ignore:
      - '**.md'
      - 'Makefile'
      - 'config.json'
    tags:
      - '*'

jobs:
  build:
    name: Create Release
    runs-on: ubuntu-latest
    container:
      image: centos:centos7

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.18
      
      - name: Setup necessary packages
        run: |
          yum install epel-release -y
          yum groupinstall 'Development Tools' -y
          yum install libaom-devel -y

      - name: Make WebP Server Go
        run: |
          make
          sha256sum builds/webp-server-linux-amd64 > builds/webp-server-linux-amd64.sha256
      
      - name: Check for ldd version
        run: |
          ldd --version
          ldd builds/webp-server-linux-amd64
      
      - uses: "marvinpinto/action-automatic-releases@latest"
        with:
          repo_token: "${{ secrets.GITHUB_TOKEN }}"
          prerelease: true
          title: "WebP Server Go"
          files: |
            builds/webp-server-linux-amd64
            builds/webp-server-linux-amd64.sha256