Skip to content

Don't access the network in Python setup (#6) #47

Don't access the network in Python setup (#6)

Don't access the network in Python setup (#6) #47

name: Build, Test, and Publish Wheel
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: pip install wheel requests
- name: Build Linux wheel (manylinux_x86_64)
run: python build_wheels.py
- name: Store wheel filename
run: echo "WHEEL_NAME=$(ls dist/*.whl | head -n 1)" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: linux-wheel
path: dist/*.whl
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: pip install wheel requests
- name: Build Windows wheel (win_amd64)
run: python build_wheels.py
- name: Store wheel filename
shell: powershell
run: |
$wheel_file = (Get-ChildItem dist\*.whl).FullName
echo "WHEEL_NAME=$wheel_file" | Out-File -FilePath $env:GITHUB_ENV -Append
- uses: actions/upload-artifact@v4
with:
name: windows-wheel
path: dist/*.whl
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: pip install wheel requests
- name: Build macOS wheel (macosx_universal2)
run: |
python build_wheels.py
- name: Store wheel filename
run: echo "WHEEL_NAME=$(ls dist/*.whl | head -n 1)" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: macos-wheel
path: dist/*.whl
test-linux:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Download wheel
uses: actions/download-artifact@v4
with:
name: linux-wheel
path: wheel-download
- name: Find wheel file (Python)
run: echo "LINUX_WHEEL_NAME=$(python -c "import os, glob; print(glob.glob('wheel-download/*.whl')[0])")" >> $GITHUB_ENV
- name: Install wheel
run: pip install ${{ env.LINUX_WHEEL_NAME }}
- name: Test Import
run: python -c "from lib3mf import get_wrapper"
test-windows:
needs: build-windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Download wheel
uses: actions/download-artifact@v4
with:
name: windows-wheel
path: wheel-download
- name: Install wheel
shell: powershell
run: pip install (Get-ChildItem wheel-download\*.whl).FullName
- name: Test Import
shell: powershell
run: python -c "from lib3mf import get_wrapper"
test-macos:
needs: build-macos
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Download wheel
uses: actions/download-artifact@v4
with:
name: macos-wheel
path: wheel-download
- name: Identify OSX Wheel
run: echo "OSX_WHEEL_NAME=$(python -c "import os, glob; print(glob.glob('wheel-download/*.whl')[0])")" >> $GITHUB_ENV
- name: Install wheel
run: pip install ${{ env.OSX_WHEEL_NAME }}
- name: Test Import
run: python -c "from lib3mf import get_wrapper"
publish:
needs: [test-linux, test-windows, test-macos]
runs-on: ubuntu-latest
if: "${{ contains(github.event.head_commit.message, 'PUBLISH_NOW') }}"
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Download all wheels
uses: actions/download-artifact@v4
with:
name: linux-wheel
path: dist
- uses: actions/download-artifact@v4
with:
name: windows-wheel
path: dist
- uses: actions/download-artifact@v4
with:
name: macos-wheel
path: dist
- name: Install dependencies
run: pip install twine
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*