@@ -55,3 +55,192 @@ jobs:
5555 package_name : MDAnalysisData
5656 module_name : ' MDAnalysisData'
5757 test_deps : ' pytest pytest-mock'
58+
59+ # ######################3
60+ name : Build and upload to PyPi
61+
62+ on :
63+ push :
64+ tags :
65+ - " *"
66+ release :
67+ types :
68+ - published
69+
70+ concurrency :
71+ group : " ${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}"
72+ cancel-in-progress : false
73+
74+ defaults :
75+ run :
76+ shell : bash -l {0}
77+
78+
79+ jobs :
80+ build :
81+ name : Build package
82+ runs-on : ubuntu-latest
83+ steps :
84+ - name : Checkout
85+ uses : actions/checkout@v6
86+
87+ - name : Set up Python
88+ uses : actions/setup-python@v6
89+ with :
90+ python-version : " 3.14"
91+
92+ - name : Install build dependencies
93+ run : |
94+ python -m pip install --upgrade pip
95+ pip install build twine
96+
97+ - name : Build package (binary wheel and source distribution package)
98+ run : |
99+ python -m build
100+
101+ - name : Check package
102+ run : |
103+ twine check dist/*
104+
105+ - name : Upload dist files
106+ uses : actions/upload-artifact@v4
107+ with :
108+ name : dist-files
109+ path : dist/
110+ retention-days : 1
111+
112+ test-pytest :
113+ name : Run tests
114+ runs-on : ubuntu-latest
115+ needs : build
116+ steps :
117+ - name : Set up Python
118+ uses : actions/setup-python@v6
119+ with :
120+ python-version : " 3.14"
121+
122+ - name : Download dist files
123+ uses : actions/download-artifact@v4
124+ with :
125+ name : dist-files
126+ path : dist/
127+
128+ - name : Install package with test dependencies and tests
129+ run : |
130+ python -m pip install --upgrade pip
131+ WHEEL_FILE=$(ls dist/*.whl)
132+ pip install "$WHEEL_FILE"[test]
133+
134+ - name : Test import
135+ run : |
136+ python -c "import MDAnalysisData; print(f'Package {MDAnalysisData.__version__} imported successfully')"
137+
138+ - name : Run basic tests
139+ run : |
140+ pytest --verbose --pyargs MDAnalysisData
141+
142+ deploy-testpypi :
143+ name : Deploy to TestPyPI
144+ runs-on : ubuntu-latest
145+ needs : [build, test-pytest]
146+ if : |
147+ github.repository == 'MDAnalysis/MDAnalysisData' &&
148+ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
149+ environment :
150+ name : testpypi
151+ url : https://test.pypi.org/p/MDAnalysisData
152+ permissions :
153+ id-token : write # IMPORTANT: mandatory for trusted publishing
154+ steps :
155+ - name : Download dist files
156+ uses : actions/download-artifact@v4
157+ with :
158+ name : dist-files
159+ path : dist/
160+
161+ - name : Publish to TestPyPI
162+ uses : pypa/gh-action-pypi-publish@v1.13.0
163+ with :
164+ repository-url : https://test.pypi.org/legacy/
165+
166+ deploy-pypi :
167+ name : Deploy to PyPI
168+ runs-on : ubuntu-latest
169+ needs : [build, test-pytest]
170+ if : |
171+ github.repository == 'MDAnalysis/MDAnalysisData' &&
172+ (github.event_name == 'release' && github.event.action == 'published')
173+ environment :
174+ name : pypi
175+ url : https://pypi.org/p/MDAnalysisData
176+ permissions :
177+ id-token : write # IMPORTANT: mandatory for trusted publishing
178+ steps :
179+ - name : Download dist files
180+ uses : actions/download-artifact@v4
181+ with :
182+ name : dist-files
183+ path : dist/
184+
185+ - name : Publish to PyPI
186+ uses : pypa/gh-action-pypi-publish@v1.13.0
187+
188+ test-deployed-testpypi :
189+ name : Test deployed package (TestPyPI)
190+ runs-on : ${{ matrix.os }}
191+ strategy :
192+ fail-fast : false
193+ matrix :
194+ os : [ubuntu-latest, macos-latest]
195+ needs : deploy-testpypi
196+ if : |
197+ github.repository == 'MDAnalysis/MDAnalysisData' &&
198+ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
199+ steps :
200+ - name : Set up Python
201+ uses : actions/setup-python@v6
202+ with :
203+ python-version : " 3.14"
204+
205+ - name : Install from TestPyPI
206+ run : |
207+ python -m pip install --upgrade pip
208+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ MDAnalysisData[test]
209+
210+ - name : Test import
211+ run : |
212+ python -c "import MDAnalysisData; print(f'Package {MDAnalysisData.__version__} imported successfully from TestPyPi')"
213+
214+ - name : Run basic tests
215+ run : |
216+ pytest --verbose --pyargs MDAnalysisData
217+
218+ test-deployed-pypi :
219+ name : Test deployed package (PyPI)
220+ runs-on : ${{ matrix.os }}
221+ strategy :
222+ fail-fast : false
223+ matrix :
224+ os : [ubuntu-latest, macos-latest]
225+ needs : deploy-pypi
226+ if : |
227+ github.repository == 'MDAnalysis/MDAnalysisData' &&
228+ (github.event_name == 'release' && github.event.action == 'published')
229+ steps :
230+ - name : Set up Python
231+ uses : actions/setup-python@v6
232+ with :
233+ python-version : " 3.14"
234+
235+ - name : Install from PyPI
236+ run : |
237+ python -m pip install --upgrade pip
238+ pip install MDAnalysisData[test]
239+
240+ - name : Test import
241+ run : |
242+ python -c "import MDAnalysisData; print(f'Package {MDAnalysisData.__version__} imported successfully from PyPi')"
243+
244+ - name : Run basic tests
245+ run : |
246+ pytest --verbose --pyargs MDAnalysisData
0 commit comments