ci: build wheel #17
Workflow file for this run
This file contains hidden or 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: 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" | |
| # Linux: install system dependencies in manylinux container | |
| CIBW_BEFORE_ALL_LINUX: | | |
| if command -v apt-get >/dev/null 2>&1; then | |
| mkdir -p /etc/apt/sources.list.d /etc/apt/preferences.d | |
| echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list | |
| echo 'Package: * | |
| Pin: release a=sid | |
| Pin-Priority: 100' > /etc/apt/preferences.d/sid | |
| apt-get update | |
| apt-get install -y build-essential pkg-config libbz2-dev | |
| apt-get install -y -t sid libmapnik-dev fonts-noto-cjk | |
| elif command -v dnf >/dev/null 2>&1 || command -v yum >/dev/null 2>&1; then | |
| DNF_BIN=$(command -v dnf || command -v yum) | |
| $DNF_BIN install -y epel-release | |
| # Enable CRB on EL9 for additional build deps. | |
| if command -v dnf >/dev/null 2>&1; then | |
| dnf config-manager --set-enabled crb || true | |
| fi | |
| $DNF_BIN install -y \ | |
| bzip2-devel \ | |
| gcc gcc-c++ make \ | |
| pkgconfig | |
| $DNF_BIN install -y mapnik-devel | |
| # Fonts are optional for building; try common package names. | |
| $DNF_BIN install -y google-noto-sans-cjk-ttc-fonts || \ | |
| $DNF_BIN install -y google-noto-cjk-fonts || \ | |
| $DNF_BIN install -y noto-sans-cjk-fonts || true | |
| else | |
| echo "No supported package manager found (apt-get or yum)." >&2 | |
| exit 1 | |
| fi | |
| # macOS: install dependencies via Homebrew | |
| CIBW_BEFORE_ALL_MACOS: "brew install mapnik icu4c pkg-config boost gdal proj harfbuzz libx11 xorgproto libxext libxrender libxau libxdmcp xtrans" | |
| # macOS: set up build environment | |
| CIBW_BEFORE_BUILD_MACOS: | | |
| eval $(brew shellenv) | |
| HOMEBREW_PREFIX=$(brew --prefix) | |
| ICU4C_PREFIX=$(brew --prefix icu4c) | |
| BOOST_PREFIX=$(brew --prefix boost) | |
| GDAL_PREFIX=$(brew --prefix gdal) | |
| PROJ_PREFIX=$(brew --prefix proj) | |
| HARFBUZZ_PREFIX=$(brew --prefix harfbuzz) | |
| XORGPROTO_PREFIX=$(brew --prefix xorgproto) | |
| LIBX11_PREFIX=$(brew --prefix libx11) | |
| LIBXEXT_PREFIX=$(brew --prefix libxext) | |
| LIBXRENDER_PREFIX=$(brew --prefix libxrender) | |
| LIBXAU_PREFIX=$(brew --prefix libxau) | |
| LIBXDMCP_PREFIX=$(brew --prefix libxdmcp) | |
| XTRANS_PREFIX=$(brew --prefix xtrans) | |
| XORGPROTO_PKGCONFIG_DIR=$(find "$HOMEBREW_PREFIX/Cellar/xorgproto" -type d -name "pkgconfig" 2>/dev/null | head -1) | |
| [ -z "$XORGPROTO_PKGCONFIG_DIR" ] && XORGPROTO_PKGCONFIG_DIR="$XORGPROTO_PREFIX/share/pkgconfig" | |
| export PKG_CONFIG_PATH="$HOMEBREW_PREFIX/lib/pkgconfig:$HOMEBREW_PREFIX/share/pkgconfig:$ICU4C_PREFIX/lib/pkgconfig:$GDAL_PREFIX/lib/pkgconfig:$PROJ_PREFIX/lib/pkgconfig:$HARFBUZZ_PREFIX/lib/pkgconfig:$LIBX11_PREFIX/lib/pkgconfig:$LIBXEXT_PREFIX/lib/pkgconfig:$LIBXRENDER_PREFIX/lib/pkgconfig:$LIBXAU_PREFIX/lib/pkgconfig:$LIBXDMCP_PREFIX/lib/pkgconfig:$XTRANS_PREFIX/share/pkgconfig:$XORGPROTO_PKGCONFIG_DIR:$XORGPROTO_PREFIX/share/pkgconfig:$XORGPROTO_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" | |
| export CXXFLAGS="-I$BOOST_PREFIX/include -I$GDAL_PREFIX/include -I$PROJ_PREFIX/include -I$HARFBUZZ_PREFIX/include $CXXFLAGS" | |
| export LDFLAGS="-L$BOOST_PREFIX/lib -L$GDAL_PREFIX/lib -L$PROJ_PREFIX/lib -L$HARFBUZZ_PREFIX/lib $LDFLAGS" | |
| run: | | |
| cibuildwheel --output-dir wheelhouse | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }} | |
| path: wheelhouse/*.whl | |
| retention-days: 7 | |
| release: | |
| needs: | |
| - extract-version | |
| - build-wheels | |
| 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 |