spf 0.9.0

.spf (Simple Pixel Font) file parser
Documentation
name: builder

on:
  workflow_dispatch:
    inputs:
      tag_name:
        description: "Tag name (e.g. v1.0.0)"
        required: true

jobs:
  parse-tag:
    name: Parse Tag
    runs-on: ubuntu-latest
    outputs:
      type:        ${{ steps.parse.outputs.type }}
      version:     ${{ steps.parse.outputs.version }}
      sha:         ${{ steps.parse.outputs.sha }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Parse tag
        id: parse
        run: |
          TAG="${{ inputs.tag_name }}"
          SHA=$(git rev-list -n 1 "$TAG")
          echo "sha=$SHA" >> $GITHUB_OUTPUT
          VERSION=$(echo "$TAG" | awk -F'-v' '{print $2}')
          echo "type=library" >> $GITHUB_OUTPUT
          echo "version=$VERSION" >> $GITHUB_OUTPUT

  header-file:
    name: Generate ABI Header
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Install cbindgen
        run: cargo install cbindgen --locked
      - name: Generate header
        run: cbindgen --output spf.h --lang c --cpp-compat
      - name: Upload ABI Header
        uses: actions/upload-artifact@v4
        with:
          name: spf-header
          path: spf.h

  build:
    name: Build (${{ matrix.target }})
    needs: [parse-tag, header-file]
    strategy:
      fail-fast: false
      matrix:
        include:
          # Linux GNU
          - { target: x86_64-unknown-linux-gnu,      os: ubuntu-latest }
          - { target: aarch64-unknown-linux-gnu,     os: ubuntu-latest }
          - { target: i686-unknown-linux-gnu,        os: ubuntu-latest }
          - { target: armv7-unknown-linux-gnueabihf, os: ubuntu-latest }
          # Linux MUSL
          - { target: x86_64-unknown-linux-musl,     os: ubuntu-latest }
          - { target: aarch64-unknown-linux-musl,    os: ubuntu-latest }
          # Windows GNU (Cross-compiles easily from Linux)
          - { target: x86_64-pc-windows-gnu,         os: ubuntu-latest }
          # Windows MSVC (Switched to windows-latest to use native MSVC tools)
          - { target: x86_64-pc-windows-msvc,        os: windows-latest }
          # Other
          - { target: x86_64-unknown-freebsd,        os: ubuntu-latest }
          # macOS
          - { target: x86_64-apple-darwin,           os: macos-latest  }
          - { target: aarch64-apple-darwin,          os: macos-latest  }
    runs-on: ${{ matrix.os }}
    env:
      TAG_NAME:  ${{ inputs.tag_name }}
      TARGET:    ${{ matrix.target }}

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ needs.parse-tag.outputs.sha }}
      
      - name: Download ABI Header
        uses: actions/download-artifact@v4
        with:
          name: spf-header
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      # Install zigbuild only on Linux runners
      - name: Install Zig + cargo-zigbuild
        if: matrix.os == 'ubuntu-latest'
        run: |
          pip install ziglang --quiet
          cargo install cargo-zigbuild --locked

      - name: Build
        shell: bash
        run: bash .ci/build.sh

      - uses: actions/upload-artifact@v4
        with:
          name: artifact-${{ matrix.target }}
          path: artifacts/*.tar.gz

  release:
    name: Upload Release Assets
    needs: [parse-tag, build]
    outputs:
      outcome: ${{ steps.upload.outcome }}
    if: always() && needs.build.result != 'cancelled'
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/download-artifact@v4
        with:
          pattern: artifact-*
          merge-multiple: true
          path: artifacts/
      - uses: softprops/action-gh-release@v1
        id: upload
        with:
          tag_name: ${{ inputs.tag_name }}
          files: artifacts/*

  badge:
    name: Update Badge
    runs-on: ubuntu-latest
    needs: release
    if: always()
    steps:
      - name: passing
        if: needs.release.outputs.outcome == 'success'
        uses: SimplePixelFont/badge-spf-action@main
        with:
          filename: compatibility.png
          label: Compatibility
          message: passing
          labelColor: "#2d3136"
          color: "#00bfa3"
          logo: "https://raw.githubusercontent.com/The-Nice-One/GalleryArt/refs/heads/main/emojis_flattened/version_control.png"
          font: "https://raw.githubusercontent.com/SimplePixelFont/web-spf/refs/heads/main/Monogram5x8-light.spf"
      - name: failing
        if: needs.release.outputs.outcome != 'success'
        uses: SimplePixelFont/badge-spf-action@main
        with:
          filename: compatibility.png
          label: Compatibility
          message: failing
          labelColor: "#2d3136"
          color: "#d94a69"
          logo: "https://raw.githubusercontent.com/The-Nice-One/GalleryArt/refs/heads/main/emojis_flattened/version_control.png"
          font: "https://raw.githubusercontent.com/SimplePixelFont/web-spf/refs/heads/main/Monogram5x8-light.spf"
      - name: deploy
        uses: exuanbo/actions-deploy-gist@v1
        with:
          token: ${{ secrets.GIST_SECRET }}
          gist_id: cfebb0fe555ac7e77ada109c469cdeb4
          file_path: compatibility.png
          file_type: binary