Debian Codegraph @

.github/workflows/pypi_upload.yml

raw
1 name: build and publish
2
3 on:
4 release:
5 types: published
6 pull_request:
7 push:
8 branches: main
9
10 permissions: {}
11
12 env:
13 PROJECT: https://pypi.org/p/black
14
15 jobs:
16 configure:
17 name: generate wheels matrix
18 runs-on: ubuntu-latest
19 outputs:
20 include: ${{ steps.set-matrix.outputs.include }}
21 steps:
22 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23 with:
24 persist-credentials: false
25
26 - name: Set up latest Python
27 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
28 with:
29 python-version: "3.13"
30 pip-version: "25.3"
31 pip-install: --group cibw
32
33 - name: generate matrix
34 if: |
35 github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ci: build all wheels')
36 run: |
37 {
38 cibuildwheel --print-build-identifiers --platform linux \
39 | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \
40 && cibuildwheel --print-build-identifiers --platform macos \
41 | pyp 'json.dumps({"only": x, "os": "macos-latest"})' \
42 && cibuildwheel --print-build-identifiers --platform windows \
43 | pyp 'json.dumps({"only": x, "os": "windows-latest"})' \
44 && cibuildwheel --print-build-identifiers --platform windows --archs ARM64 \
45 | pyp 'json.dumps({"only": x, "os": "windows-11-arm"})'
46 } | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix
47 env:
48 CIBW_ARCHS_LINUX: x86_64
49 CIBW_ARCHS_MACOS: x86_64 arm64
50 CIBW_ARCHS_WINDOWS: AMD64
51
52 - name: generate matrix (PR)
53 if: |
54 github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'ci: build all wheels')
55 run: |
56 {
57 CIBW_BUILD="cp310-*" cibuildwheel --print-build-identifiers --platform linux | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})'
58 CIBW_BUILD="cp314-*" cibuildwheel --print-build-identifiers --platform windows | pyp 'json.dumps({"only": x, "os": "windows-latest"})'
59 } | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix
60 env:
61 CIBW_ARCHS_LINUX: x86_64
62
63 - id: set-matrix
64 run: echo "include=$(cat /tmp/matrix)" | tee -a $GITHUB_OUTPUT
65
66 mypyc:
67 name: mypyc wheels ${{ matrix.only }}
68 needs: configure
69 runs-on: ${{ matrix.os }}
70 strategy:
71 matrix:
72 include: ${{ fromJson(needs.configure.outputs.include) }}
73
74 steps:
75 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
76 with:
77 persist-credentials: false
78
79 - name: Set up latest Python
80 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
81 with:
82 python-version: "3.13"
83 pip-version: "25.3"
84 pip-install: --group cibw
85
86 - name: Run cibuildwheel
87 run: cibuildwheel . --only ${{ matrix.only }}
88
89 - name: Upload wheels as workflow artifacts
90 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
91 with:
92 name: ${{ matrix.only }}-mypyc-wheels
93 path: wheelhouse/
94
95 hatch:
96 name: sdist + pure wheel
97 runs-on: ubuntu-latest
98
99 steps:
100 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
101 with:
102 persist-credentials: false
103
104 - name: Set up latest Python
105 uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
106 with:
107 python-version: "3.13"
108 pip-version: "25.3"
109 pip-install: --group hatch
110
111 - name: Build wheel and source distributions
112 run: python -m hatch build
113
114 - name: Store the distribution packages
115 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
116 with:
117 name: sdist-and-pure-wheel
118 path: dist/
119
120 publish-mypyc:
121 if: github.event_name == 'release'
122 needs: mypyc
123 runs-on: ubuntu-latest
124 environment:
125 name: release
126 url: ${{ env.PROJECT }}
127 permissions:
128 id-token: write # Required for PyPI trusted publishing
129 steps:
130 - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
131 with:
132 pattern: "*-mypyc-wheels"
133 path: wheelhouse/
134 merge-multiple: true
135
136 - name: Publish package distributions to PyPI
137 uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
138 with:
139 packages-dir: wheelhouse/
140 verbose: true
141
142 publish-hatch:
143 if: github.event_name == 'release'
144 needs: hatch
145 runs-on: ubuntu-latest
146 environment:
147 name: release
148 url: ${{ env.PROJECT }}
149 permissions:
150 id-token: write # Required for PyPI trusted publishing
151 steps:
152 - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
153 with:
154 name: sdist-and-pure-wheel
155 path: dist/
156
157 - name: Publish package distributions to PyPI
158 uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
159 with:
160 verbose: true