Skip to content

Commit 2d35db9

Browse files
committed
updated deployment workflow to directly use the pypa action
1 parent 3aa01ab commit 2d35db9

File tree

1 file changed

+166
-28
lines changed

1 file changed

+166
-28
lines changed

.github/workflows/deploy.yaml

Lines changed: 166 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,183 @@ 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"
48153

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

0 commit comments

Comments
 (0)