CI/CD #6
This file contains hidden or 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: CI/CD | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-13, macos-14] | |
python-version: ["3.10", "3.11", "3.12"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install poetry | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade setuptools cython | |
pipx install poetry | |
- name: Build dist | |
run: poetry build --format wheel | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
path: dist/*.whl | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install poetry | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade setuptools cython | |
pipx install poetry | |
- name: Build dist | |
run: poetry build --format sdist | |
- name: Upload dist | |
uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.tar.gz | |
publish-to-testpypi: | |
name: Publish package to TestPyPI | |
needs: | |
- build_wheels | |
- build_sdist | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
merge-multiple: true | |
- name: Publish in TestPyPI | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install twine | |
python -m twine upload dist/* | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_ACCESS }} |