ldsc 0.3.1

LD Score Regression — fast Rust reimplementation of Bulik-Sullivan et al. LDSC
name: Release

on:
  push:
    tags: ["v*"]

env:
  CARGO_TERM_COLOR: always

permissions:
  contents: write

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-22.04
            target: x86_64-unknown-linux-gnu
            artifact: ldsc_linux-x86_64
            archive_ext: tar.gz
            sha_cmd: sha256sum
          - os: macos-14
            target: aarch64-apple-darwin
            artifact: ldsc_macos-aarch64
            archive_ext: tar.gz
            sha_cmd: shasum -a 256
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: ldsc_windows-x86_64
            archive_ext: zip
    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4

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

      - name: Setup vcpkg (Windows)
        if: startsWith(matrix.os, 'windows')
        run: echo "No external BLAS dependencies required."

      - name: Build (Linux/macOS)
        if: "!startsWith(matrix.os, 'windows')"
        run: cargo build --release --locked --target ${{ matrix.target }}

      - name: Build (Windows)
        if: startsWith(matrix.os, 'windows')
        run: cargo build --release --locked --target ${{ matrix.target }}

      - name: Package (Linux/macOS)
        if: "!startsWith(matrix.os, 'windows')"
        run: |
          mkdir -p dist
          cp target/${{ matrix.target }}/release/ldsc dist/
          cp LICENSE README.md dist/
          tar -czf dist/${{ matrix.artifact }}.${{ matrix.archive_ext }} -C dist ldsc LICENSE README.md
          ${{ matrix.sha_cmd }} dist/${{ matrix.artifact }}.${{ matrix.archive_ext }} > dist/${{ matrix.artifact }}.${{ matrix.archive_ext }}.sha256

      - name: Package (Windows)
        if: startsWith(matrix.os, 'windows')
        shell: pwsh
        run: |
          New-Item -ItemType Directory -Force dist | Out-Null
          Copy-Item target\${{ matrix.target }}\release\ldsc.exe dist\
          Copy-Item -Path LICENSE,README.md -Destination dist\
          Compress-Archive -Path dist\* -DestinationPath "dist\${{ matrix.artifact }}.${{ matrix.archive_ext }}"
          (Get-FileHash "dist\${{ matrix.artifact }}.${{ matrix.archive_ext }}" -Algorithm SHA256).Hash.ToLower() + "  ${{ matrix.artifact }}.${{ matrix.archive_ext }}" | Out-File -Encoding ASCII "dist\${{ matrix.artifact }}.${{ matrix.archive_ext }}.sha256"

      - name: Upload artifacts
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.artifact }}
          path: |
            dist/${{ matrix.artifact }}.${{ matrix.archive_ext }}
            dist/${{ matrix.artifact }}.${{ matrix.archive_ext }}.sha256

  release:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v4
        with:
          path: dist
          merge-multiple: true

      - name: Publish release assets
        uses: softprops/action-gh-release@v2
        with:
          files: dist/*