1+ ---
2+ name : Build & upload PyPI package
3+
4+ on :
5+ push :
6+ branches : [main]
7+ tags : ["*"]
8+ release :
9+ types :
10+ - published
11+ workflow_dispatch :
12+
13+
14+ jobs :
15+ lint :
16+ uses : " ./.github/workflows/test.yaml"
17+ tests :
18+ uses : " ./.github/workflows/lint.yaml"
19+ variants :
20+ uses : " ./.github/workflows/variants.yaml"
21+ typecheck :
22+ uses : " ./.github/workflows/typecheck.yaml"
23+
24+ # Always build & lint package.
25+ build-package :
26+ name : Build & verify package
27+ needs :
28+ - tests
29+ runs-on : ubuntu-latest
30+ permissions :
31+ attestations : write
32+ id-token : write
33+
34+ steps :
35+ - uses : actions/checkout@v4
36+ with :
37+ fetch-depth : 0
38+ persist-credentials : false
39+
40+ - uses : hynek/build-and-inspect-python-package@v2
41+ with :
42+ attest-build-provenance-github : ' true'
43+
44+ # Upload to Test PyPI on every commit on main.
45+ release-test-pypi :
46+ name : Publish in-dev package to test.pypi.org
47+ environment : release-test-pypi
48+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
49+ runs-on : ubuntu-latest
50+ needs :
51+ - build-package
52+ permissions :
53+ id-token : write
54+
55+ steps :
56+ - name : Download packages built by build-and-inspect-python-package
57+ uses : actions/download-artifact@v4
58+ with :
59+ name : Packages
60+ path : dist
61+
62+ - name : Upload package to Test PyPI
63+ uses : pypa/gh-action-pypi-publish@release/v1
64+ with :
65+ repository-url : https://test.pypi.org/legacy/
66+
67+ # Upload to real PyPI on GitHub Releases.
68+ release-pypi :
69+ name : Publish released package to pypi.org
70+ environment : release-pypi
71+ if : github.event.action == 'published'
72+ runs-on : ubuntu-latest
73+ needs :
74+ - build-package
75+ permissions :
76+ id-token : write
77+
78+ steps :
79+ - name : Download packages built by build-and-inspect-python-package
80+ uses : actions/download-artifact@v4
81+ with :
82+ name : Packages
83+ path : dist
84+
85+ - name : Upload package to PyPI
86+ uses : pypa/gh-action-pypi-publish@release/v1
87+ docs :
88+ needs :
89+ - release-pypi
90+ uses : " ./.github/workflows/docs.yaml"
0 commit comments