Skip to content

Commit d6fdece

Browse files
authored
Merge pull request #28 from Becksteinlab/improve-deploy
updated deployment workflow to directly use the pypa action
2 parents 10c34e9 + 6639635 commit d6fdece

File tree

1 file changed

+172
-28
lines changed

1 file changed

+172
-28
lines changed

.github/workflows/deploy.yaml

Lines changed: 172 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and upload to PyPi
1+
name: Build and Deploy Package
22

33
on:
44
push:
@@ -9,45 +9,189 @@ on:
99
- published
1010

1111
jobs:
12-
test_pypi_push:
13-
environment:
14-
name: deploy
15-
url: https://test.pypi.org/p/basicrta
16-
permissions:
17-
id-token: write
18-
if: |
19-
github.repository == 'Becksteinlab/basicrta' &&
20-
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
21-
name: Build, upload and test pure Python wheels to TestPypi
12+
build:
13+
name: Build package
2214
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.x"
23+
24+
- name: Install build dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install build twine
28+
29+
- name: Build package (binary wheel and source distribution package)
30+
run: |
31+
python -m build
32+
33+
- name: Check package
34+
run: |
35+
twine check dist/*
2336
37+
- name: Upload dist files
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: dist-files
41+
path: dist/
42+
retention-days: 1
43+
44+
test-install:
45+
name: Test package installation
46+
runs-on: ubuntu-latest
47+
needs: build
2448
steps:
25-
- uses: actions/checkout@v4
49+
- name: Set up Python
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: "3.x"
2653

27-
- name: testpypi_deploy
28-
uses: MDAnalysis/pypi-deployment@main
29-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
54+
- name: Download dist files
55+
uses: actions/download-artifact@v4
3056
with:
31-
test_submission: true
32-
package_name: 'basicrta'
57+
name: dist-files
58+
path: dist/
3359

34-
pypi_push:
60+
- name: Install package
61+
run: |
62+
python -m pip install --upgrade pip
63+
pip install dist/*.whl
64+
65+
- name: Test import
66+
run: |
67+
python -c "import basicrta; print('Package imported successfully')"
68+
69+
test-pytest:
70+
name: Run tests
71+
runs-on: ubuntu-latest
72+
needs: build
73+
steps:
74+
- name: Set up Python
75+
uses: actions/setup-python@v5
76+
with:
77+
python-version: "3.x"
78+
79+
- name: Download dist files
80+
uses: actions/download-artifact@v4
81+
with:
82+
name: dist-files
83+
path: dist/
84+
85+
- name: Install package with test dependencies
86+
run: |
87+
python -m pip install --upgrade pip
88+
WHEEL_FILE=$(ls dist/*.whl)
89+
pip install "$WHEEL_FILE"[test]
90+
91+
- name: Run tests
92+
run: |
93+
pytest -n auto --verbose --pyargs basicrta
94+
95+
deploy-testpypi:
96+
name: Deploy to TestPyPI
97+
runs-on: ubuntu-latest
98+
needs: [build, test-install, test-pytest]
99+
if: |
100+
github.repository == 'Becksteinlab/basicrta' &&
101+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
35102
environment:
36-
name: deploy
37-
url: https://pypi.org/p/basicrta
103+
name: testpypi
104+
url: https://test.pypi.org/p/basicrta
38105
permissions:
39-
id-token: write
106+
id-token: write # IMPORTANT: mandatory for trusted publishing
107+
steps:
108+
- name: Download dist files
109+
uses: actions/download-artifact@v4
110+
with:
111+
name: dist-files
112+
path: dist/
113+
114+
- name: Publish to TestPyPI
115+
uses: pypa/[email protected]
116+
with:
117+
repository-url: https://test.pypi.org/legacy/
118+
119+
deploy-pypi:
120+
name: Deploy to PyPI
121+
runs-on: ubuntu-latest
122+
needs: [build, test-install, test-pytest]
40123
if: |
41124
github.repository == 'Becksteinlab/basicrta' &&
42125
(github.event_name == 'release' && github.event.action == 'published')
43-
name: Build, upload and test pure Python wheels to PyPi
44-
runs-on: ubuntu-latest
126+
environment:
127+
name: pypi
128+
url: https://pypi.org/p/basicrta
129+
permissions:
130+
id-token: write # IMPORTANT: mandatory for trusted publishing
131+
steps:
132+
- name: Download dist files
133+
uses: actions/download-artifact@v4
134+
with:
135+
name: dist-files
136+
path: dist/
137+
138+
- name: Publish to PyPI
139+
uses: pypa/[email protected]
45140

141+
test-deployed-testpypi:
142+
name: Test deployed package (TestPyPI)
143+
runs-on: ubuntu-latest
144+
needs: deploy-testpypi
145+
if: |
146+
github.repository == 'Becksteinlab/basicrta' &&
147+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
46148
steps:
47-
- uses: actions/checkout@v4
149+
- name: Set up Python
150+
uses: actions/setup-python@v5
151+
with:
152+
python-version: "3.x"
153+
154+
- name: Wait for package to be available from testpypi
155+
run: sleep 10
48156

49-
- name: pypi_deploy
50-
uses: MDAnalysis/pypi-deployment@main
51-
if: github.event_name == 'release' && github.event.action == 'published'
157+
- name: Install from TestPyPI
158+
run: |
159+
python -m pip install --upgrade pip
160+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ basicrta[test]
161+
162+
- name: Test import
163+
run: |
164+
python -c "import basicrta; print('Package imported successfully from TestPyPI')"
165+
166+
- name: Run basic tests
167+
run: |
168+
python -c "import basicrta; print('Package version:', basicrta.__version__)"
169+
170+
test-deployed-pypi:
171+
name: Test deployed package (PyPI)
172+
runs-on: ubuntu-latest
173+
needs: deploy-pypi
174+
if: |
175+
github.repository == 'Becksteinlab/basicrta' &&
176+
(github.event_name == 'release' && github.event.action == 'published')
177+
steps:
178+
- name: Set up Python
179+
uses: actions/setup-python@v5
52180
with:
53-
package_name: 'basicrta'
181+
python-version: "3.x"
182+
183+
- name: Wait for package to be available from pypi
184+
run: sleep 10
185+
186+
- name: Install from PyPI
187+
run: |
188+
python -m pip install --upgrade pip
189+
pip install basicrta[test]
190+
191+
- name: Test import
192+
run: |
193+
python -c "import basicrta; print('Package imported successfully from PyPI')"
194+
195+
- name: Run basic tests
196+
run: |
197+
python -c "import basicrta; print('Package version:', basicrta.__version__)"

0 commit comments

Comments
 (0)