Skip to content

Commit ac816b3

Browse files
committed
Enable publishing to pypi
1 parent 034990f commit ac816b3

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.github/workflows/publish.yml

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

0 commit comments

Comments
 (0)