Skip to content

Commit 83f3542

Browse files
committed
Add a GitHub workflow for pushing to PyPI and Test PyPI
In this commit I'm adding a new workflow which will build distributable packages for pytest-localserver and upload them to PyPI and Test PyPI. The uploads are treated as deployments, so they will not run until someone manually approves them. A future enhancement I'd like to make is to actually run tests using the same package that is going to be uploaded. That's going to involve tweaking tox to install from a prebuilt package rather than directly from the source code, so it will take some time to figure that out.
1 parent bbdc9d5 commit 83f3542

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish package to PyPI
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
build:
10+
name: Build distribution packages
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Python 3.10
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.10"
18+
- name: Install pypa/build
19+
run: |
20+
python -m pip install --user build
21+
- name: Build packages
22+
run: |
23+
pyproject-build
24+
- uses: actions/upload-artifact@v3
25+
with:
26+
name: dist
27+
path: dist/
28+
if-no-files-found: error
29+
publish-to-test-pypi:
30+
name: Publish packages to Test PyPI
31+
runs-on: ubuntu-latest
32+
needs: [build]
33+
environment: test-pypi
34+
steps:
35+
- uses: actions/download-artifact@v3
36+
with:
37+
name: dist
38+
path: dist/
39+
- name: Publish packages to Test PyPI
40+
uses: pypa/gh-action-pypi-publish@release/v1
41+
with:
42+
password: '${{ secrets.TEST_PYPI_API_TOKEN }}'
43+
repository_url: https://test.pypi.org/legacy/
44+
print_hash: true
45+
publish-to-pypi:
46+
name: Publish packages to PyPI
47+
runs-on: ubuntu-latest
48+
needs: [build]
49+
environment: pypi
50+
steps:
51+
- uses: actions/download-artifact@v3
52+
with:
53+
name: dist
54+
path: dist/
55+
- name: Publish packages to PyPI
56+
uses: pypa/gh-action-pypi-publish@release/v1
57+
with:
58+
password: '${{ secrets.PYPI_API_TOKEN }}'
59+
print_hash: true

0 commit comments

Comments
 (0)