Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.7 KB
Raw Blame
name: Set up uv
description: |
    Installs CI's exact uv version and optionally restores its cache.

    The exact pin makes installs reproducible. setup-uv v10.3.2 resolves
    downloads through Astral's static manifest, not the GitHub releases API.
    Jobs that check out an older revision must install uv directly: this
    action does not exist in those trees.

    Defaults suit the root Python project: cache against uv.lock and save
    only on master. Tool-only jobs should disable dependency caching.

inputs:
    enable-cache:
        description: Whether to use the uv cache
        required: false
        default: 'true'
    cache-dependency-glob:
        description: Files used to calculate the uv cache key
        required: false
        default: uv.lock
    save-cache:
        description: Whether to save the uv cache after the job
        required: false
        default: ${{ github.ref == 'refs/heads/master' && github.event_name != 'api' }}

outputs:
    cache-hit:
        description: Whether a matching cache entry was restored
        value: ${{ steps.setup-uv.outputs.cache-hit }}

runs:
    using: composite
    steps:
        - name: Install uv
          id: setup-uv
          uses: astral-sh/setup-uv@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
          with:
              version: '0.13.4'
              enable-cache: ${{ inputs.enable-cache }}
              cache-dependency-glob: ${{ inputs.cache-dependency-glob }}
              save-cache: ${{ inputs.save-cache }}
              # Keeps only wheels built from source. The pre-built wheels of uv.lock total about
              # 1 GB, and every job downloads them faster than it restores them from the cache.
              prune-cache: true