Skip to content

Build and Deploy Packages #3

Build and Deploy Packages

Build and Deploy Packages #3

name: Build and Deploy Packages
on:
push:
tags:
- 'v[0-9]*'
- feature/ci_test
workflow_dispatch:
jobs:
build-linux:
name: Build Linux packages (manylinux)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Generate meson files
run: |
python3 scripts/generate_meson.py ./src/dbzero/ core
python3 scripts/generate_meson_tests.py tests/
- name: Configure git
run: |
git config --global user.email "ci@example.com"
git config --global user.name "CI Builder"
rm .gitignore
git add . && git commit -m "Update meson files for build"
- name: Install build dependencies
run: |
pip install build cibuildwheel
- name: Build wheels (manylinux)
run: python3 -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: cp${{ matrix.python-version }}-*
CIBW_SKIP: pp* *-musllinux*
CIBW_ARCHS_LINUX: x86_64 aarch64
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
- name: Upload Linux wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.python-version }}
path: wheelhouse/*.whl
# build-windows:
# name: Build Windows packages
# runs-on: windows-2019
# strategy:
# fail-fast: false
# matrix:
# python-version: ["3.11", "3.12", "3.13"]
# architecture: [x64, x86]
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
# architecture: ${{ matrix.architecture }}
# - name: Set up MSVC
# uses: bus1/cabuild/action/msdevshell@v1
# with:
# architecture: ${{ matrix.architecture }}
# - name: Generate meson files
# run: |
# python scripts/generate_meson.py ./src/dbzero/ core
# python scripts/generate_meson_tests.py tests/
# - name: Configure git
# run: |
# git config --global user.email "ci@example.com"
# git config --global user.name "CI Builder"
# Remove-Item .gitignore -ErrorAction SilentlyContinue
# git add . && git commit -m "Update meson files for build"
# - name: Install build dependencies
# run: |
# pip install build cibuildwheel
# - name: Build wheels (Windows)
# run: python -m cibuildwheel --output-dir wheelhouse
# env:
# CIBW_BUILD: cp${{ matrix.python-version }}-*
# CIBW_ARCHS_WINDOWS: ${{ matrix.architecture }}
# - name: Upload Windows wheels
# uses: actions/upload-artifact@v4
# with:
# name: wheels-windows-${{ matrix.python-version }}-${{ matrix.architecture }}
# path: wheelhouse/*.whl
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Generate meson files
run: |
python3 scripts/generate_meson.py ./src/dbzero/ core
python3 scripts/generate_meson_tests.py tests/
- name: Configure git
run: |
git config --global user.email "ci@example.com"
git config --global user.name "CI Builder"
rm .gitignore
git add . && git commit -m "Update meson files for build"
- name: Install build dependencies
run: |
pip install build meson
- name: Build source distribution
run: python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
deploy-to-pypi:
name: Deploy to PyPI (Manual)
runs-on: ubuntu-latest
needs: [build-linux, build-sdist]
if: github.event_name == 'workflow_dispatch'
environment: pypi-deployment
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./dist/
- name: Flatten artifact structure
run: |
mkdir -p ./upload/
find ./dist/ -name "*.whl" -exec cp {} ./upload/ \;
find ./dist/ -name "*.tar.gz" -exec cp {} ./upload/ \;
ls -la ./upload/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: ${{ vars.REPO_URL }}
username: ${{ vars.USER }}
password: ${{ secrets.PASSWORD }}
packages-dir: ./upload/
verbose: true