Skip to content

Example update and two convenience functions #130

Example update and two convenience functions

Example update and two convenience functions #130

name: build-and-publish
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
pyver: [cp38, cp39, cp310, cp311, cp312]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: "true"
- name: Build wheels and test
uses: pypa/cibuildwheel@v2.16.4
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:
if: github.event_name == 'push'
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/*
trigger-build-doc:
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
steps:
- name: Trigger ReadTheDocs build
uses: dfm/rtds-action@v1
with:
webhook_url: ${{ secrets.RTDS_WEBHOOK_URL }}
webhook_token: ${{ secrets.RTDS_WEBHOOK_TOKEN }}
commit_ref: ${{ github.ref }}
nightly-release:
if: github.event_name == 'push' && 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: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') # if a tag is pushed
needs: [build, build-sdist]
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/