Skip to content

PSR in a github action and uv.lock #1097

Closed

Description

@aptly-io

Question

I've a github action python-semantic-release/python-semantic-release@v9. It updates the version in pyproject.toml, commits and tags this.

But now the uv.lock is no longer in sync: uv lock should have been called.

Is there a way that PSR can invoke additional commands to perform this and then also commit the updated uv.lock file?

Or should one create an additional github action step after the PSR process?

Someone has another suggestion?

Thanks!

Configuration

The github action looks like

      - name: Find version, stamp version, commit version, tag version
        uses: python-semantic-release/python-semantic-release@v9
        id: versioned
        with:
          changelog: false # no changelog generation (--no-changelog)
          vcs_release: false # no github release (--no-vcs-release)
          build: true

Activity

  1. codejedi365 commented on Nov 13, 2024

    @codejedi365
    Contributor

    I feel like I'm missing something. Why would uv lock be called--because the version changed? PSR only builds the distribution artifact via the user configured build command and modifies files with a version number. Otherwise it does not handle any modification to your virtual environment (unless otherwise user-defined). PSR is also not designed to be aware of pip, uv or poetry or to interface them at all internally.

    To solve this you can either modify the build command or add a step after to install the built distribution into your environment.

    If you add some additional steps to your build_command configuration you can run whatever commands need to occur. But do note that the PSR GitHub action is a Docker action, meaning the build command is run inside of a container. uv is not installed in the container so if you need it, you need to make sure it's installed as one of the first steps of the build command. Yes, it's not intuitive and not ideal but that's the current situation for the docker action.

  2. codejedi365 commented on Nov 13, 2024

    @codejedi365
    Contributor

    Thinking a little bit more about this. You need uv.lock updated because the next repo installation is broken because of mismatched files. So to solve this in your build_command you will need to run uv lock and add the lock file to the index.

    # pyproject.toml
    [tool.semantic_release]
    build_command = """
    pip install uv 
    uv lock
    git add uv.lock
    <build command>
    """

    Because the file is added to the index during the build command, it will be included in the commit that is created by PSR.

    Prior to the build command the repo files are stamped with the new version so when you run uv lock in the build command it should update properly.

  3. added and removed
    triagewaiting for initial maintainer review
    on Nov 13, 2024
  4. aptly-io commented on Nov 13, 2024

    @aptly-io
    Author

    Hi @codejedi365 many thanks; your swift solution worked like a charm! The uv.lock is now back in sync with the pyproject.toml when finishing the PSR github action.

  5. codejedi365 commented on Nov 13, 2024

    @codejedi365
    Contributor

    @aptly-io, great to hear, thanks for replying and closing. Cheers!

  6. beaugunderson commented on Feb 13, 2025

    @beaugunderson

    This fixed our issue as well, we ended up using this build_command; adding in cases it helps the next searcher:

    build_command = """
    uv lock
    git add uv.lock
    uv build
    """
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions