-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github workflow for building and publishing wheels
- Loading branch information
Showing
1 changed file
with
91 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: build-and-publish | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
tags: ['v*'] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
pyver: [cp36, cp37, cp38, cp39, cp310, cp311, cp312] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: "true" | ||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
env: | ||
CIBW_BUILD: ${{ matrix.pyver }}-* | ||
- name: Upload wheel artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels-${{ matrix.os }}-${{ matrix.pyver }}-${{ strategy.job-index }} | ||
path: wheelhouse/* | ||
|
||
build-sdist: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: "true" | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Install pypa/build | ||
run: "python -m pip install build --user" | ||
- name: Build a source tarball | ||
run: "python -m build --sdist" | ||
- name: Upload sdist artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sdist | ||
path: dist/* | ||
|
||
nightly-release: | ||
if: startsWith(github.ref, 'refs/heads/') # if a commit is pushed | ||
needs: [build, build-sdist] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # create nightly release | ||
steps: | ||
- name: Download wheel artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: dist/ | ||
merge-multiple: true | ||
- name: Update Nightly Release | ||
uses: andelf/nightly-release@main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: nightly | ||
name: 'Nightly Release' | ||
prerelease: true | ||
body: 'MPlib development nightly release. This release is mainly for internal testing. Stable releases are published to pypi https://pypi.org/p/mplib/' | ||
files: | | ||
dist/* | ||
publish-pypi: | ||
if: startsWith(github.ref, 'refs/tags/v') # if a tag is pushed | ||
needs: build | ||
runs-on: ubuntu-latest | ||
environment: pypi_publish | ||
permissions: | ||
id-token: write # mandatory for PyPI trusted publishing | ||
steps: | ||
- name: Download wheel artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: dist/ | ||
merge-multiple: true | ||
- name: Publish distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages-dir: dist/ |