path fixes for publishing [ci publish] #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish | |
# NOTE: build logic is duplicated here and in test_build.yml | |
# Run on the main branch for commits only | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build_wheels: | |
# only run if the most recent commit contains '[ci publish]' | |
if: "contains(github.event.head_commit.message, '[ci publish]')" | |
strategy: | |
matrix: | |
# macos-13 is an intel runner, macos-14 is apple silicon | |
os: [ubuntu-latest, windows-latest, macos-13, macos-14] | |
name: Build wheels ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Package source distribution | |
if: runner.os == 'Linux' | |
run: | | |
python -m pip install build | |
python -m build --sdist | |
- name: Run cibuildwheel | |
uses: pypa/[email protected] | |
with: | |
config-file: ".github/workflows/cibuildwheel_config.toml" | |
- name: Copy source distribution into wheelhouse | |
if: runner.os == 'Linux' | |
run: mv dist/*.tar.gz wheelhouse/ | |
# Upload binaries to the github artifact store | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }} | |
path: | | |
./wheelhouse/*.whl | |
./wheelhouse/*.tar.gz | |
overwrite: true | |
# Push the resulting binaries to pypi on a tag starting with 'v' | |
upload_pypi: | |
name: Upload release to PyPI | |
# only run if the most recent commit contains '[ci publish]' | |
if: "contains(github.event.head_commit.message, '[ci publish]')" | |
needs: [build_wheels] | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/robust-laplacian/ | |
permissions: # we authenticate via PyPI's 'trusted publisher' workflow, this permission is required | |
id-token: write | |
steps: | |
- name: Download built wheels artifact # downloads from the jobs storage from the previous step | |
uses: actions/[email protected] | |
with: | |
# omitting the `name: ` field downloads all artifacts from this workflow | |
path: dist | |
- name: List downloaded files from artifact | |
run: ls dist | cat # piping through cat prints one per line | |
# dist directory has subdirs from the different jobs, merge them into one directory and delete | |
# the empty leftover dirs | |
- name: Flatten directory | |
run: find dist -mindepth 2 -type f -exec mv -t dist {} + && find dist -type d -empty -delete | |
- name: List downloaded files from artifact after flatten | |
run: ls dist | cat # piping through cat prints one per line | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# To test: repository_url: https://test.pypi.org/legacy/ | |