Debian Codegraph @

.github/workflows/pypi-package.yml

raw
1 ---
2 name: Build & maybe upload PyPI package
3
4 on:
5 push:
6 branches: [main]
7 tags: ["*"]
8 release:
9 types:
10 - published
11 workflow_dispatch:
12
13 permissions:
14 attestations: write
15 contents: read
16 id-token: write
17
18 jobs:
19 # Always build & lint package.
20 build-package:
21 name: Build & verify package
22 runs-on: ubuntu-latest
23
24 steps:
25 - uses: actions/checkout@v4
26 with:
27 fetch-depth: 0
28
29 - uses: hynek/build-and-inspect-python-package@v2
30 with:
31 attest-build-provenance-github: 'true'
32
33 # Upload to Test PyPI on every commit on main.
34 release-test-pypi:
35 name: Publish in-dev package to test.pypi.org
36 environment: release-test-pypi
37 if: github.event_name == 'push' && github.ref == 'refs/heads/main'
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@v4
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.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@v4
64 with:
65 name: Packages
66 path: dist
67
68 - name: Upload package to PyPI
69 uses: pypa/gh-action-pypi-publish@release/v1