Skip to content

Commit 09ef145

Browse files
authored
Update GitHub Actions workflow for PyPI publishing
1 parent b43e9ab commit 09ef145

File tree

1 file changed

+32
-35
lines changed

1 file changed

+32
-35
lines changed

.github/workflows/publish.yml

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
1-
name: Build and deploy
1+
name: Publish to PyPI
22

33
on:
44
workflow_dispatch:
5-
# push:
6-
# # Sequence of patterns matched against refs/tags
7-
# tags:
8-
# - '[0-9]+.[0-9]+.[0-9]+' # Push events to any matching semantic tag. For example, 1.10.1 or 2.0.0.
95
release:
10-
types:
11-
- published
6+
types: [published]
127

138
jobs:
14-
dist:
9+
build:
10+
name: Build distribution
1511
runs-on: ubuntu-latest
12+
1613
steps:
17-
- uses: actions/checkout@v1
14+
- uses: actions/checkout@v4
1815

19-
- name: Build wheel and SDist
20-
run: pipx run build
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
2120

22-
- uses: actions/upload-artifact@v4
23-
with:
24-
path: dist/*
21+
- name: Install build
22+
run: pip install build
2523

26-
- name: Check metadata
27-
run: pipx run twine check dist/*
24+
- name: Build sdist and wheel
25+
run: python -m build
2826

27+
- name: Upload dist artifacts
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: dist
31+
path: dist/
2932

3033
publish:
31-
needs: [dist]
34+
name: Publish to PyPI
35+
needs: build
3236
runs-on: ubuntu-latest
33-
# upload to PyPI on every tag starting with 'v'
34-
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
35-
# alternatively, to publish when a GitHub Release is created, use the following rule:
36-
if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch'
37+
environment: release
38+
permissions:
39+
id-token: write # required for OIDC trusted publishing
3740

3841
steps:
39-
- uses: actions/download-artifact@v4
40-
with:
41-
name: artifact
42-
path: dist
43-
44-
- name: Publish distribution 📦 to PyPI
45-
uses: pypa/gh-action-pypi-publish@v1.9.0
46-
with:
47-
password: ${{ secrets.PYPI_API_TOKEN_PYCBA }}
48-
# remove following once testing complete
49-
# user: __token__
50-
# password: ${{ secrets.TEST_PYPI_API_TOKEN_PYCBA }}
51-
# repository_url: https://test.pypi.org/legacy/
52-
42+
- name: Download dist artifacts
43+
uses: actions/download-artifact@v4
44+
with:
45+
name: dist
46+
path: dist/
47+
48+
- name: Publish to PyPI
49+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)