Skip to content

Commit 807d454

Browse files
committed
Update actions to test, build and publish on pypi.org
1 parent 28d76c6 commit 807d454

File tree

2 files changed

+78
-9
lines changed

2 files changed

+78
-9
lines changed
Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
1+
# This workflow runs whenever a new tag is pushed.
2+
# It will install Python dependencies, run tests and lint with a variety of Python versions
3+
# If tests pass, it will build the package and publish it on pypi.org
34

45
name: Python package
56

67
on:
78
push:
8-
branches: [ '*' ]
9-
pull_request:
10-
branches: [ $default-branch ]
9+
tags:
10+
- 'v*'
1111

1212
jobs:
13-
build:
14-
13+
test:
1514
runs-on: ubuntu-latest
1615
strategy:
1716
fail-fast: false
1817
matrix:
1918
python-version: ["3.10", "3.11", "3.12", "3.13"]
2019

2120
steps:
22-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v5
2322
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v5
2524
with:
2625
python-version: ${{ matrix.python-version }}
2726
- name: Install dependencies
@@ -30,3 +29,42 @@ jobs:
3029
python -m pip install tox
3130
- name: tox
3231
run: tox
32+
33+
build:
34+
name: Build package for PyPI
35+
runs-on: ubuntu-latest
36+
needs: test
37+
steps:
38+
- uses: actions/checkout@v5
39+
- name: Set up Python ${{ matrix.python-version }}
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: '3.11'
43+
- name: Build release
44+
run: |
45+
python -m pip install --upgrade build
46+
python -m build
47+
- name: Upload dist
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: release-dists
51+
path: dist/
52+
53+
publish:
54+
name: Publish package to PyPI
55+
runs-on: ubuntu-latest
56+
needs: build
57+
steps:
58+
- name: Retrieve dist
59+
uses: actions/download-artifact@v5
60+
with:
61+
name: release-dists
62+
path: dist/
63+
- name: Push to pypi
64+
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
65+
uses: pypa/gh-action-pypi-publish@release/v1.13
66+
with:
67+
user: __token__
68+
password: ${{ secrets.PYPI_API_TOKEN }}
69+
verbose: true
70+

.github/workflows/test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
branches: [ '*' ]
9+
pull_request:
10+
branches: [ $default-branch ]
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
python-version: ["3.10", "3.11", "3.12", "3.13"]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
python -m pip install tox
30+
- name: tox
31+
run: tox

0 commit comments

Comments
 (0)