Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: build-macos

on:
push:
branches:
- main
tags:
- "[0-9]*.[0-9]*.[0-9]*"
paths-ignore:
- ".github/workflows/build.yml"
- ".github/workflows/build-windows.yml"
pull_request:
branches:
- main
paths-ignore:
- ".github/workflows/build.yml"
- ".github/workflows/build-windows.yml"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-wheel:
if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'docs-only') }}
runs-on: macos-13
permissions:
contents: read
env:
CIBW_BUILD: cp312-*
CIBW_ENVIRONMENT: SETUPTOOLS_SCM_PRETEND_VERSION_FOR_COMPAS_CGAL=${{ github.ref_type == 'tag' && github.ref_name || '' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Build wheels
run: pipx run --spec cibuildwheel==2.23.1 cibuildwheel --output-dir wheelhouse .

- uses: actions/upload-artifact@v4
with:
name: python-cp312-macos
path: wheelhouse/*.whl

test-wheel:
if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'docs-only') }}
needs: build-wheel
strategy:
fail-fast: false
matrix:
include:
- runner: macos-13
python-version: "3.12"
wheel-glob: "*x86_64.whl"
- runner: macos-14
python-version: "3.13"
wheel-glob: "*arm64.whl"
runs-on: ${{ matrix.runner }}
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/download-artifact@v4
with:
name: python-cp312-macos
path: dist

- name: Install wheel in a clean virtual environment
run: |
WHEEL=$(find dist -name "${{ matrix.wheel-glob }}" -print -quit)
[ -n "$WHEEL" ] || { echo "::error::No wheel found matching ${{ matrix.wheel-glob }}"; exit 1; }
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install pytest "$WHEEL"
python -c "import compas_cgal; print(compas_cgal.__version__)"
python -m pytest tests

publish:
needs:
- build-wheel
- test-wheel
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
environment: macos
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: "python-*-macos*"
merge-multiple: true
path: dist

- name: Assert wheel versions match the tag
run: |
[[ "$GITHUB_REF_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::Expected a bare X.Y.Z tag, got $GITHUB_REF_NAME"; exit 1; }
shopt -s nullglob
wheels=(dist/*.whl)
[ ${#wheels[@]} -gt 0 ] || { echo "::error::No wheels were downloaded for publishing"; exit 1; }
for whl in "${wheels[@]}"; do
v=$(basename "$whl" | cut -d- -f2)
[ "$v" = "$GITHUB_REF_NAME" ] || { echo "::error::$whl is $v, expected $GITHUB_REF_NAME"; exit 1; }
done

- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
113 changes: 113 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: build-windows

on:
push:
branches:
- main
tags:
- "[0-9]*.[0-9]*.[0-9]*"
paths-ignore:
- ".github/workflows/build.yml"
- ".github/workflows/build-macos.yml"
pull_request:
branches:
- main
paths-ignore:
- ".github/workflows/build.yml"
- ".github/workflows/build-macos.yml"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-wheel:
if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'docs-only') }}
runs-on: windows-2022
permissions:
contents: read
env:
CIBW_BUILD: cp312-*
CIBW_ENVIRONMENT: SETUPTOOLS_SCM_PRETEND_VERSION_FOR_COMPAS_CGAL=${{ github.ref_type == 'tag' && github.ref_name || '' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Build wheels
run: pipx run --spec cibuildwheel==2.23.1 cibuildwheel --output-dir wheelhouse .

- uses: actions/upload-artifact@v4
with:
name: python-cp312-windows-amd64
path: wheelhouse/*.whl

test-wheel:
if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'docs-only') }}
needs: build-wheel
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13"]
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/download-artifact@v4
with:
name: python-cp312-windows-amd64
path: dist

- name: Install wheel in a clean virtual environment
shell: pwsh
run: |
python -m venv .venv
.\.venv\Scripts\python -m pip install --upgrade pip
$wheel = (Get-ChildItem dist\*.whl | Select-Object -First 1).FullName
if (-not $wheel) { throw "No wheel found in dist" }
.\.venv\Scripts\python -m pip install pytest $wheel
.\.venv\Scripts\python -c "import compas_cgal; print(compas_cgal.__version__)"
.\.venv\Scripts\python -m pytest tests

publish:
needs:
- build-wheel
- test-wheel
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
environment: windows
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: "python-*-windows-*"
merge-multiple: true
path: dist

- name: Assert wheel versions match the tag
run: |
[[ "$GITHUB_REF_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::Expected a bare X.Y.Z tag, got $GITHUB_REF_NAME"; exit 1; }
shopt -s nullglob
wheels=(dist/*.whl)
[ ${#wheels[@]} -gt 0 ] || { echo "::error::No wheels were downloaded for publishing"; exit 1; }
for whl in "${wheels[@]}"; do
v=$(basename "$whl" | cut -d- -f2)
[ "$v" = "$GITHUB_REF_NAME" ] || { echo "::error::$whl is $v, expected $GITHUB_REF_NAME"; exit 1; }
done

- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
Loading