The current release process for the pytest project involves two main scripts: `prepare-release-pr.py` and `release.py`. The first script, `prepare-release-pr.py`, is responsible for preparing a release pull request by creating a new release branch from a specified base branch, determining the next version number according to semantic versioning rules (major, minor/feature, patch), running the release tox environment with the appropriate template, pushing the branch to the remote repository, and opening a pull request on GitHub. The `release.py` script handles generating the release announcement documentation, regenerating the project's documentation examples and outputs, fixing formatting using pre-commit hooks, checking links in the docs, and creating the changelog with towncrier before committing all changes locally.
A notable problem arises due to the disjointed nature of these scripts: after the `prepare-release-pr.py` script creates the release branch and runs the release tox environment, the associated documentation generation, changelog updates, announcements, and formatting fixes done in `release.py` are not automatically integrated into the release pull request branch before pushing or pull request creation. This causes an incomplete release PR that lacks the updated documentation artifacts, changelog, and possibly proper commit formatting, forcing developers to manually re-run the second script or perform these steps later.
The task is to improve and integrate the release process such that upon preparing a release pull request with `prepare-release-pr.py`, the script will also invoke, at the appropriate point, the relevant functionality from `release.py` (or equivalent logic) to generate the release announcement, update docs, update the changelog, fix formatting, and optionally check links, so that the release PR branch is fully prepared with all necessary release artifacts before pushing and creating the PR. This must be accomplished without requiring the user to manually run the secondary script or perform additional steps after the PR creation.
The solution should carefully handle environment contexts (e.g., tox environments, git branch states), correctly pass the dynamically determined version, template names, and doc versions consistently between the scripts, and handle any errors gracefully. It should also maintain the current process flow such that if this integration is skipped/disabled, the scripts still work independently as before. This facilitates a smoother, more reliable, and more automated release preparation workflow requiring fewer manual interventions.
Checklist of factors a good miner agent should consider
Analyze the `prepare-release-pr.py` script to identify the point after the version is determined and the release branch is created and checked out where additional processing should be invoked.
Examine the `release.py` script to understand how the release announcement, docs regeneration, changelog update, formatting fixes, and link checks are performed and the parameters needed (version, template_name, doc_version).
Design an integrated approach in `prepare-release-pr.py` to call the necessary functions or subprocess commands to perform all the release preparation steps currently done by `release.py` after the release branch has been created and checked out, but before pushing and creating the PR.
Ensure environment variables and contexts used in the secondary script (`release.py`) are appropriately set in the integrated calls, especially for tox environments and git state.
Maintain the ability to pass command-line flags such as `--skip-check-links` from the initial release preparation invocation or make it configurable in the integrated process.
Test that the newly integrated release PR branch created includes all updated docs, changelog, and formatting fixes as expected before push.
Validate the error handling so if any sub-steps fail (e.g., docs regeneration or changelog creation), the process exits with an understandable error and does not push an incomplete release PR.
Ensure the commit author and email configurations remain correct when committing changes from the integrated steps within the release branch.
Preserve the existing command-line interface and usage patterns for `prepare-release-pr.py` with minimal additions, such that existing workflows are minimally disrupted.
Verify that authentication tokens and GitHub API usage remain correct and secure after integration, and that pull requests continue to be created with accurate descriptions and metadata.