Skip to content

Commit 7d899c9

Browse files
Merge pull request #1028 from VWS-Python/gha-pypi-release
Switch to GitHub actions for releasing to PyPI
2 parents b13a49b + bdb714b commit 7d899c9

File tree

6 files changed

+48
-52
lines changed

6 files changed

+48
-52
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
3+
name: Publish Python distributions to PyPI
4+
5+
on: push
6+
7+
jobs:
8+
build:
9+
name: Publish Python distributions to PyPI
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
python-version: ["3.10"]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: "Set up Python"
20+
uses: actions/setup-python@v1
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install pypa/build
25+
run: >-
26+
python -m
27+
pip install
28+
build
29+
--user
30+
- name: Build a binary wheel and a source tarball
31+
run: >-
32+
python -m
33+
build
34+
--sdist
35+
--wheel
36+
--outdir dist/
37+
.
38+
39+
- name: Publish distribution 📦 to PyPI
40+
if: startsWith(github.ref, 'refs/tags')
41+
uses: pypa/gh-action-pypi-publish@master
42+
with:
43+
password: ${{ secrets.PYPI_API_TOKEN }}
44+
verbose: true

admin/release.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import datetime
66
import os
7-
import subprocess
87
from pathlib import Path
98

109
from github import Github
@@ -58,21 +57,6 @@ def update_changelog(version: str, github_repository: Repository) -> None:
5857
)
5958

6059

61-
def build_and_upload_to_pypi() -> None:
62-
"""
63-
Build source and binary distributions.
64-
"""
65-
for args in (
66-
['git', 'fetch', '--tags'],
67-
['git', 'merge', 'origin/master'],
68-
['rm', '-rf', 'build'],
69-
['git', 'status'],
70-
['python', 'setup.py', 'sdist', 'bdist_wheel'],
71-
['twine', 'upload', '-r', 'pypi', 'dist/*'],
72-
):
73-
subprocess.run(args=args, check=True)
74-
75-
7660
def main() -> None:
7761
"""
7862
Perform a release.
@@ -94,7 +78,6 @@ def main() -> None:
9478
type='commit',
9579
object=github_repository.get_commits()[0].sha,
9680
)
97-
build_and_upload_to_pypi()
9881

9982

10083
if __name__ == '__main__':

docs/source/release-process.rst

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,6 @@ Prerequisites
1818
Perform a Release
1919
~~~~~~~~~~~~~~~~~
2020

21-
#. Install keyring
22-
23-
Make sure that `keyring <https://pypi.org/project/keyring/>`__ is available on your path.
24-
25-
E.g.:
26-
27-
.. prompt:: bash
28-
29-
python3 -m pip install --user pipx
30-
python3 -m pipx ensurepath
31-
pipx install keyring
32-
33-
#. Set up PyPI credentials
34-
35-
Register at `PyPI <https://pypi.org>`__.
36-
37-
Add the following information to :file:`~/.pypirc`.
38-
39-
.. code:: ini
40-
41-
[distutils]
42-
index-servers=
43-
pypi
44-
45-
[pypi]
46-
username = <Your PyPI username>
47-
48-
Store your PyPI password:
49-
50-
.. prompt:: bash
51-
52-
keyring set https://upload.pypi.org/legacy/ <Your PyPI username>
53-
5421
#. Get a GitHub access token:
5522

5623
Follow the `GitHub access token instructions`_ for getting an access token.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ ignore_path = [
181181
"./src/*/_setuptools_scm_version.txt",
182182
]
183183

184+
[tool.setuptools_scm]
185+
186+
184187
[tool.pydocstyle]
185188
# We do not have summary lines, care about "mood", or need sections with
186189
# dash underlined titles.

requirements/dev-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ sphinx-autodoc-typehints==1.12.0
3030
sphinx_paramlinks==0.5.2
3131
sphinxcontrib-httpdomain==1.8.0
3232
sphinxcontrib-spelling==7.3.0
33-
twine==3.7.1
3433
types-Flask==1.1.6
3534
types-freezegun==1.1.3
3635
types-PyYAML==6.0.1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _get_dependencies(requirements_file: Path) -> list[str]:
3535
# We use a dictionary with a fallback version rather than "True"
3636
# like https://github.com/pypa/setuptools_scm/issues/77 so that we do not
3737
# error in Docker.
38-
use_scm_version={'fallback_version': 'FALLBACK_VERSION'},
38+
# use_scm_version={'fallback_version': 'FALLBACK_VERSION'},
3939
setup_requires=SETUP_REQUIRES,
4040
install_requires=INSTALL_REQUIRES,
4141
extras_require={'dev': DEV_REQUIRES},

0 commit comments

Comments
 (0)