Skip to content

Commit

Permalink
New github workflows
Browse files Browse the repository at this point in the history
- BuildAndPublish triggers on tag "v*.*.*" and main branch
- BuildAndTest triggers on dev branch and +ci commit message
  • Loading branch information
Bluemi committed Aug 20, 2024
1 parent 746393b commit 11987b1
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 145 deletions.
76 changes: 43 additions & 33 deletions .github/workflows/BuildAndPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
workflow_dispatch:
pull_request:
push:
branches:
- main
tags:
- 'v*.*.*'

defaults:
run:
Expand All @@ -17,14 +17,9 @@ jobs:
fail-fast: false
matrix:
platform: [windows-latest, macos-latest, macos-13, ubuntu-latest]
# platform: [ubuntu-latest]
python-version: ["3.11", "3.12"]
exclude: # We don't need this as cibuildwheel builds for all python versions
- platform: ubuntu-latest
python-version: "3.11"

runs-on: ${{ matrix.platform }}
if: "contains(github.event.head_commit.message, '+ci')"
if: "github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') && github.base_ref == 'refs/heads/main"

steps:
- uses: actions/checkout@v4
Expand All @@ -33,50 +28,65 @@ jobs:

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

- name: Add requirements
run: python -m pip install --upgrade wheel setuptools pybind11>=2.12.0 build pytest cibuildwheel
run: python -m pip install --upgrade setuptools pybind11>=2.12.0 cibuildwheel

- name: Copy Build Files
run: python3 setup.py copy_build_files
run: python setup.py copy_build_files

# building package on linux
- name: Build CiBuildWheel
- name: Build Packages
run: cibuildwheel --output-dir "dist"
env:
FORCE_AVX2: "1"
run: cibuildwheel --archs auto64 --output-dir dist
if: runner.os == 'Linux'
CIBW_ARCHS: auto64
CIBW_BUILD_FRONTEND: "pip; args: --verbose"
CIBW_ENVIRONMENT: "FORCE_AVX2=1"
CIBW_ENVIRONMENT_MACOS: "FORCE_AVX2=1 MACOSX_DEPLOYMENT_TARGET=10.15"
CIBW_SKIP: "cp313-*"

# building package on windows / osx
- name: Build
env:
FORCE_AVX2: "1"
run: python3 -m build
if: runner.os != 'Linux'
# upload artifacts
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: release-dists-${{ matrix.platform }}
path: python/dist

- name: Install
run: pip install --verbose .[test]
if: runner.os != 'Linux'
build_sdist:
runs-on: ubuntu-latest
if: "github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') && github.base_ref == 'refs/heads/main"

- name: Test
run: python -m pytest
if: runner.os != 'Linux'
steps:
- uses: actions/checkout@v4
with:
submodules: false

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

- name: Add requirements
run: python -m pip install --upgrade setuptools pybind11>=2.12.0

- name: Copy Build Files
run: python setup.py copy_build_files

- name: Build Source Distribution
run: python setup.py sdist

# upload artifacts
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: release-dists-${{ matrix.platform }}-python${{ matrix.python-version}}
path: python/dist/

name: release-dists-sdist
path: python/dist

pypi-publish:
runs-on: "ubuntu-latest"
if: "contains(github.event.head_commit.message, '+ci')"
if: "github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') && github.base_ref == 'refs/heads/main"

needs:
- build
- build_sdist

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
Expand Down
112 changes: 0 additions & 112 deletions .github/workflows/BuildAndPublishUniform.yml

This file was deleted.

68 changes: 68 additions & 0 deletions .github/workflows/BuildAndTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: BuildAndTest

on:
workflow_dispatch:
pull_request:
push:
branches:
- dev

defaults:
run:
working-directory: python

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [windows-latest, macos-latest, macos-13, ubuntu-latest]

runs-on: ${{ matrix.platform }}
if: "contains(github.event.head_commit.message, '+ci')"

steps:
- uses: actions/checkout@v4
with:
submodules: false

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

- name: Add requirements
run: python -m pip install --upgrade setuptools pybind11>=2.12.0 cibuildwheel

- name: Copy Build Files
run: python setup.py copy_build_files

- name: Build Packages
run: cibuildwheel --output-dir "dist"
env:
CIBW_ARCHS: auto64
CIBW_BUILD_FRONTEND: "pip; args: --verbose"
CIBW_ENVIRONMENT: "FORCE_AVX2=1"
CIBW_ENVIRONMENT_MACOS: "FORCE_AVX2=1 MACOSX_DEPLOYMENT_TARGET=10.15"
CIBW_SKIP: "cp313-*"

build_sdist:
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, '+ci')"

steps:
- uses: actions/checkout@v4
with:
submodules: false

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

- name: Add requirements
run: python -m pip install --upgrade setuptools pybind11>=2.12.0

- name: Copy Build Files
run: python setup.py copy_build_files

- name: Build Source Distribution
run: python setup.py sdist

0 comments on commit 11987b1

Please sign in to comment.