Skip to content

Commit 3b31915

Browse files
authored
Add dedicated package build and publish action (#323)
1 parent 500d817 commit 3b31915

2 files changed

Lines changed: 56 additions & 31 deletions

File tree

.github/workflows/publish.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Build distribution 📦
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v6
12+
with:
13+
persist-credentials: false
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v6
17+
with:
18+
python-version: "3.x"
19+
20+
- name: Install pypa/build
21+
run: >-
22+
python3 -m
23+
pip install
24+
build
25+
--user
26+
27+
- name: Build a binary wheel and a source tarball
28+
run: python3 -m build
29+
30+
- name: Store the distribution packages
31+
uses: actions/upload-artifact@v5
32+
with:
33+
name: python-package-distributions
34+
path: dist/
35+
36+
publish-to-pypi:
37+
name: >-
38+
Publish Python 🐍 distribution 📦 to PyPI
39+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
40+
needs:
41+
- build
42+
runs-on: ubuntu-latest
43+
environment:
44+
name: pypi
45+
url: https://pypi.org/p/napari-matplotlib # Replace <package-name> with your PyPI project name
46+
permissions:
47+
id-token: write # IMPORTANT: mandatory for trusted publishing
48+
49+
steps:
50+
- name: Download all the dists
51+
uses: actions/download-artifact@v6
52+
with:
53+
name: python-package-distributions
54+
path: dist/
55+
- name: Publish distribution 📦 to PyPI
56+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -86,34 +86,3 @@ jobs:
8686
with:
8787
token: ${{ secrets.CODECOV_TOKEN }}
8888
fail_ci_if_error: false
89-
90-
deploy:
91-
# this will run when you have tagged a commit, starting with "v*"
92-
# and requires that you have put your twine API key in your
93-
# github secrets (see readme for details)
94-
needs: [test]
95-
runs-on: ubuntu-latest
96-
if: contains(github.ref, 'tags')
97-
environment: pypi-deploy
98-
permissions:
99-
id-token: write
100-
steps:
101-
- uses: actions/checkout@v6
102-
with:
103-
persist-credentials: false
104-
- name: Set up Python
105-
uses: actions/setup-python@v6
106-
with:
107-
python-version: "3.x"
108-
- name: Install build
109-
run: |
110-
python -m pip install --upgrade pip
111-
python -m pip install --upgrade build
112-
113-
- name: Build package
114-
run: |
115-
git tag
116-
python -m build .
117-
118-
- name: Publish package
119-
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

0 commit comments

Comments
 (0)