Debian Codegraph @

.github/workflows/pypi-package.yml

raw
1 ---
2 name: Build & maybe upload PyPI package
3
4 on:
5 push:
6 branches: [master]
7 tags: ["*"]
8 pull_request:
9 branches: [master]
10 release:
11 types:
12 - published
13 workflow_dispatch:
14
15 permissions:
16 contents: read
17 # Needed for trusted publishing.
18 id-token: write
19
20 jobs:
21 # Always build & lint package.
22 build-package:
23 name: Build & verify package
24 runs-on: ubuntu-latest
25
26 steps:
27 - uses: actions/checkout@v6
28 with:
29 fetch-depth: 0
30
31 - uses: hynek/build-and-inspect-python-package@v2
32
33 # Upload to Test PyPI on every commit on master.
34 release-test-pypi:
35 name: Publish in-dev package to test.pypi.org
36 environment: release-test-pypi
37 if: github.repository_owner == 'jpadilla' && github.event_name == 'push' && github.ref == 'refs/heads/master'
38 runs-on: ubuntu-latest
39 needs: build-package
40
41 steps:
42 - name: Download packages built by build-and-inspect-python-package
43 uses: actions/download-artifact@v8
44 with:
45 name: Packages
46 path: dist
47
48 - name: Upload package to Test PyPI
49 uses: pypa/gh-action-pypi-publish@release/v1
50 with:
51 repository-url: https://test.pypi.org/legacy/
52
53 # Upload to real PyPI on GitHub Releases.
54 release-pypi:
55 name: Publish released package to pypi.org
56 environment: release-pypi
57 if: github.repository_owner == 'jpadilla' && github.event.action == 'published'
58 runs-on: ubuntu-latest
59 needs: build-package
60
61 steps:
62 - name: Download packages built by build-and-inspect-python-package
63 uses: actions/download-artifact@v8
64 with:
65 name: Packages
66 path: dist
67
68 - name: Upload package to PyPI
69 uses: pypa/gh-action-pypi-publish@release/v1