Build and Deploy to Test PyPI #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy to Test PyPI | |
on: | |
workflow_dispatch: | |
env: | |
BUILD_TYPE: Release | |
jobs: | |
build-windows: | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5.1.1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Build and Package | |
run: .\build_windows.ps1 | |
- name: Publish on PyPI | |
run: | | |
$maxRetries = 3 | |
$retryCount = 0 | |
$success = $false | |
while (-not $success -and $retryCount -lt $maxRetries) { | |
try { | |
python -m twine upload --repository-url https://test.pypi.org/legacy/ -u __token__ -p "${{ secrets.TEST_PYPI_REPO_TOKEN }}" PythonBuild/dist/* --verbose --disable-progress-bar | |
$success = $true | |
} | |
catch { | |
$retryCount++ | |
Write-Host "Upload failed. Retrying in 30 seconds... (Attempt $retryCount of $maxRetries)" | |
Start-Sleep -Seconds 30 | |
} | |
} | |
if (-not $success) { | |
throw "Failed to upload after $maxRetries attempts" | |
} | |
build-manylinux: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['cp37-cp37m', 'cp38-cp38', 'cp39-cp39', 'cp310-cp310', 'cp311-cp311', 'cp312-cp312'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v3 | |
- name: Build manylinux wheel | |
run: | | |
docker build -t tensorfrost-manylinux . | |
docker run --rm -e PYTHON_VERSION=${{ matrix.python-version }} -v $(pwd):/io tensorfrost-manylinux | |
- name: Install Twine | |
run: pip install twine | |
- name: Publish on PyPI | |
run: python -m twine upload --repository-url https://test.pypi.org/legacy/ -u __token__ -p ${{ secrets.TEST_PYPI_REPO_TOKEN }} wheelhouse/*.whl --verbose --disable-progress-bar |