-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (128 loc) · 4.05 KB
/
pypi-release.yml
File metadata and controls
136 lines (128 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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]
- 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_3d; 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