Update pkg version #20
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: Upload Python Package | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "[0-9][0-9].[0-9][0-9]*" | |
env: | |
MLM_LICENSE_TOKEN: ${{ secrets.MATLAB_BATCH_TOKEN }} | |
permissions: | |
contents: write | |
jobs: | |
compile-and-deploy: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
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: Setup python version | |
if: ${{ matrix.main }} | |
run: | | |
sed -i 's/\(version = "[^"]*\)"/version = "${{ github.ref_name }}"/' pyproject.toml | |
- name: Add Matlab version specifier | |
if: ${{ !matrix.main }} | |
run: | | |
sed -i 's/\(version = "[^"]*\)"/\1+${{ matrix.matlab }}"/' pyproject.toml | |
- name: Setup Python version (2.7) | |
if: ${{ !matrix.py3from }} | |
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 | |
cat pyproject.toml | |
- name: Setup Python version (3+) | |
if: ${{ matrix.py3from }} | |
run: | | |
FROM=${{ matrix.py3from }} | |
TO=${{ matrix.py3to }} | |
sed -i 's/^python-requires = .*/python-requires = "$FROM>=,<$TO"/' pyproject.toml | |
tags=$(for i in $(seq ${FROM//3./} $(( ${TO//3./} - 1)) ); do echo -n "py3$i."; done | sed 's/\.$//') | |
echo "[tool.distutils.bdist_wheel]" >> pyproject.toml | |
echo "python-tag = \"$tags\"" >> pyproject.toml | |
cat pyproject.toml | |
- name: Build package | |
run: python -m build --sdist --wheel | |
- name: Detect Pre-release | |
shell: bash | |
run: | | |
if echo "${{ github.ref_name }}" | grep -q '^[0-9][0-9]\.[0-9][0-9]\.[A-Za-z]'; then | |
echo "PRERELEASE=true" >> $GITHUB_ENV | |
else | |
echo "PRERELEASE=false" >> $GITHUB_ENV | |
fi | |
echo PRERELEASE=${{ env.PRERELEASE }} | |
- name: Release package | |
uses: softprops/action-gh-release@v2 | |
with: | |
prerelease: ${{ env.PRERELEASE }} | |
files: ./dist/spm_python*.whl | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |