Skip to content

Commit bdf381c

Browse files
Add workflow to publish tagged releases to PyPI (#1369)
* CI/CD: Add step to publish wheels on tag creation * Remove file * Restrict pre-release workflow branches * Update PyPI publishing * Update PyPI publishing * Update package workflow name * continuous pre-release only on main
1 parent e7c6fc6 commit bdf381c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/python-package.yml

+30
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ on:
1818
release:
1919
types: [published]
2020
workflow_dispatch: {} # Allow manual trigger
21+
workflow_call: {} # Allow triggering from other worfkflows
2122

2223
concurrency:
2324
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -156,6 +157,7 @@ jobs:
156157
upload-pre-release-wheels:
157158
name: Create release and upload artifacts
158159
runs-on: ubuntu-latest
160+
if: github.ref_name == 'main'
159161
permissions:
160162
contents: write
161163
needs:
@@ -221,6 +223,34 @@ jobs:
221223
- run: pip install auditwheel
222224
- run: python ./.github/scripts/auditwheel_show.py wheels/* | tee $GITHUB_STEP_SUMMARY
223225

226+
publish-wheels:
227+
name: Publish wheels to PyPI
228+
needs: [build-wheels, audit-wheels]
229+
runs-on: ubuntu-latest
230+
if: |
231+
github.repository == 'bitsandbytes-foundation/bitsandbytes'
232+
&& github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
233+
environment:
234+
name: release
235+
url: https://pypi.org/p/bitsandbytes
236+
permissions:
237+
id-token: write
238+
steps:
239+
- name: Download distribution artifacts
240+
uses: actions/download-artifact@v4
241+
with:
242+
path: dist/
243+
pattern: "bdist_wheel_*"
244+
merge-multiple: true
245+
246+
- name: Remove macOS wheels
247+
run: rm dist/*macos*
248+
249+
- name: Publish to PyPI
250+
uses: pypa/gh-action-pypi-publish@release/v1
251+
with:
252+
print-hash: true
253+
224254
# test:
225255
# needs:
226256
# - build-wheels

0 commit comments

Comments
 (0)