1414 - ' pyproject.toml'
1515 - ' .github/workflows/wheels.yml'
1616 workflow_dispatch :
17+ inputs :
18+ publish_target :
19+ description : " Publish target (manual runs only)"
20+ required : true
21+ default : " none"
22+ type : choice
23+ options :
24+ - none
25+ - testpypi
1726
1827jobs :
1928 build_wheels :
2534 include :
2635 - os : ubuntu-latest
2736 cibw_archs : " x86_64"
28- - os : macos-latest
37+ - os : macos-14
2938 cibw_archs : " x86_64"
30- - os : macos-latest
39+ - os : macos-14
3140 cibw_archs : " arm64"
3241
3342 steps :
@@ -122,7 +131,7 @@ jobs:
122131 strategy :
123132 fail-fast : false
124133 matrix :
125- os : [ubuntu-latest, macos-latest ]
134+ os : [ubuntu-latest, macos-14 ]
126135 python-version : ['3.9', '3.10', '3.11', '3.12']
127136
128137 steps :
@@ -144,12 +153,17 @@ jobs:
144153 echo "=== Available wheels ==="
145154 ls -la wheelhouse/*.whl
146155
156+ # Determine the distribution name from the wheel filenames (PEP 427)
157+ # e.g. kalign_test-3.4.5-...whl -> kalign-test
158+ DIST_NAME="$(ls wheelhouse/*.whl | head -n 1 | xargs basename | cut -d- -f1 | tr '_' '-')"
159+ echo "=== Detected dist name: ${DIST_NAME} ==="
160+
147161 echo "=== Installing wheel ==="
148- pip install --find-links wheelhouse/ kalign --force-reinstall
162+ pip install --find-links wheelhouse/ "${DIST_NAME}" --force-reinstall
149163
150164 # Check what got installed
151165 echo "=== Checking installed packages ==="
152- pip list | grep kalign || true
166+ pip list | grep -E ' kalign' || true
153167
154168 # Check the kalign module structure
155169 echo "=== Checking kalign module ==="
@@ -209,6 +223,10 @@ jobs:
209223 needs : [build_wheels, build_sdist, test_install]
210224 runs-on : ubuntu-latest
211225 if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
226+ permissions :
227+ id-token : write
228+ environment :
229+ name : pypi
212230
213231 steps :
214232 - name : Download all artifacts
@@ -218,9 +236,30 @@ jobs:
218236 merge-multiple : true
219237 path : dist/
220238
221- - name : Publish to PyPI
239+ - name : Publish to PyPI (trusted publishing)
240+ uses : pypa/gh-action-pypi-publish@release/v1
241+ with :
242+ packages_dir : dist/
243+
244+ upload_testpypi :
245+ name : Upload to TestPyPI
246+ needs : [build_wheels, build_sdist, test_install]
247+ runs-on : ubuntu-latest
248+ if : github.event_name == 'workflow_dispatch' && inputs.publish_target == 'testpypi'
249+
250+ steps :
251+ - name : Download all artifacts
252+ uses : actions/download-artifact@v4
253+ with :
254+ pattern : cibw-*
255+ merge-multiple : true
256+ path : dist/
257+
258+ - name : Publish to TestPyPI (API token)
222259 uses : pypa/gh-action-pypi-publish@release/v1
223260 with :
224261 user : __token__
225- password : ${{ secrets.PYPI_API_TOKEN }}
226- packages_dir : dist/
262+ password : ${{ secrets.TEST_PYPI_API_TOKEN }}
263+ packages_dir : dist/
264+ repository-url : https://test.pypi.org/legacy/
265+ verbose : true
0 commit comments