Add CI to build sdist and wheels distributions #49
Workflow file for this run
This file contains 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
# Copyright (C) 2023 Roberto Rossini ([email protected]) | |
# SPDX-License-Identifier: MIT | |
name: Pip | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
paths: | |
- ".github/workflows/pip.yml" | |
- "cmake/**" | |
- "src/**" | |
- "test/**" | |
- "CMakeLists.txt" | |
- "conanfile.txt" | |
- "pyproject.toml" | |
- "setup.cfg" | |
- "setup.py" | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
paths: | |
- ".github/workflows/pip.yml" | |
- "cmake/**" | |
- "src/**" | |
- "test/**" | |
- "CMakeLists.txt" | |
- "conanfile.txt" | |
- "pyproject.toml" | |
- "setup.cfg" | |
- "setup.py" | |
env: | |
CONAN_HOME: "${{ github.workspace }}/conan/" | |
# https://stackoverflow.com/a/72408109 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build-project: | |
strategy: | |
fail-fast: false | |
matrix: | |
# platform: [windows-latest, macos-latest, ubuntu-latest] | |
platform: [macos-latest, ubuntu-latest] | |
python-version: ["3.7", "3.11"] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Add requirements | |
run: python -m pip install --upgrade conan wheel setuptools | |
- name: Generate cache key | |
id: cache-key | |
run: | | |
hash="${{ hashFiles('conanfile.txt', '.github/workflows/pip.yml') }}" | |
echo "conan-key=pip-$hash" >> $GITHUB_OUTPUT | |
- name: Restore Conan cache | |
id: cache-conan | |
uses: actions/cache/restore@v3 | |
with: | |
key: conan-${{ steps.cache-key.outputs.conan-key }} | |
path: ${{ env.CONAN_HOME }} | |
- name: Configure Conan | |
if: steps.cache-conan.outputs.cache-hit != 'true' | |
run: | | |
conan profile detect --force | |
- name: Clean Conan cache (pre-build) | |
if: steps.cache-conan.outputs.cache-hit != 'true' | |
run: | | |
conan cache clean "*" --build | |
conan cache clean "*" --download | |
conan cache clean "*" --source | |
conan remove --confirm "*" | |
- name: Install build dependencies | |
run: | | |
conan install . \ | |
-s build_type=Release \ | |
-s compiler.cppstd=17 \ | |
--output-folder conan_build \ | |
-o '*/*:shared=True' \ | |
--build=missing | |
- name: Clean Conan cache (post-build) | |
if: steps.cache-conan.outputs.cache-hit != 'true' | |
run: | | |
conan cache clean "*" --build | |
conan cache clean "*" --download | |
conan cache clean "*" --source | |
- name: Save Conan cache | |
uses: actions/cache/save@v3 | |
if: steps.cache-conan.outputs.cache-hit != 'true' | |
with: | |
key: conan-${{ steps.cache-key.outputs.conan-key }} | |
path: ${{ env.CONAN_HOME }} | |
- name: Build and install | |
env: | |
CMAKE_ARGS: "-DCMAKE_PREFIX_PATH=${{ github.workspace}}/conan_build" | |
run: pip install --verbose . | |
- name: Test | |
run: python -c 'import hictkpy; print(hictkpy.__version__)' | |
pip-status-check: | |
name: Status Check (pip) | |
if: ${{ always() }} | |
runs-on: ubuntu-latest | |
needs: | |
- build-project | |
steps: | |
- name: Collect job results | |
if: needs.build-project.result != 'success' | |
run: exit 1 |