Skip to content

Add geolocation backend #270

Add geolocation backend

Add geolocation backend #270

Workflow file for this run

name: CI and Deploy
on:
push:
branches: [ master, main ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ '**' ]
jobs:
determine-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install setuptools_scm
run: pip install setuptools_scm
- name: Get version
id: version
run: |
CMAKE_VERSION=$(python - <<'PY'
import re
from pathlib import Path
match = re.search(r'set\(MAPGET_VERSION\s+([0-9.]+)\)', Path('CMakeLists.txt').read_text())
if not match:
raise SystemExit('Could not find MAPGET_VERSION in CMakeLists.txt')
print(match.group(1))
PY
)
if [[ "$GITHUB_EVENT_NAME" == "pull_request" && "$GITHUB_BASE_REF" == "main" && "$GITHUB_HEAD_REF" == release/* ]]; then
# Release PRs need installable intermediate wheels before the final
# release tag exists. Use the planned CMake version as the base so
# `release/2026.3.0` publishes `2026.3.0.devN`, not the SCM-inferred
# `2026.2.1.devN` from the previous release tag.
DEV_SERIAL=$((GITHUB_RUN_NUMBER * 100 + GITHUB_RUN_ATTEMPT))
VERSION="${CMAKE_VERSION}.dev${DEV_SERIAL}"
else
VERSION=$(python -c "import setuptools_scm; print(setuptools_scm.get_version(local_scheme='no-local-version'))")
fi
echo "Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
build-manylinux:
needs: [determine-version]
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
arch: ["x86_64"]
runs-on: ubuntu-latest
container: ghcr.io/klebert-engineering/manylinux-cpp17-py${{ matrix.python-version }}-${{ matrix.arch }}:2025.1
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Init submodules
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git submodule update --init --recursive --depth=1
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Install libuuid
run: |
yum -y install libuuid-devel
- name: Configure
run: |
python3 -m venv venv && . ./venv/bin/activate
pip install -U setuptools wheel pip
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DMAPGET_ENABLE_TESTING=True \
-DMAPGET_BUILD_EXAMPLES=True \
-DMAPGET_WITH_WHEEL=True \
-DMAPGET_WITH_SERVICE=True \
-DMAPGET_WITH_HTTPLIB=True \
-DMAPGET_VERSION="${{ needs.determine-version.outputs.version }}" \
-GNinja
- name: Build
run: |
. ./venv/bin/activate
cd build
cmake --build .
mv bin/wheel bin/wheel-auditme
auditwheel repair bin/wheel-auditme/mapget*.whl -w bin/wheel
- name: Test
timeout-minutes: 30
run: |
. ./venv/bin/activate
cd build
ctest --verbose --no-tests=error
- name: Deploy
uses: actions/upload-artifact@v4
with:
name: mapget-py${{ matrix.python-version }}-ubuntu-latest-${{ matrix.arch }}
path: build/bin/wheel/*.whl
build-manylinux-aarch64:
needs: [determine-version]
if: |
github.event_name != 'pull_request' ||
(github.base_ref == 'main' && startsWith(github.head_ref, 'release/'))
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
runs-on: ubuntu-24.04-arm
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
MANYLINUX_IMAGE: ghcr.io/klebert-engineering/manylinux-cpp17-py${{ matrix.python-version }}-aarch64:2025.1
steps:
- uses: actions/checkout@v4
with:
submodules: false
- name: Init submodules
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git submodule update --init --recursive --depth=1
- name: Build aarch64 wheel in manylinux container
timeout-minutes: 60
run: |
docker pull "$MANYLINUX_IMAGE"
docker run --rm \
-v "$GITHUB_WORKSPACE:/work" \
-w /work \
-e MAPGET_VERSION="${{ needs.determine-version.outputs.version }}" \
"$MANYLINUX_IMAGE" \
bash -lc '
set -euo pipefail
yum -y install libuuid-devel
python3 -m venv venv && . ./venv/bin/activate
pip install -U setuptools wheel pip
rm -rf build
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DMAPGET_ENABLE_TESTING=True \
-DMAPGET_BUILD_EXAMPLES=True \
-DMAPGET_WITH_WHEEL=True \
-DMAPGET_WITH_SERVICE=True \
-DMAPGET_WITH_HTTPLIB=True \
-DMAPGET_VERSION="$MAPGET_VERSION" \
-GNinja
cmake --build .
mv bin/wheel bin/wheel-auditme
auditwheel repair bin/wheel-auditme/mapget*.whl -w bin/wheel
ctest --verbose --no-tests=error
'
- name: Deploy
uses: actions/upload-artifact@v4
with:
name: mapget-py${{ matrix.python-version }}-ubuntu-latest-aarch64
path: build/bin/wheel/*.whl
build:
needs: [determine-version]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-14, windows-2022]
python-version: ["3.10", "3.11", "3.12", "3.13"]
exclude:
# Python 3.10 doesn't have ARM64 builds for macOS
- os: macos-14
python-version: "3.10"
env:
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- run: python -m pip install setuptools wheel ninja
- name: Build (macOS)
if: startsWith(matrix.os, 'macos')
run: |
python -m pip install delocate
export MACOSX_DEPLOYMENT_TARGET=11.0 # ARM64 requires macOS 11.0+
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DPython3_ROOT_DIR="$pythonLocation" \
-DPython3_FIND_FRAMEWORK=LAST \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DMAPGET_ENABLE_TESTING=ON \
-DMAPGET_BUILD_EXAMPLES=ON \
-DMAPGET_WITH_WHEEL=True \
-DMAPGET_WITH_SERVICE=True \
-DMAPGET_WITH_HTTPLIB=True \
-DMAPGET_VERSION="${{ needs.determine-version.outputs.version }}" \
-GNinja
cmake --build .
- name: Enable Developer Command Prompt (Windows)
uses: ilammy/msvc-dev-cmd@v1.12.1
if: matrix.os == 'windows-2022'
- name: Build (Windows)
if: matrix.os == 'windows-2022'
run: |
# Install NASM and jom using chocolatey (required for OpenSSL build)
choco install nasm jom -y
# Add NASM to PATH for current session
$env:PATH = "$env:PATH;C:\Program Files\NASM"
# Verify NASM installation
nasm -v
echo "cmake -DPython3_ROOT_DIR=$env:pythonLocation"
mkdir build
cd build
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release `
"-DPython3_ROOT_DIR=$env:pythonLocation" `
-DPython3_FIND_REGISTRY=LAST `
-DCMAKE_C_COMPILER_LAUNCHER=sccache `
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache `
-DMAPGET_ENABLE_TESTING=YES `
-DMAPGET_BUILD_EXAMPLES=YES `
-DMAPGET_WITH_WHEEL=True `
-DMAPGET_WITH_SERVICE=True `
-DMAPGET_WITH_HTTPLIB=True `
-DMAPGET_VERSION="${{ needs.determine-version.outputs.version }}"
cmake --build . --config Release
- name: Deploy
uses: actions/upload-artifact@v4
with:
name: mapget-py${{ matrix.python-version }}-${{ matrix.os }}
path: build/**/bin/wheel/*.whl
- name: Test
timeout-minutes: 30
run: |
cd build
ctest -C Release --verbose --no-tests=error
deploy:
needs: [determine-version, build-manylinux, build-manylinux-aarch64, build]
if: |
(github.event_name == 'push' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))) ||
(github.event_name == 'pull_request' && github.base_ref == 'main' && startsWith(github.head_ref, 'release/'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install setuptools wheel setuptools_scm twine
- name: Set version from determine-version job
id: version
run: |
VERSION="${{ needs.determine-version.outputs.version }}"
echo "Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Validate version
run: |
python .github/scripts/validate_version.py
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: mapget-py*
path: dist/
- name: Consolidate wheels
run: |
echo "Downloaded artifacts structure:"
find dist/ -type f -name "*.whl"
# Move all wheels to dist/ root
mkdir -p dist_consolidated
find dist/ -name "*.whl" -type f -exec mv {} dist_consolidated/ \;
rm -rf dist
mv dist_consolidated dist
echo "Consolidated wheels:"
ls -la dist/
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.KE_PYPI_TOKEN }}
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Uploading release PR development version ${{ steps.version.outputs.version }} to PyPI..."
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "Uploading development snapshot version ${{ steps.version.outputs.version }} to PyPI..."
else
echo "Uploading release version ${{ steps.version.outputs.version }} to PyPI..."
fi
twine upload \
--non-interactive \
--skip-existing \
--verbose \
--disable-progress-bar \
dist/*.whl