ldsc 0.2.1

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

on:
  push:
    branches: [main]
    tags: ["v*"]
  pull_request:
    branches: [main]

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - uses: actions/checkout@v4

      # BuildKit is required for --mount=type=cache in the Dockerfile.
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      # Only log in when we intend to push (not on pull requests).
      - name: Log in to GitHub Container Registry
        if: github.event_name != 'pull_request'
        uses: docker/login-action@v3
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      # Derive image tags and OCI labels from Git context.
      #   push to main  → ghcr.io/OWNER/ldsc:main + :sha-XXXXXXX
      #   push of v1.2.3 → ghcr.io/OWNER/ldsc:1.2.3 + :1.2 + :latest
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          tags: |
            type=ref,event=branch
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=sha

      # Build (and optionally push) using GitHub Actions cache for Docker layers.
      # The Dockerfile's --mount=type=cache entries (sccache, cargo registry)
      # persist on the runner via the GHA cache backend.
      - name: Build and push
        uses: docker/build-push-action@v6
        with:
          context: .
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=gha
          cache-to: type=gha,mode=max