py2pyd 0.1.6

A Rust-based tool to compile Python modules to pyd files
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

# We need this to be able to create releases.
permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  upload-assets:
    name: ${{ matrix.target }}
    if: startsWith(github.ref_name, 'v')
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          # Linux x86_64
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-22.04
          - target: x86_64-unknown-linux-musl
            os: ubuntu-22.04
            use-cross: true
          # Linux ARM64
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-22.04
            use-cross: true
          - target: aarch64-unknown-linux-musl
            os: ubuntu-22.04
            use-cross: true
          # macOS x86_64 (Intel)
          - target: x86_64-apple-darwin
            os: macos-13
          # macOS ARM64 (Apple Silicon)
          - target: aarch64-apple-darwin
            os: macos-14
          # Windows x86_64
          - target: x86_64-pc-windows-msvc
            os: windows-2022
          # Windows ARM64
          - target: aarch64-pc-windows-msvc
            os: windows-2022
    timeout-minutes: 60
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Setup Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      # Install cross for Linux cross-compilation
      - name: Install cross
        if: matrix.use-cross == true
        uses: taiki-e/install-action@v2
        with:
          tool: cross

      # Setup cross-toolchain for Linux GNU targets
      - name: Setup cross-toolchain
        if: startsWith(matrix.os, 'ubuntu') && !matrix.use-cross
        uses: taiki-e/setup-cross-toolchain-action@v1
        with:
          target: ${{ matrix.target }}

      # Windows static linking
      - name: Set Windows RUSTFLAGS
        if: contains(matrix.target, 'windows-msvc')
        shell: bash
        run: echo "RUSTFLAGS=-C target-feature=+crt-static" >> "${GITHUB_ENV}"

      # Upload binary
      - name: Upload release binary
        uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: py2pyd
          target: ${{ matrix.target }}
          tar: all
          zip: windows
          token: ${{ secrets.GITHUB_TOKEN }}
          checksum: sha256