Upload and Publish Python Package #9
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: Upload Python Package | ||
| on: | ||
| release: | ||
| types: [published] | ||
| workflow_dispatch: | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| compile-and-deploy: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - matlab: "R2020b" | ||
| python: "2.7" | ||
| - matlab: "R2020b" | ||
| python: "3.8" | ||
| py3from: "3.6" | ||
| py3to: "3.9" | ||
| - matlab: "R2021a" | ||
| python: "2.7" | ||
| - matlab: "R2021a" | ||
| python: "3.8" | ||
| py3from: "3.7" | ||
| py3to: "3.9" | ||
| - matlab: "R2021b" | ||
| python: "2.7" | ||
| - matlab: "R2021b" | ||
| python: "3.9" | ||
| py3from: "3.7" | ||
| py3to: "3.10" | ||
| - matlab: "R2022a" | ||
| python: "2.7" | ||
| - matlab: "R2022a" | ||
| python: "3.9" | ||
| py3from: "3.8" | ||
| py3to: "3.10" | ||
| - matlab: "R2022b" | ||
| python: "2.7" | ||
| - matlab: "R2022b" | ||
| python: "3.10" | ||
| py3from: "3.8" | ||
| py3to: "3.11" | ||
| - matlab: "R2023a" | ||
| python: "3.10" | ||
| py3from: "3.8" | ||
| py3to: "3.11" | ||
| - matlab: "R2023b" | ||
| python: "3.11" | ||
| py3from: "3.9" | ||
| py3to: "3.12" | ||
| - matlab: "R2024a" | ||
| python: "3.11" | ||
| py3from: "3.9" | ||
| py3to: "3.12" | ||
| - matlab: "R2024b" | ||
| python: "3.12" | ||
| py3from: "3.9" | ||
| py3to: "3.13" | ||
| - matlab: "R2024b" | ||
| main: "true" | ||
| python: "3.12" | ||
| py3from: "3.9" | ||
| py3to: "3.13" | ||
| steps: | ||
| - name: Set up MATLAB | ||
| uses: matlab-actions/setup-matlab@v2 | ||
| with: | ||
| cache: True | ||
| release: ${{ matrix.matlab }} | ||
| products: | | ||
| MATLAB_Compiler | ||
| MATLAB_Compiler_SDK | ||
| - name: Check out repository | ||
| uses: actions/checkout@v4 | ||
| - name: Run MPython | ||
| uses: matlab-actions/run-command@v2 | ||
| with: | ||
| command: | | ||
| cd('.mpython'); | ||
| addpath(genpath('.')); | ||
| spm_make_python('.', true, false); | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python }} | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install build | ||
| pip install numpy | ||
| - name: Add Matlab version specifier | ||
| if: ${{ !matrix.main }} | ||
| run: | | ||
| sed -i 's/\(version = "[^"]*\)"/\1+${{ matrix.matlab }}"/' pyproject.toml | ||
| cat pyproject.toml | ||
| - name: Setup Python version (2.7) | ||
| if: matrix.python == "2.7" | ||
|
Check failure on line 122 in .github/workflows/publish-release.yml
|
||
| run: | | ||
| sed -i 's/^python-requires = .*/python-requires = ">=2.7,<3.1"/' pyproject.toml | ||
| echo "[tool.distutils.bdist_wheel]" >> pyproject.toml | ||
| echo "python-tag = \"2.7\"" >> pyproject.toml | ||
| - name: Setup Python version (3+) | ||
| if: ${{ matrix.py3from }} | ||
| run: | | ||
| sed -i 's/^python-requires = .*/python-requires = ">=${{ matrix.py3from }},<${{ matrix.py3to }}"/' pyproject.toml | ||
| tags=$(for i in $(seq ${${{ matrix.py3from }}//./} $(( ${${{ matrix.py3to }}//./} - 1)) ); do echo -n "py$i."; done | sed 's/\.$//') | ||
| echo "[tool.distutils.bdist_wheel]" >> pyproject.toml | ||
| echo "python-tag = \"$tags\"" >> pyproject.toml | ||
| - name: Build package | ||
| run: python -m build | ||
| - name: Publish package | ||
| uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | ||
| with: | ||
| user: __token__ | ||
| password: ${{ secrets.PYPI_API_TOKEN }} | ||