Skip to content

Test

Test #160

Workflow file for this run

name: Build And Publish
on:
push:
branches: [ master ]
paths:
- '.github/workflows/*'
- 'cmake/*'
- 'deps/*'
- 'include/*'
- 'ntgcalls/*'
- 'wrtc/*'
- 'CMakeLists.txt'
- 'setup.py'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
cibw_archs: "native"
shared_name: "linux-x86_64"
cibw_os_build: "manylinux_"
#- os: ubuntu-latest
# cibw_archs: "aarch64"
# shared_name: "linux-arm64"
# cibw_os_build: "manylinux_"
- os: windows-latest
cibw_archs: "native"
shared_name: "windows-x86_64"
- os: macos-13
cibw_archs: "arm64"
cibw_os_build: "macosx_arm64"
shared_name: "macos-arm64"
fail-fast: false
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up QEMU
if: matrix.cibw_archs == 'aarch64'
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Install SetupTools
if: matrix.cibw_os_build == 'macosx_arm64'
run: |
pip install setuptools
- name: Build Debug Shared lib
run: python3 setup.py build_shared --no-preserve-cache --debug
- name: Build Release Shared lib
run: python3 setup.py build_shared --no-preserve-cache
- name: Upload Debug Shared lib for ${{ matrix.shared_name }}
uses: actions/upload-artifact@v3
with:
name: ntgcalls.${{ matrix.shared_name }}-debug-shared_libs
path: ./shared-output-debug/*
if-no-files-found: error
- name: Upload Release Shared lib for ${{ matrix.shared_name }}
uses: actions/upload-artifact@v3
with:
name: ntgcalls.${{ matrix.shared_name }}-shared_libs
path: ./shared-output/*
if-no-files-found: error
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS: ${{ matrix.cibw_archs }}
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8"
CIBW_BUILD: cp3*-${{ matrix.cibw_os_build }}*
CIBW_SKIP: cp36-* cp37-*
CIBW_BUILD_VERBOSITY: 3
CIBW_TEST_SKIP: "*-macosx_arm64"
CIBW_TEST_COMMAND: python -c "from ntgcalls import NTgCalls; NTgCalls().ping()"
- uses: actions/upload-artifact@v3
with:
name: ntgcalls-${{ matrix.shared_name }}-wheels
path: ./wheelhouse/*.whl
if-no-files-found: error
publish:
runs-on: ubuntu-latest
needs: [build]
permissions:
id-token: write
contents: write
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
submodules: recursive
- name: Get library Version
id: get-library-version
run: |
VERSION=$(grep -oP -m 1 'ntgcalls VERSION \K[A-Za-z0-9.]+' CMakeLists.txt)
echo "Library Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Patch version number
id: patch-version
run: |
version="${{ steps.get-library-version.outputs.version }}"
if [[ "$version" == *.*.* ]]; then
echo "Version contains three dots"
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
patch=$(echo "$version" | cut -d. -f3)
tweak=$(echo "$version" | cut -d. -f4)
new_version="${major}.${minor}.${patch}.dev${tweak}"
echo $new_version
echo "new_version=$new_version" >> $GITHUB_OUTPUT
echo "is_dev=true" >> $GITHUB_OUTPUT
else
echo "Version does not contain three dots"
echo "new_version=${{ steps.get-library-version.outputs.version }}" >> $GITHUB_OUTPUT
echo "is_dev=false" >> $GITHUB_OUTPUT
fi
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: tmp/
- name: Prepare source distribution
run: |
python3 -m pip install --upgrade setuptools
python3 setup.py sdist
- name: Zip releases
run: |
mkdir releases
for dir in tmp/*shared_libs; do
if [ -d "$dir" ]; then
echo "$dir"
folder_name=$(basename "$dir" .zip)
(cd $dir && zip -r "../../releases/${folder_name}.zip" *)
fi
done
- name: Create Release
id: create-new-release
uses: softprops/action-gh-release@v1
with:
files: |
./releases/*
tag_name: "v${{ steps.patch-version.outputs.new_version }}"
name: "NTgCalls auto build v${{ steps.patch-version.outputs.new_version }}"
body: "These are the build files for the commit [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }}).\nThese files were built during [this workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})."
prerelease: ${{ steps.patch-version.outputs.is_dev }}
- name: Extract artifacts
run: find tmp -type f -name "*.whl" | xargs -I {} mv {} dist
- name: Publish a Python distribution to PyPI.
if: github.ref == 'refs/heads/master' && github.repository == 'pytgcalls/ntgcalls'
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
packages-dir: dist/