fixed smoke tests in pypi release action #4
Workflow file for this run
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: Publish to PyPI | |
| on: | |
| push: | |
| tags: ["v*"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| id-token: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: pip | |
| - run: python -m pip install -U pip | |
| - run: python -m pip install -e .[test,vis,gpu] | |
| - run: pytest tests/ -v --cov=flowreg3d | |
| build: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: [test] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: pip | |
| - name: Fail if README contains relative image links | |
| run: | | |
| python - <<'PY' | |
| import re, sys, pathlib | |
| t = pathlib.Path("README.md").read_text(encoding="utf-8") | |
| # Check for relative links in Markdown or HTML img tags | |
| bad = re.search(r'!\[[^\]]*\]\((?!https?://)[^)]+\)|<img[^>]*src="(?!https?://)', t) | |
| if bad: | |
| print(f"ERROR: README.md contains relative image links: {bad.group(0)}") | |
| print("Please ensure README image links are normalized before tagging a release.") | |
| sys.exit(1) | |
| else: | |
| print("✓ README.md has properly normalized image links") | |
| PY | |
| - run: python -m pip install -U build twine | |
| - run: python -m build | |
| - run: python -m twine check dist/* | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: dist/ | |
| wheel-smoke: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: [build] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| python-version: ["3.11"] | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: dist/ | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install wheel | |
| shell: bash | |
| run: python -m pip install dist/*.whl | |
| - name: Test wheel imports | |
| run: | | |
| python -c "import flowreg3d; print('flowreg3D version:', getattr(flowreg3d, '__version__', 'unknown'))" | |
| python -c "from flowreg3d.core.optical_flow_3d import get_displacement; print('Core imports working')" | |
| sdist-smoke: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: dist/ | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install sdist | |
| shell: bash | |
| run: python -m pip install dist/*.tar.gz | |
| - run: python -c "import flowreg3d, importlib; importlib.import_module('flowreg3d'); print('sdist import OK')" | |
| publish: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: [wheel-smoke, sdist-smoke] | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: dist/ | |
| - name: Publish RCs to TestPyPI | |
| if: contains(github.ref_name, 'rc') | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| packages-dir: dist/ | |
| skip-existing: true | |
| - name: Publish to PyPI | |
| if: "!contains(github.ref_name, 'rc')" | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/ | |
| skip-existing: true |