Publish to PyPI #4
Workflow file for this run
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: Publish to PyPI | |
on: | |
release: | |
types: [published] | |
env: | |
BUILD_FOLDER: build | |
jobs: | |
build: | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
label: linux-64 | |
prefix: /usr/share/miniconda3/envs/ezc3d | |
# - os: macos-latest | |
# label: osx-64 | |
# prefix: /Users/runner/miniconda3/envs/ezc3d | |
# - os: windows-latest | |
# label: win-64 | |
# prefix: C:\Miniconda3\envs\ezc3d | |
name: ${{ matrix.label }} | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Get number of CPU cores | |
uses: SimenB/github-actions-cpu-cores@v1 | |
id: cpu-cores | |
- name: Setup environment | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
use-mamba: true | |
activate-environment: ezc3d | |
environment-file: environment.yml | |
- name: Print mamba info | |
run: | | |
mamba info | |
mamba list | |
- name: Install dependencies | |
run: | | |
mamba install cmake git pkgconfig swig numpy pip scikit-build -cconda-forge | |
mamba list | |
- name: Build ezc3d UNIX | |
run: | | |
MAIN_FOLDER=`pwd` | |
CONDA_ENV_PATH=$CONDA/envs/ezc3d | |
mkdir -p $MAIN_FOLDER/$BUILD_FOLDER | |
cd $MAIN_FOLDER/$BUILD_FOLDER | |
cmake -DCMAKE_INSTALL_PREFIX=$CONDA_ENV_PATH -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF -DUSE_MATRIX_FAST_ACCESSOR=OFF -DBINDER_OCTAVE=OFF -DBINDER_PYTHON3=ON .. | |
make install -j${{ steps.cpu-cores.outputs.count }} | |
cd $MAIN_FOLDER | |
if: matrix.label != 'win-64' | |
- name: Build ezc3d WINDOWS | |
run: | | |
MAIN_FOLDER=`pwd` | |
CONDA_ENV_PATH=$CONDA/envs/ezc3d | |
mkdir -p $BUILD_FOLDER | |
cd $BUILD_FOLDER | |
cmake -G"Visual Studio 17 2022" -Ax64 -DCMAKE_INSTALL_PREFIX=$CONDA_ENV_PATH -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_DOC=OFF -DBUILD_EXAMPLE=ON -DUSE_MATRIX_FAST_ACCESSOR=OFF -DBINDER_OCTAVE=OFF -DBINDER_PYTHON3=ON .. | |
cmake --build . --config Release --target install -j${{ steps.cpu-cores.outputs.count }} | |
cd $MAIN_FOLDER | |
if: matrix.label == 'win-64' | |
- name: Build the binary wheel | |
run: python setup.py sdist bdist_wheel | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-pypi: | |
name: >- | |
Publish to PyPI | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/ezc3d | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
publish-to-testpypi: | |
name: Publish to TestPyPI | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/<package-name> | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution 📦 to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ |