Skip to content

Commit 61c52e0

Browse files
committed
Implemented automatic uploading to PyPI
Closes #388
1 parent 006142d commit 61c52e0

File tree

4 files changed

+91
-17
lines changed

4 files changed

+91
-17
lines changed

.github/workflows/release.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Build distribution 📦
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: "3.x"
16+
- name: Install pypa/build
17+
run: >-
18+
python3 -m
19+
pip install
20+
build
21+
--user
22+
- name: Build a binary wheel and a source tarball
23+
run: python3 -m build
24+
- name: Store the distribution packages
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: python-package-distributions
28+
path: dist/
29+
30+
publish-to-pypi:
31+
name: >-
32+
Publish Python 🐍 distribution 📦 to PyPI
33+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
34+
needs:
35+
- build
36+
runs-on: ubuntu-latest
37+
environment:
38+
name: pypi
39+
url: https://pypi.org/p/sphinx-autoapi
40+
permissions:
41+
id-token: write # IMPORTANT: mandatory for trusted publishing
42+
43+
steps:
44+
- name: Download all the dists
45+
uses: actions/download-artifact@v3
46+
with:
47+
name: python-package-distributions
48+
path: dist/
49+
- name: Publish distribution 📦 to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1
51+
52+
github-release:
53+
name: >-
54+
Sign the Python 🐍 distribution 📦 with Sigstore
55+
and upload them to GitHub Release
56+
needs:
57+
- publish-to-pypi
58+
runs-on: ubuntu-latest
59+
60+
permissions:
61+
contents: write # IMPORTANT: mandatory for making GitHub Releases
62+
id-token: write # IMPORTANT: mandatory for sigstore
63+
64+
steps:
65+
- name: Download all the dists
66+
uses: actions/download-artifact@v3
67+
with:
68+
name: python-package-distributions
69+
path: dist/
70+
- name: Sign the dists with Sigstore
71+
uses: sigstore/gh-action-sigstore-python@v1.2.3
72+
with:
73+
inputs: >-
74+
./dist/*.tar.gz
75+
./dist/*.whl
76+
- name: Upload artifact signatures to GitHub Release
77+
env:
78+
GITHUB_TOKEN: ${{ github.token }}
79+
# Upload to GitHub Release using the `gh` CLI.
80+
# `dist/` contains the built packages, and the
81+
# sigstore-produced signatures and certificates.
82+
run: >-
83+
gh release upload
84+
'${{ github.ref_name }}' dist/**
85+
--repo '${{ github.repository }}'

docs/changes/388.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implemented automatic uploading to PyPI

docs/maintenance/release-process.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ Preparation
2222
Release
2323
-------
2424

25-
.. code-block:: bash
26-
27-
git clean -idx
28-
tox -e release
29-
git tag vX.X.X
30-
git push --tags
25+
Create a new release in github that tags the commit
26+
and uses the built release notes as the description.
27+
The tag created by the release will trigger the github actions to
28+
build and upload the package to PyPI.

tox.ini

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,4 @@ deps =
6060
towncrier
6161
importlib-resources<6 # pinned due to https://github.com/twisted/towncrier/issues/528
6262
commands =
63-
towncrier {posargs:check}
64-
65-
[testenv:release]
66-
skip_install = true
67-
deps =
68-
build
69-
twine
70-
commands =
71-
python -c "import shutil, os; os.path.isdir('dist') and shutil.rmtree('dist')"
72-
python -m build
73-
twine upload dist/*
63+
towncrier {posargs:check}

0 commit comments

Comments
 (0)