Skip to content

Commit 1354df4

Browse files
authored
Merge pull request #7329 from pradyunsg/misc/nox-upload-command
Add a `nox -s upload-release` command and switch the release process to it
2 parents deecb36 + 1308270 commit 1354df4

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

docs/html/development/release-process.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ Creating a new release
8080
----------------------
8181

8282
#. Checkout the current pip ``master`` branch.
83-
#. Ensure you have the latest ``nox`` and ``twine`` installed.
83+
#. Ensure you have the latest ``nox`` installed.
8484
#. Prepare for release using ``nox -s prepare-release -- YY.N``.
8585
This will update the relevant files and tag the correct commit.
8686
#. Build the release artifacts using ``nox -s build-release -- YY.N``.
8787
This will checkout the tag, generate the distribution files to be
8888
uploaded and checkout the master branch again.
89-
#. Upload the distribution files to PyPI using ``twine upload dist/*``.
89+
#. Upload the release to PyPI using ``nox -s upload-release -- YY.N``.
9090
#. Push all of the changes including the tag.
9191
#. Regenerate the ``get-pip.py`` script in the `get-pip repository`_ (as
9292
documented there) and commit the results.

noxfile.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def prepare_release(session):
189189
def build_release(session):
190190
version = release.get_version_from_arguments(session.posargs)
191191
if not version:
192-
session.error("Usage: nox -s upload-release -- YY.N[.P]")
192+
session.error("Usage: nox -s build-release -- YY.N[.P]")
193193

194194
session.log("# Ensure no files in dist/")
195195
if release.have_files_in_folder("dist"):
@@ -209,3 +209,36 @@ def build_release(session):
209209

210210
session.log("# Checkout the master branch")
211211
session.run("git", "checkout", "master", external=True, silent=True)
212+
213+
214+
@nox.session(name="upload-release")
215+
def upload_release(session):
216+
version = release.get_version_from_arguments(session.posargs)
217+
if not version:
218+
session.error("Usage: nox -s upload-release -- YY.N[.P]")
219+
220+
session.log("# Install dependencies")
221+
session.install("twine")
222+
223+
distribution_files = glob.glob("dist/*")
224+
session.log(f"# Distribution files: {distribution_files}")
225+
226+
# Sanity check: Make sure there's 2 distribution files.
227+
count = len(distribution_files)
228+
if count != 2:
229+
session.error(
230+
f"Expected 2 distribution files for upload, got {count}. "
231+
f"Remove dist/ and run 'nox -s build-release -- {version}'"
232+
)
233+
# Sanity check: Make sure the files are correctly named.
234+
expected_distribution_files = [
235+
f"pip-{version}-py2.py3-none-any.whl",
236+
f"pip-{version}.tar.gz",
237+
]
238+
if sorted(distribution_files) != sorted(expected_distribution_files):
239+
session.error(
240+
f"Distribution files do not seem to be for {version} release."
241+
)
242+
243+
session.log("# Upload distributions")
244+
session.run("twine", "upload", *distribution_files)

0 commit comments

Comments
 (0)