Merge pull request #11 from diggit/linux_intel_build #89
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 2021-2023 Jetperch LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# GitHub actions | |
# See documentation: https://docs.github.com/en/actions | |
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
# CMake example: https://github.com/Mizux/cmake-cpp/blob/main/.github/workflows/amd64_windows.yml | |
name: Packaging | |
on: ['push', 'pull_request'] | |
env: | |
PYTHON_VERSION: '3.11' | |
jobs: | |
build_native_win: | |
name: Build native on windows-latest | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Display CMake version | |
run: cmake --version | |
- name: Build static | |
run: | | |
cmake -S . -B cmake_build_static -G "Visual Studio 17 2022" -DCMAKE_CONFIGURATION_TYPES=Release -DCMAKE_VERBOSE_MAKEFILE=ON | |
cmake --build cmake_build_static --config Release --target ALL_BUILD | |
- name: Run tests | |
run: cmake --build cmake_build_static --config Release --target RUN_TESTS | |
- name: Build dynamic | |
run: | | |
cmake -S . -B cmake_build_dyn -G "Visual Studio 17 2022" -DCMAKE_CONFIGURATION_TYPES=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=ON | |
cmake --build cmake_build_dyn --config Release --target jls | |
- name: Upload binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-latest | |
path: | | |
cmake_build_static/example/Release/jls.exe | |
cmake_build_dyn/src/Release/jls.* | |
build_native_posix: | |
name: Build native on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-latest", "macos-latest"] | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Display CMake version | |
run: cmake --version | |
- name: Build static | |
run: | | |
cmake -S . -B cmake_build_static -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_VERBOSE_MAKEFILE=ON | |
cmake --build cmake_build_static | |
- name: Run tests | |
run: cmake --build cmake_build_static --target test | |
- name: Upload binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }} | |
path: | | |
cmake_build_static/example/jls | |
build_python_sdist: | |
name: Build python sdist | |
runs-on: ubuntu-latest | |
steps: | |
- name: Display info | |
run: | | |
echo "github.event_name=$GITHUB_EVENT_NAME" | |
echo "github.ref=$GITHUB_REF" | |
echo "github.ref_type=$GITHUB_REF_TYPE" | |
echo "runner.os=$RUNNER_OS" | |
echo "runner.arch=$RUNNER_ARCH" | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Display version | |
run: python -VV | |
- name: Install python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build wheel | |
- name: Build sdist | |
run: python -m build --sdist | |
- name: Install the wheel | |
run: python -m pip install -f dist pyjls | |
- name: Run python unit tests | |
run: python3 -m unittest | |
working-directory: pyjls/test | |
- name: Upload python source package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python_sdist | |
path: dist/*.tar.gz | |
if-no-files-found: error | |
build_python_wheels: | |
name: Build on ${{ matrix.os }} | |
needs: | |
- build_native_win | |
- build_native_posix | |
- build_python_sdist | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-latest", "windows-latest", "macos-latest"] | |
python_version: ["cp39", "cp310", "cp311", "cp312"] | |
steps: | |
- name: Download sdist | |
uses: actions/download-artifact@v4 | |
with: | |
name: python_sdist | |
path: dist/ | |
- name: Find sdist filename | |
shell: bash | |
id: find_sdist_filename | |
run: echo "filename=$(ls dist/*.tar.gz)" >> $GITHUB_OUTPUT | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_ARCHS_MACOS: universal2 | |
CIBW_ARCHS_WINDOWS: native | |
CIBW_ARCHS_LINUX: x86_64 | |
# skip PyPy: Cython only supports CPython | |
# skip musllinux: build takes too long with default os images. | |
CIBW_SKIP: 'pp* *musllinux*' | |
CIBW_BUILD: '${{ matrix.python_version }}-*' | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: pytest --pyargs pyjls | |
with: | |
package-dir: ${{ steps.find_sdist_filename.outputs.filename }} | |
- name: Upload python wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python_wheel-${{ matrix.os }}-${{ matrix.python_version }} | |
path: wheelhouse/*.whl | |
if-no-files-found: error | |
publish_python: | |
name: Publish python packages to PyPi | |
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/v') | |
needs: | |
- build_python_sdist | |
- build_python_wheels | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- name: Download python sdist artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: python_sdist | |
path: dist/ | |
- name: Download python wheel artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: python_wheel-* | |
path: dist/ | |
- name: Display artifacts | |
shell: bash | |
run: ls dist/* | |
- name: Publish packages to PyPi | |
uses: pypa/[email protected] | |
with: | |
verbose: true | |
print-hash: true | |
- name: Download windows-latest artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: windows-latest | |
path: dist_windows_latest/ | |
- name: Copy jls.exe | |
shell: bash | |
run: cp dist_windows_latest/cmake_build_static/example/Release/* dist/ | |
- name: Publish release assets | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
dist/* |