Skip to content

Commit 83cec62

Browse files
committed
update deployment workflow
- fix #153 - replaced MDAnalysis/pypi-deployment action with explicit steps (see also MDAnalysis/pypi-deployment#11 for details on issues) - include full tests of installed packages
1 parent dd8d17f commit 83cec62

File tree

1 file changed

+174
-29
lines changed

1 file changed

+174
-29
lines changed

.github/workflows/deploy.yaml

Lines changed: 174 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,193 @@ on:
88
types:
99
- published
1010

11+
concurrency:
12+
group: "${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}"
13+
cancel-in-progress: true
14+
15+
defaults:
16+
run:
17+
shell: bash -l {0}
18+
19+
1120
jobs:
12-
testpypi_push:
13-
environment:
14-
name: deploy
15-
url: https://test.pypi.org/p/GridDataFormats
16-
permissions:
17-
id-token: write
18-
if: |
19-
github.repository == 'MDAnalysis/GridDataFormats' &&
20-
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
21-
name: Build, upload and test pure Python wheels to TestPypi
21+
build:
22+
name: Build package
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: "3.x"
32+
33+
- name: Install build dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install build twine
37+
38+
- name: Build package (binary wheel and source distribution package)
39+
run: |
40+
python -m build
41+
42+
- name: Check package
43+
run: |
44+
twine check dist/*
45+
46+
- name: Upload dist files
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: dist-files
50+
path: dist/
51+
retention-days: 1
52+
53+
test-install:
54+
name: Test package installation
2255
runs-on: ubuntu-latest
56+
needs: build
57+
steps:
58+
- name: Set up Python
59+
uses: actions/setup-python@v5
60+
with:
61+
python-version: "3.x"
62+
63+
- name: Download dist files
64+
uses: actions/download-artifact@v4
65+
with:
66+
name: dist-files
67+
path: dist/
68+
69+
- name: Install package
70+
run: |
71+
python -m pip install --upgrade pip
72+
pip install dist/*.whl
73+
74+
- name: Run tests
75+
run: |
76+
python -c "import gridData; print(f'Package {gridData.__version__} imported successfully')"
2377
78+
test-pytest:
79+
name: Run tests
80+
runs-on: ubuntu-latest
81+
needs: build
2482
steps:
25-
- uses: actions/checkout@v4
83+
- name: Set up Python
84+
uses: actions/setup-python@v5
85+
with:
86+
python-version: "3.x"
2687

27-
- name: testpypi_deploy
28-
uses: MDAnalysis/pypi-deployment@main
29-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
88+
- name: Download dist files
89+
uses: actions/download-artifact@v4
3090
with:
31-
test_submission: true
32-
package_name: GridDataFormats
33-
module_name: 'gridData'
91+
name: dist-files
92+
path: dist/
93+
94+
- name: Install package with test dependencies and tests
95+
run: |
96+
python -m pip install --upgrade pip
97+
WHEEL_FILE=$(ls dist/*.whl)
98+
pip install "$WHEEL_FILE"[test]
99+
100+
- name: Run tests
101+
run: |
102+
pytest --verbose --pyargs gridData
34103
35-
pypi_push:
104+
deploy-testpypi:
105+
name: Deploy to TestPyPI
106+
runs-on: ubuntu-latest
107+
needs: [build, test-install, test-pytest]
108+
if: |
109+
github.repository == 'MDAnalysis/GridDataFormats' &&
110+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
36111
environment:
37-
name: deploy
38-
url: https://pypi.org/p/GridDataFormats
112+
name: testpypi
113+
url: https://test.pypi.org/p/GridDataFormats
39114
permissions:
40-
id-token: write
115+
id-token: write # IMPORTANT: mandatory for trusted publishing
116+
steps:
117+
- name: Download dist files
118+
uses: actions/download-artifact@v4
119+
with:
120+
name: dist-files
121+
path: dist/
122+
123+
- name: Publish to TestPyPI
124+
uses: pypa/gh-action-pypi-publish@v1.12.4
125+
with:
126+
repository-url: https://test.pypi.org/legacy/
127+
128+
deploy-pypi:
129+
name: Deploy to PyPI
130+
runs-on: ubuntu-latest
131+
needs: [build, test-install, test-pytest]
41132
if: |
42133
github.repository == 'MDAnalysis/GridDataFormats' &&
43134
(github.event_name == 'release' && github.event.action == 'published')
44-
name: Build, upload and test pure Python wheels to PyPi
45-
runs-on: ubuntu-latest
135+
environment:
136+
name: pypi
137+
url: https://pypi.org/p/GridDataFormats
138+
permissions:
139+
id-token: write # IMPORTANT: mandatory for trusted publishing
140+
steps:
141+
- name: Download dist files
142+
uses: actions/download-artifact@v4
143+
with:
144+
name: dist-files
145+
path: dist/
46146

147+
- name: Publish to PyPI
148+
uses: pypa/gh-action-pypi-publish@v1.12.4
149+
150+
test-deployed-testpypi:
151+
name: Test deployed package (TestPyPI)
152+
runs-on: ubuntu-latest
153+
needs: deploy-testpypi
154+
if: |
155+
github.repository == 'MDAnalysis/GridDataFormats' &&
156+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
47157
steps:
48-
- uses: actions/checkout@v4
158+
- name: Set up Python
159+
uses: actions/setup-python@v5
160+
with:
161+
python-version: "3.x"
49162

50-
- name: pypi_deploy
51-
uses: MDAnalysis/pypi-deployment@main
52-
if: github.event_name == 'release' && github.event.action == 'published'
163+
- name: Install from TestPyPI
164+
run: |
165+
python -m pip install --upgrade pip
166+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ GridDataFormats[test]
167+
168+
- name: Test import
169+
run: |
170+
python -c "import gridData; print(f'Package {gridData.__version__} imported successfully from TestPyPi')"
171+
172+
- name: Run basic tests
173+
run: |
174+
pytest --verbose --pyargs gridData
175+
176+
test-deployed-pypi:
177+
name: Test deployed package (PyPI)
178+
runs-on: ubuntu-latest
179+
needs: deploy-pypi
180+
if: |
181+
github.repository == 'MDAnalysis/GridDataFormats' &&
182+
(github.event_name == 'release' && github.event.action == 'published')
183+
steps:
184+
- name: Set up Python
185+
uses: actions/setup-python@v5
53186
with:
54-
package_name: GridDataFormats
55-
module_name: 'gridData'
187+
python-version: "3.x"
188+
189+
- name: Install from PyPI
190+
run: |
191+
python -m pip install --upgrade pip
192+
pip install GridDataFormats[test]
193+
194+
- name: Test import
195+
run: |
196+
python -c "import gridData; print(f'Package {gridData.__version__} imported successfully from PyPi')"
197+
198+
- name: Run basic tests
199+
run: |
200+
pytest --verbose --pyargs gridData

0 commit comments

Comments
 (0)