Skip to content

Build and Publish

Build and Publish #2

Workflow file for this run

name: Build and Publish
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
# -- Build Linux wheels FIRST (fastest, no downloads needed) --
build_linux:
name: Build Linux wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/cibuildwheel@v2.21.3
env:
CIBW_BUILD: cp310-* cp311-* cp312-* cp313-*
CIBW_SKIP: pp* *-manylinux_i686 *-musllinux_i686 *-musllinux_x86_64
CIBW_ARCHS_LINUX: x86_64
CIBW_TEST_COMMAND: >
python -c "from vtrng import VTRNG; rng = VTRNG(verbose=False, startup_assessment=False); print(rng.random_hex(16))"
- uses: actions/upload-artifact@v4
with:
name: wheels-linux
path: ./wheelhouse/*.whl
# -- Build Windows wheels AFTER Linux finishes --
build_windows:
name: Build Windows wheels
runs-on: windows-latest
needs: build_linux # stagger: wait for Linux to finish
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/cibuildwheel@v2.21.3
env:
CIBW_BUILD: cp310-* cp311-* cp312-* cp313-*
CIBW_SKIP: pp* *-win32
CIBW_ARCHS_WINDOWS: AMD64
CIBW_ENVIRONMENT: PYTHONIOENCODING=utf-8
CIBW_TEST_COMMAND: >
python -c "from vtrng import VTRNG; rng = VTRNG(verbose=False, startup_assessment=False); print(rng.random_hex(16))"
- uses: actions/upload-artifact@v4
with:
name: wheels-windows
path: ./wheelhouse/*.whl
# -- Build macOS wheels AFTER Windows finishes --
build_macos:
name: Build macOS wheels
runs-on: macos-latest
needs: build_windows # stagger: wait for Windows to finish
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/cibuildwheel@v2.21.3
env:
CIBW_BUILD: cp310-* cp311-* cp312-* cp313-*
CIBW_SKIP: pp*
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_TEST_COMMAND: >
python -c "from vtrng import VTRNG; rng = VTRNG(verbose=False, startup_assessment=False); print(rng.random_hex(16))"
- uses: actions/upload-artifact@v4
with:
name: wheels-macos
path: ./wheelhouse/*.whl
# -- Source distribution --
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
# -- Inspect what we built --
inspect:
name: List built packages
needs: [build_linux, build_windows, build_macos, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: '*'
path: dist
merge-multiple: true
- name: Show all packages
run: |
echo " === VTRNG Built Packages === "
echo ""
echo "--- Wheels ---"
for f in dist/*.whl; do
size=$(du -h "$f" | cut -f1)
echo " $size $(basename $f)"
done
echo ""
echo "--- Source ---"
for f in dist/*.tar.gz; do
size=$(du -h "$f" | cut -f1)
echo " $size $(basename $f)"
done
echo ""
echo "Total wheels: $(ls dist/*.whl 2>/dev/null | wc -l)"
echo "Total files: $(ls dist/* | wc -l)"
echo "============================================"
# Publish to TestPyPI
publish_test:
name: Upload to TestPyPI
needs: [inspect]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
environment: testpypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: '*'
path: dist
merge-multiple: true
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# real pypi implementation
# publish:
# name: Upload to PyPI
# needs: [inspect]
# runs-on: ubuntu-latest
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# environment: pypi
# permissions:
# id-token: write
# steps:
# - uses: actions/download-artifact@v4
# with:
# pattern: '*'
# path: dist
# merge-multiple: true
#
# - name: Publish to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1