Skip to content

ci: build wheel

ci: build wheel #12

Workflow file for this run

name: Release
on:
pull_request:
branches: [ main, master, develop ]
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., v4.2.0)'
required: true
type: string
jobs:
extract-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
version_number: ${{ steps.version.outputs.version_number }}
steps:
- name: Extract version from tag
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION=${{ inputs.tag }}
else
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
build-wheels:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-15-intel]
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
submodules: recursive
- name: Install cibuildwheel
run: |
python -m pip install --upgrade pip
pip install cibuildwheel
- name: Build wheels
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_BEFORE_BUILD: "pip install uv && uv sync --frozen --no-dev || uv sync --no-dev"
run: |
cibuildwheel --output-dir wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
retention-days: 7
build-sdist:
# sdist is platform-agnostic (source distribution), so we only need to build it once
# Use Debian container to avoid package conflicts with Ubuntu runner
runs-on: ubuntu-latest
container: python:3.12-bookworm
permissions:
contents: write
env:
UV_LINK_MODE: copy
UV_CACHE_DIR: /github/home/.cache/uv
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
submodules: recursive
- name: Add Debian sid repository
run: |
echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
echo 'Package: *\nPin: release a=sid\nPin-Priority: 100' > /etc/apt/preferences.d/sid
- name: Install system dependencies
run: |
apt-get update
# Ensure /etc/os-release exists (required by some actions' OS detection)
apt-get install -y base-files
apt-get install -y build-essential pkg-config libbz2-dev
apt-get install -y -t sid libmapnik-dev
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Build sdist
run: |
uv build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
retention-days: 7
release:
needs:
- extract-version
- build-wheels
- build-sdist
runs-on: ubuntu-latest
permissions:
contents: write
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist-all
- name: Combine artifacts
run: |
mkdir -p dist
# Copy all wheels
find dist-all -name "*.whl" -exec cp {} dist/ \;
# Copy sdist (should be only one)
find dist-all -name "*.tar.gz" -exec cp {} dist/ \;
echo "Artifacts in dist/:"
ls -lh dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ needs.extract-version.outputs.version }}
name: Release ${{ needs.extract-version.outputs.version }}
body: |
## Python Mapnik ${{ needs.extract-version.outputs.version_number }}
### Installation
Download the wheel file for your platform and install:
```bash
pip install mapnik-${{ needs.extract-version.outputs.version_number }}-*.whl
```
Or install directly from GitHub (replace platform tag as needed):
```bash
pip install https://github.com/${{ github.repository }}/releases/download/${{ needs.extract-version.outputs.version }}/mapnik-${{ needs.extract-version.outputs.version_number }}-cp312-cp312-linux_x86_64.whl
```
Or install from source:
```bash
pip install git+https://github.com/${{ github.repository }}.git@${{ needs.extract-version.outputs.version }}
```
### Requirements
- Python >= 3.12
- Mapnik >= 4.2.0
### Changes
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ needs.extract-version.outputs.version }}/CHANGELOG.md) for details.
files: |
dist/*.whl
dist/*.tar.gz
draft: false
prerelease: false
- name: Summary
run: |
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ Released version: **${{ needs.extract-version.outputs.version }}**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Artifacts Built:" >> $GITHUB_STEP_SUMMARY
ls -lh dist/ >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Supported Platforms:" >> $GITHUB_STEP_SUMMARY
echo "- Linux x86_64: ✅" >> $GITHUB_STEP_SUMMARY
echo "- Linux arm64: ✅" >> $GITHUB_STEP_SUMMARY
echo "- macOS x86_64: ✅" >> $GITHUB_STEP_SUMMARY
echo "- macOS arm64: ✅" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Distribution:" >> $GITHUB_STEP_SUMMARY
echo "- GitHub Release: ✅" >> $GITHUB_STEP_SUMMARY