Skip to content

Commit a5e5a7d

Browse files
committed
add publish workflow
1 parent e63d128 commit a5e5a7d

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/workflows/publish.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
name: Build distribution 📦
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.x"
18+
- name: Install pypa/build
19+
run: >-
20+
python3 -m
21+
pip install
22+
build
23+
--user
24+
- name: Build a binary wheel and a source tarball
25+
run: python3 -m build
26+
- name: Store the distribution packages
27+
uses: actions/upload-artifact@v3
28+
with:
29+
name: python-package-distributions
30+
path: dist/
31+
32+
publish-to-pypi:
33+
name: >-
34+
Publish Python 🐍 distribution 📦 to PyPI
35+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
36+
needs:
37+
- build
38+
runs-on: ubuntu-latest
39+
environment:
40+
name: pypi
41+
url: https://pypi.org/p/smrt
42+
permissions:
43+
id-token: write # IMPORTANT: mandatory for trusted publishing
44+
45+
steps:
46+
- name: Download all the dists
47+
uses: actions/[email protected]
48+
with:
49+
name: python-package-distributions
50+
path: dist/
51+
- name: Publish distribution 📦 to PyPI
52+
uses: pypa/gh-action-pypi-publish@release/v1
53+
54+
55+
56+
# publish-to-testpypi:
57+
# name: Publish Python 🐍 distribution 📦 to TestPyPI
58+
# needs:
59+
# - build
60+
# runs-on: ubuntu-latest
61+
#
62+
# environment:
63+
# name: testpypi
64+
# url: https://test.pypi.org/p/smrt
65+
#
66+
# permissions:
67+
# id-token: write # IMPORTANT: mandatory for trusted publishing
68+
#
69+
# steps:
70+
# - name: Download all the dists
71+
# uses: actions/[email protected]
72+
# with:
73+
# name: python-package-distributions
74+
# path: dist/
75+
# - name: Publish distribution 📦 to TestPyPI
76+
# uses: pypa/gh-action-pypi-publish@release/v1
77+
# with:
78+
# repository-url: https://test.pypi.org/legacy/
79+
80+

0 commit comments

Comments
 (0)