Skip to content

Commit 240cc60

Browse files
committed
Modernize pypi action
Change format to yaml Run it on pull requests to check all steps work Publish conditionally only on tag ref pushes Signed-off-by: Simo Sorce <[email protected]>
1 parent 491f448 commit 240cc60

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
1-
{
2-
"name": "Release to PyPI",
3-
"on": {
4-
"push": {
5-
"tags": [ "v*.*" ]
6-
},
7-
},
8-
"jobs": {
9-
"pypi": {
10-
"name": "Publish Release",
11-
"runs-on": "ubuntu-latest",
12-
"steps": [
13-
{ "uses": "actions/checkout@v2" },
14-
{
15-
"uses": "actions/setup-python@v2",
16-
"with": {
17-
"python-version": "3.10"
18-
},
19-
},
20-
{ "run": "sudo apt-get update" },
21-
{ "run": "sudo apt-get install cargo" },
22-
{ "run": "pip --version" },
23-
{ "run": "python setup.py sdist" },
24-
{ "run": "python setup.py bdist_wheel" },
25-
{
26-
"uses": "pypa/gh-action-pypi-publish@release/v1",
27-
"with": {
28-
"user": "__token__",
29-
"password": "${{secrets.PYPI_API_TOKEN}}",
30-
"skip-existing": true,
31-
},
32-
},
33-
],
34-
},
35-
},
36-
}
1+
---
2+
name: Release to PyPI
3+
4+
on:
5+
push:
6+
tags: [ "v*.*" ]
7+
pull_request:
8+
branches: ["main"]
9+
10+
jobs:
11+
pypi:
12+
name: Publish Release
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v4
19+
- name: Setup
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.11'
23+
- name: Make distribution
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install cargo
27+
pip --version
28+
pip install wheel
29+
python setup.py sdist
30+
python setup.py bdist_wheel
31+
- name: Publish on pypi (only for tag pushes)
32+
if: startsWith(github.ref, 'refs/tags')
33+
uses: pypa/gh-action-pypi-publish@release/v1
34+
with:
35+
user: __token__
36+
password: ${{secrets.PYPI_API_TOKEN}}
37+
skip-existing: true

0 commit comments

Comments
 (0)