liepress 0.1.1

A Markdown to PDF/SVG/PNG converter with CSS styling support
Documentation
name: release

on:
  workflow_dispatch:
    inputs:
      upload_artifacts:
        description: "Upload build artifacts"
        required: false
        default: "true"
        type: choice
        options: ["true", "false"]
  push:
    tags: ["v*"]

env:
  CARGO_TERM_COLOR: always
  BINARY_NAME: liepress

jobs:
  build-x86_64-linux:
    name: Build x86_64 Linux (gnu)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-unknown-linux-gnu

      - uses: Swatinem/rust-cache@v2
        with:
          key: x86_64-gnu-217

      - name: Install system deps
        run: |

          sudo apt-get update
          sudo apt-get install -y \
            libfontconfig1-dev libfreetype6-dev libexpat1-dev pkg-config

      - uses: mlugg/setup-zig@v2
        with:
          version: "0.13.0"

      - name: Install cargo-zigbuild
        run: pip3 install cargo-zigbuild

      - name: Build
        run: cargo zigbuild --release --target x86_64-unknown-linux-gnu.2.17

      - name: Sanity check
        run: |

          BIN=target/x86_64-unknown-linux-gnu/release/${{ env.BINARY_NAME }}
          readelf -W --version-info "$BIN" | grep -o 'GLIBC_[0-9.]*' | sort -Vu | tail -1
          nm -D --undefined-only "$BIN" 2>/dev/null | grep -E 'Fc[A-Z].*@FONTCCONFIG_2\.(1[1-9]|[2-9][0-9])' && exit 1 || echo "fontconfig symbols OK"

      - uses: actions/upload-artifact@v4
        if: ${{ github.event.inputs.upload_artifacts != 'false' }}
        with:
          name: ${{ env.BINARY_NAME }}-x86_64-linux-gnu
          path: target/x86_64-unknown-linux-gnu/release/${{ env.BINARY_NAME }}
          retention-days: 30

  build-aarch64-linux:
    name: Build aarch64 Linux (gnu)
    runs-on: ubuntu-24.04-arm
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: aarch64-unknown-linux-gnu

      - uses: Swatinem/rust-cache@v2
        with:
          key: aarch64-gnu-228

      - name: Install system deps
        run: |

          sudo apt-get update
          sudo apt-get install -y \
            libfontconfig1-dev libfreetype6-dev libexpat1-dev pkg-config

      - uses: mlugg/setup-zig@v2
        with:
          version: "0.13.0"

      - name: Install cargo-zigbuild
        run: pip3 install cargo-zigbuild

      - name: Build
        run: cargo zigbuild --release --target aarch64-unknown-linux-gnu.2.28

      - name: Sanity check
        run: |

          BIN=target/aarch64-unknown-linux-gnu/release/${{ env.BINARY_NAME }}
          readelf -W --version-info "$BIN" | grep -o 'GLIBC_[0-9.]*' | sort -Vu | tail -1
          nm -D --undefined-only "$BIN" 2>/dev/null | grep -E 'Fc[A-Z].*@FONTCCONFIG_2\.(1[1-9]|[2-9][0-9])' && exit 1 || echo "fontconfig symbols OK"

      - uses: actions/upload-artifact@v4
        if: ${{ github.event.inputs.upload_artifacts != 'false' }}
        with:
          name: ${{ env.BINARY_NAME }}-aarch64-linux-gnu
          path: target/aarch64-unknown-linux-gnu/release/${{ env.BINARY_NAME }}
          retention-days: 30

  build-x86_64-windows:
    name: Build x86_64 Windows (MSVC)
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-pc-windows-msvc

      - uses: Swatinem/rust-cache@v2
        with:
          key: x86_64-windows-msvc

      - name: Install NASM (for some native deps)
        run: |

          choco install nasm -y
          echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

      - name: Build
        run: cargo build --release --target x86_64-pc-windows-msvc

      - name: Sanity check
        run: |

          $BIN = "target\x86_64-pc-windows-msvc\release\${{ env.BINARY_NAME }}.exe"
          if (Test-Path $BIN) {
            Write-Host "Binary exists: $BIN"
            $size = (Get-Item $BIN).Length
            Write-Host "Binary size: $([math]::Round($size / 1MB, 2)) MB"
          } else {
            Write-Error "Binary not found: $BIN"
            exit 1
          }

      - uses: actions/upload-artifact@v4
        if: ${{ github.event.inputs.upload_artifacts != 'false' }}
        with:
          name: ${{ env.BINARY_NAME }}-x86_64-windows-msvc
          path: target\x86_64-pc-windows-msvc\release\${{ env.BINARY_NAME }}.exe
          retention-days: 30