cairo-native 0.2.6

A compiler to convert Cairo's intermediate representation Sierra code to MLIR.
name: GitHub Release

permissions:
  contents: write
  discussions: write

on:
  push:
    tags:
      - "v*.*.*"

jobs:
  release-linux:
    runs-on: ubuntu-24.04
    env:
        MLIR_SYS_190_PREFIX: /usr/lib/llvm-19/
        LLVM_SYS_191_PREFIX: /usr/lib/llvm-19/
        TABLEGEN_190_PREFIX: /usr/lib/llvm-19/
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: free HDD space
        run: |
          # deleting space
          sudo rm -rf /usr/share/dotnet/
          sudo rm -rf /usr/local/lib/android
      - name: Setup rust env
        uses: dtolnay/rust-toolchain@1.83.0
      - name: Retreive cached dependecies
        uses: Swatinem/rust-cache@v2
      - name: add llvm deb repository
        uses: myci-actions/add-deb-repo@11
        with:
          repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main
          repo-name: llvm-repo
          keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
      - name: Install LLVM
        run: sudo apt-get install llvm-19 llvm-19-dev llvm-19-runtime clang-19 clang-tools-19 lld-19 libpolly-19-dev libmlir-19-dev mlir-19-tools
      - name: Install deps
        run: make deps
      - name: build release
        run: make build
      - name: Compress into a tar file
        run: cd target/release && tar -cJvf ../cairo-native-x86_64.tar.xz cairo-native-test \
          cairo-native-compile cairo-native-dump cairo-native-run libcairo_native_runtime.a && cd ..
      - uses: actions/upload-artifact@v4
        with:
          name: linux-build
          path: cairo-native-x86_64.tar.xz

  release-macos:
    runs-on: macos-14
    env:
      CARGO_TERM_COLOR: always
      LIBRARY_PATH: /opt/homebrew/lib
      MLIR_SYS_190_PREFIX: /opt/homebrew/opt/llvm@19
      LLVM_SYS_191_PREFIX: /opt/homebrew/opt/llvm@19
      TABLEGEN_190_PREFIX: /opt/homebrew/opt/llvm@19
      RUST_LOG: cairo_native=debug,cairo_native_test=debug
    steps:
      - uses: actions/checkout@v4
      - name: Rustup toolchain install
        uses: dtolnay/rust-toolchain@1.83.0
        with:
          components: clippy
      - name: Rust `$PATH` workaround.
        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
      - name: Install deps
        run: make deps
      - name: Build release
        run: make build
      - name: Compress into a tar file
        run: cd target/release && tar -cJvf ../cairo-native-aarch64.tar.xz cairo-native-test \
          cairo-native-compile cairo-native-dump cairo-native-run libcairo_native_runtime.a && cd ..
      - uses: actions/upload-artifact@v4
        with:
          name: macos-build
          path: cairo-native-aarch64.tar.xz

  release:
    runs-on: ubuntu-24.04
    needs: [release-macos, release-linux]
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Download linux
        uses: actions/download-artifact@v4
        with:
          name: linux-build
      - name: Download macos
        uses: actions/download-artifact@v4
        with:
          name: macos-build
      - name: Release on GitHub
        uses: softprops/action-gh-release@v2
        with:
          files: |
            cairo-native-aarch64.tar.xz
            cairo-native-x86_64.tar.xz