Skip to content

Commit

Permalink
update build
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielBok committed Apr 3, 2024
1 parent 39963de commit a69f753
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 21 deletions.
62 changes: 43 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:
strategy:
fail-fast: False
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -41,8 +41,9 @@ jobs:
ls -al ./dist
- name: Place wheels in artifacts folder
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.python-version }}
path: ./dist/*.whl

build_wheels_unix:
Expand All @@ -59,7 +60,7 @@ jobs:
submodules: true

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.11'

Expand All @@ -78,8 +79,9 @@ jobs:
ls -R dist
- name: Place wheels in artifacts folder
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: ./dist/*.whl

test-wheels:
Expand All @@ -89,23 +91,27 @@ jobs:
strategy:
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest ]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Retrieve packages
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
path: dist

- name: List items
run: |
ls -alR dist
- name: Test Package Installation
run: |
python -m pip install --upgrade pip
Expand All @@ -131,34 +137,52 @@ jobs:
python extern/nlopt/test/t_python.py
deploy:
name: deploy packages
name: Deploy packages
runs-on: ubuntu-latest
needs: test-wheels
if: startsWith(github.ref, 'refs/tags/')
if: ${{ !startsWith(github.ref, 'refs/tags/') }}

steps:
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Retrieve packages
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: artifact
path: dist

- name: Install twine
run: pip install twine

- name: Move files to top level directory
run: |
ls -ltR dist
python - << EOF
from pathlib import Path
import shutil
d = Path('dist')
for f in d.rglob('*.whl'):
shutil.move(f, d / f.name)
for f in d.iterdir():
if f.is_dir():
shutil.rmtree(f)
EOF
- name: Upload packages to testpypi
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_TEST_UID }}
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PWD }}
run: python -m twine upload --skip-existing --repository testpypi dist/*
TWINE_USERNAME: ${{ secrets.PYPI_TEST_TOKEN_NAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_API_TOKEN }}
run: python -m twine upload --skip-existing --repository testpypi dist/* --verbose

- name: Upload packages to pypi
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: ${{ secrets.PYPI_UID }}
TWINE_PASSWORD: ${{ secrets.PYPI_PWD }}
run: python -m twine upload --skip-existing dist/*
TWINE_USERNAME: ${{ secrets.PYPI_PROD_TOKEN_NAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PROD_API_TOKEN }}
run: python -m twine upload --skip-existing dist/* --verbose
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

from extensions import NLOptBuild, NLOptBuildExtension

from wheel.bdist_wheel import bdist_wheel

with open("README.md") as f:
long_description = f.read()

Expand Down

0 comments on commit a69f753

Please sign in to comment.