Skip to content

Commit 448f971

Browse files
committed
update build
1 parent ba57e9a commit 448f971

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

.github/workflows/build.yml

+21-27
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
fail-fast: False
2424
matrix:
25-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
25+
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
2626
steps:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
@@ -91,7 +91,7 @@ jobs:
9191
strategy:
9292
matrix:
9393
os: [ windows-latest, ubuntu-latest, macos-latest ]
94-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
94+
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
9595

9696
steps:
9797
- name: Checkout repository
@@ -136,8 +136,8 @@ jobs:
136136
pip install ${file}
137137
python extern/nlopt/test/t_python.py
138138
139-
deploy-test:
140-
name: Deploy packages to TestPyPI
139+
deploy:
140+
name: Deploy packages
141141
runs-on: ubuntu-latest
142142
needs: test-wheels
143143
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
@@ -156,38 +156,32 @@ jobs:
156156
- name: Install twine
157157
run: pip install twine
158158

159-
- name: List directory
159+
- name: Move files to top level directory
160160
run: |
161-
ls -ltR
161+
ls -ltR dist
162+
python - << EOF
163+
from pathlib import Path
164+
import shutil
165+
166+
d = Path('dist')
167+
for f in d.rglob('*.whl'):
168+
shutil.move(f, d / f.name)
169+
170+
for f in d.iterdir():
171+
if f.is_dir():
172+
shutil.rmtree(f)
173+
174+
EOF
162175
163176
- name: Upload packages to testpypi
177+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
164178
env:
165179
TWINE_USERNAME: ${{ secrets.PYPI_TEST_TOKEN_NAME }}
166180
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_API_TOKEN }}
167181
run: python -m twine upload --skip-existing --repository testpypi dist/* --verbose
168182

169-
deploy:
170-
name: Deploy packages to PyPI
171-
runs-on: ubuntu-latest
172-
needs: test-wheels
173-
if: startsWith(github.ref, 'refs/tags/')
174-
175-
steps:
176-
- name: Setup Python ${{ matrix.python-version }}
177-
uses: actions/setup-python@v4
178-
with:
179-
python-version: ${{ matrix.python-version }}
180-
181-
- name: Retrieve packages
182-
uses: actions/download-artifact@v4
183-
with:
184-
name: artifact
185-
path: dist
186-
187-
- name: Install twine
188-
run: pip install twine
189-
190183
- name: Upload packages to pypi
184+
if: startsWith(github.ref, 'refs/tags/')
191185
env:
192186
TWINE_USERNAME: ${{ secrets.PYPI_PROD_TOKEN_NAME }}
193187
TWINE_PASSWORD: ${{ secrets.PYPI_PROD_API_TOKEN }}

0 commit comments

Comments
 (0)