Try fix pyproject.toml deploy (#30) #133
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: python | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
test: | |
name: ${{ matrix.os }} py${{ matrix.case.python-version }} | |
runs-on: ${{ matrix.os }}-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu, macos, windows] | |
case: | |
- python-version: 3.11 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 100 | |
persist-credentials: false | |
- name: Fetch git tags | |
run: git fetch origin 'refs/tags/*:refs/tags/*' | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.case.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install numpy pytest pytest-flake8 flake8-pyproject | |
- name: Create, install, lint and test | |
run: | | |
cd packages | |
python create_python.py | |
cd python | |
python -m pip install . | |
pytest --flake8 | |
deploy: | |
needs: test | |
name: Deploy to PyPI | |
runs-on: ubuntu-latest | |
# Only from the origin repository, not forks; only main and tags. | |
if: github.repository_owner == 'emsig' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 100 | |
persist-credentials: false | |
- name: Fetch git tags | |
run: git fetch origin 'refs/tags/*:refs/tags/*' | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.case.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build setuptools-scm | |
- name: Create package | |
run: | | |
cd packages | |
python create_python.py | |
- name: Build source and wheel distributions | |
run: | | |
# Build source and wheel packages | |
cd packages/python | |
python -m build | |
echo "" | |
echo "Generated files:" | |
ls -lh dist/ | |
- name: Publish to Test PyPI | |
if: success() | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_PASSWORD }} | |
packages_dir: packages/python/dist/ | |
repository_url: https://test.pypi.org/legacy/ | |
# Allow existing releases on test PyPI without errors. | |
# NOT TO BE USED in PyPI! | |
skip_existing: true | |
- name: Publish to PyPI | |
# Only for releases | |
if: success() && github.event_name == 'release' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_PASSWORD }} | |
packages_dir: packages/python/dist/ |