Skip to content

Hooks for running commands after files update #1102

@S1M0N38

Description

@S1M0N38

Question: Is there a way to update generated files during release PR creation?

Context

I have a Python project using Astral's uv for dependency management. When release-please creates a new version, I need to update uv.lock to match.

Currently, this happens in a separate commit after release:

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: write
  pull-requests: write

name: Release tag

jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: googleapis/release-please-action@v4
        id: release
        with:
          token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
          release-type: python

      - uses: actions/checkout@v4
        if: ${{ steps.release.outputs.release_created }}
        with:
          fetch-depth: 0
          ref: main

      - name: Install uv
        if: ${{ steps.release.outputs.release_created }}
        uses: astral-sh/setup-uv@v5

      - name: Configure Git
        if: ${{ steps.release.outputs.release_created }}
        run: |
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"

      - name: Update lock file
        if: ${{ steps.release.outputs.release_created }}
        run: uv lock

      - name: Commit and push updated lock file
        if: ${{ steps.release.outputs.release_created }}
        run: |
          if [[ -n $(git status --porcelain uv.lock) ]]; then
            git add uv.lock
            git commit -m "chore(deps): update uv.lock for version ${{ steps.release.outputs.version }}"
            git push
          else
            echo "No changes to uv.lock"
          fi

Why updating after tag is problematic

Updating the lock file after the release tag creates several issues:

  1. The tagged release doesn't match the actual dependencies needed for the version
  2. Anyone checking out the tag will get an incorrect/outdated uv.lock file
  3. Build reproducibility is compromised as the lock file isn't synchronized with the code version
  4. The separate commit creates a state in the repository that wasn't properly tested before release

Question

Does release-please have any hooks or mechanisms to run commands (like uv lock) during PR creation, allowing generated files to be included in the release PR itself rather than added after the tag?

Environment

  • Python project using astral.sh uv
  • Using release-please-action@v4 with release-type: python

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: questionRequest for information or clarification. Not an issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions