|
| 1 | +# Release procedure |
| 2 | + |
| 3 | +The examples below release **2.3.1** after **2.3.0**. Replace the version |
| 4 | +numbers and release date as needed. Run commands from the repository root. |
| 5 | + |
| 6 | +Ensure the PyPI Trusted Publisher for `mysqlclient` is configured with |
| 7 | +repository `PyMySQL/mysqlclient`, workflow `windows.yaml`, and no required |
| 8 | +environment name. |
| 9 | + |
| 10 | +## 1. Update the release notes |
| 11 | + |
| 12 | +Review the changes since the previous release: |
| 13 | + |
| 14 | +```sh |
| 15 | +git log v2.3.0..HEAD --oneline |
| 16 | +git diff v2.3.0..HEAD --stat |
| 17 | +``` |
| 18 | + |
| 19 | +Add a `What's new in 2.3.1` section at the top of |
| 20 | +[HISTORY.rst](../HISTORY.rst), with `Release: YYYY-MM-DD` set to the release |
| 21 | +date. Document changes, fixes, and deprecations that affect users. |
| 22 | + |
| 23 | +## 2. Update the version and create a release PR |
| 24 | + |
| 25 | +Update both version fields in |
| 26 | +[src/MySQLdb/release.py](../src/MySQLdb/release.py): |
| 27 | + |
| 28 | +```python |
| 29 | +__version__ = "2.3.1" |
| 30 | +version_info = (2, 3, 1, "final", 0) |
| 31 | +``` |
| 32 | + |
| 33 | +Format the source and run the checks: |
| 34 | + |
| 35 | +```sh |
| 36 | +ruff format src/ |
| 37 | +ruff check src/ |
| 38 | +git diff --check |
| 39 | +``` |
| 40 | + |
| 41 | +Review the diff, commit it as `release v2.3.1`, and open a PR targeting |
| 42 | +`main` in `PyMySQL/mysqlclient`. |
| 43 | + |
| 44 | +## 3. Verify CI for the release commit |
| 45 | + |
| 46 | +Once the PR checks pass, merge it into `main`. Verify that all of the |
| 47 | +following workflows pass for the merged commit: |
| 48 | + |
| 49 | +- `Lint` |
| 50 | +- `Test`, including MySQL, MariaDB, and Django tests |
| 51 | +- `Build windows wheels` |
| 52 | + |
| 53 | +To run the tests locally, install the package and the dependencies in |
| 54 | +`requirements.txt`, prepare the database, and run the command used by the |
| 55 | +[test workflow](../.github/workflows/tests.yaml). Adjust `TESTDB` to use |
| 56 | +the configuration for your database: |
| 57 | + |
| 58 | +```sh |
| 59 | +TESTDB=actions.cnf pytest --cov=MySQLdb tests |
| 60 | +``` |
| 61 | + |
| 62 | +Verify that the [Windows workflow](../.github/workflows/windows.yaml) |
| 63 | +produces both `win-wheels-AMD64` and `win-wheels-ARM64` artifacts. The AMD64 |
| 64 | +artifact also contains the source distribution (sdist). |
| 65 | + |
| 66 | +Record the release commit SHA. |
| 67 | + |
| 68 | +## 4. Create and push the release tag |
| 69 | + |
| 70 | +Replace `RELEASE_SHA` with the commit SHA verified in step 3. Fetch the |
| 71 | +commit, create a lightweight tag, and push it: |
| 72 | + |
| 73 | +```sh |
| 74 | +git fetch upstream main --tags |
| 75 | +git tag v2.3.1 RELEASE_SHA |
| 76 | +git push upstream refs/tags/v2.3.1 |
| 77 | +``` |
| 78 | + |
| 79 | +Pushing the new `v*` tag starts a build of the tagged commit. Once both |
| 80 | +Windows builds succeed, the `Publish to PyPI` job combines their artifacts |
| 81 | +and publishes the wheels and sdist using Trusted Publishing. |
| 82 | +Publishing is restricted to push events that create a new `v*` tag. |
| 83 | + |
| 84 | +## 5. Verify publication and create the GitHub Release |
| 85 | + |
| 86 | +Check the tag-triggered `Build windows wheels` workflow and confirm that |
| 87 | +both builds and the `Publish to PyPI` job succeed. Then create the GitHub |
| 88 | +Release: |
| 89 | + |
| 90 | +```sh |
| 91 | +gh release create v2.3.1 -R PyMySQL/mysqlclient \ |
| 92 | + --verify-tag --title v2.3.1 \ |
| 93 | + --generate-notes --notes-start-tag v2.3.0 |
| 94 | +``` |
| 95 | + |
| 96 | +## 6. Verify the published release |
| 97 | + |
| 98 | +Check that PyPI lists the sdist and wheels for both architectures. Install |
| 99 | +`mysqlclient==2.3.1` in a fresh environment and verify the import and version: |
| 100 | + |
| 101 | +```sh |
| 102 | +python -c 'import MySQLdb; print(MySQLdb.version_info)' |
| 103 | +``` |
| 104 | + |
| 105 | +The expected output is `(2, 3, 1, 'final', 0)`. |
0 commit comments