Skip to content
🎉 GoReleaser v2.18 is out! with release summaries, preflight checks, OpenTelemetry traces, and more!

UV

Since v2.9.

You can now build Python wheel and sdist files using uv build and GoReleaser!

Simply set the builder to uv and set the buildmode you want:

.goreleaser.yaml
builds:
  - builder: uv
    buildmode: wheel

The .whl and .tar.gz files can then be signed, checksummed, used inside Docker images, and more.

Options

.goreleaser.yaml
builds:
  # You can have multiple builds defined as a yaml list
  - #
    # ID of the build.
    #
    # Default: Project name.
    id: "my-build"

    # Use uv.
    builder: uv

    # Path to project's (sub)directory containing the code.
    # This is the working directory for the uv build command(s).
    #
    # Default: ".".
    dir: my-app

    # The build mode.
    #
    # Valid options: "wheel", "sdist".
    # Default: "wheel".
    buildmode: sdist

    # Set a specific uv binary to use when building.
    # It is safe to ignore this option in most cases.
    #
    # Default: "uv".
    # Templates: allowed.
    tool: uv

    # Sets the command to run to build.
    # Can be useful if you want to build tests, for example,
    # in which case you can set this to "test".
    # It is safe to ignore this option in most cases.
    #
    # Default: build.
    command: build

    # Custom flags.
    #
    # Templates: allowed.
    flags:
      - --offline

    # Custom environment variables to be set during the builds.
    # Invalid environment variables will be ignored.
    #
    # Default: os.Environ() ++ env config section.
    # Templates: allowed.
    env:
      - FOO=bar

    # Hooks can be used to customize the final binary,
    # for example, to run generators.
    #
    # Templates: allowed.
    hooks:
      pre: ./foo.sh
      post: ./script.sh {{ .Path }}

Warning

At this time only the GoReleaser target none-any is supported. py3-none-any is a wheel filename tag, not a GoReleaser target.

Building both wheel and sdist

You need to declare two builds, one for each mode:

.goreleaser.yaml
builds:
  - id: wheel
    builder: uv
    buildmode: wheel
  - id: sdist
    builder: uv
    buildmode: sdist

Publishing to PyPI

This feature is exclusively available with GoReleaser Pro.

You can publish with global after hooks. With GoReleaser OSS, use a separate publishing step in your CI workflow.

.goreleaser.yaml
# global after hooks
after:
  hooks:
    - cmd: "uv publish"
      if: "{{ .IsRelease }}"
Last updated on