name: Build gs_crypto module
on:
  workflow_dispatch:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install dependencies
        run: sudo apt-get update && sudo apt-get install -y build-essential libssl-dev zip
      - name: Build and test
        run: |
          set -e
          mkdir -p dist
          cc -std=c11 -O2 -Wall -Wextra -Wpedantic -fPIC -shared -I. -o dist/gs_crypto.so gs_crypto.c -lcrypto
          nm -D dist/gs_crypto.so | grep greenServeFE_module_init
          cp gs_crypto.c dist/gs_crypto.c
          zip -j dist/gs_crypto-linux-x86_64.zip dist/gs_crypto.so dist/gs_crypto.c
          sha256sum dist/gs_crypto.so > dist/gs_crypto.so.sha256
      - uses: actions/upload-artifact@v4
        with:
          name: gs_crypto-linux-x86_64
          path: dist/*
          if-no-files-found: error
