From 54b900cefe9db46bcc7969c8442028fbd3117c3b Mon Sep 17 00:00:00 2001 From: Tomas Jaros Date: Tue, 13 Aug 2024 15:26:27 +0200 Subject: [PATCH] feat: implement github actions workflow for wrapper build --- .github/workflows/build_wrapper.yaml | 150 +++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 .github/workflows/build_wrapper.yaml diff --git a/.github/workflows/build_wrapper.yaml b/.github/workflows/build_wrapper.yaml new file mode 100644 index 00000000..9b09d0ec --- /dev/null +++ b/.github/workflows/build_wrapper.yaml @@ -0,0 +1,150 @@ +name: Multiplatform build of libuuu wrapper python package +on: + push: + branches: [master] + +jobs: + build-dlls: + name: Build of dynamically linked libraries + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - name: Checkout uuu repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: false + + - name: Clone vcpkg repository + run: | + git clone https://github.com/microsoft/vcpkg.git + + - name: Set up vcpkg on Windows + working-directory: ./vcpkg + if: matrix.os == 'windows-latest' + run: | + echo ("VCPKG_ROOT=" + $PWD.Path) >> $env:GITHUB_ENV + ./bootstrap-vcpkg.bat + + - name: Set up vcpkg on Ubuntu and MacOS + working-directory: ./vcpkg + if: matrix.os != 'windows-latest' + run: | + echo "VCPKG_ROOT=$(pwd)" >> $GITHUB_ENV + ./bootstrap-vcpkg.sh + + - name: Install dependencies Ubuntu + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get install gcc cmake ninja-build autotools-dev automake autoconf libudev-dev + + - name: Install dependencies MacOS + if: matrix.os == 'macos-latest' + run: | + brew install ninja cmake autoconf automake libtool + + - name: Install dependencies Windows + if: matrix.os == 'windows-latest' + run: | + choco install cmake pkgconfiglite + + - name: Build on Ubuntu and MacOS + working-directory: ./wrapper + if: matrix.os != 'windows-latest' + run: | + export PATH=$VCPKG_ROOT:$PATH + cmake --preset=unix + cmake --build build + + - name: Build on Windows + working-directory: ./wrapper + if: matrix.os == 'windows-latest' + run: | + $env:Path = $env:VCPKG_ROOT + ';' + $env:Path + cmake --preset=windows + cmake --build build + + - name: Upload artifacts Windows + if: matrix.os == 'windows-latest' + uses: actions/upload-artifact@v4 + with: + name: libuuu-windows + path: ./wrapper/build/Debug/*.dll + + - name: Upload artifacts MacOS + if: matrix.os == 'macos-latest' + uses: actions/upload-artifact@v4 + with: + name: libuuu-macos + path: ./wrapper/build/libuuu.dylib + + - name: Upload artifacts Ubuntu + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + name: libuuu-ubuntu + path: ./wrapper/build/libuuu.so + + build-libuuu-wrapper: + runs-on: ubuntu-latest + needs: build-dlls + steps: + - name: Checkout uuu repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: false + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + pattern: libuuu-* + merge-multiple: true + path: ./wrapper/libuuu/lib/ + + - name: Check the path + run: | + find ./wrapper/ + + - name: Install python dependencies + working-directory: ./wrapper + run: | + pip install --upgrade pip + pip install --force-reinstall -U build twine nxp-codecheck colorama setuptools_scm + + - name: Build the python package + working-directory: ./wrapper + run: | + python -m build --sdist --wheel + + - name: Run codecheck + working-directory: ./wrapper + run: | + codecheck -s + + - name: Upload reports if codecheck fails + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: reports + path: ./wrapper/reports/* + + - name: Release package to pypi + if: github.ref_type == 'tag' + env: + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + #TWINE_REPOSITORY_URL: ${{ secrets.TWINE_REPOSITORY_URL }} + working-directory: ./wrapper + run: | + twine --no-color check dist/* + twine --no-color upload --repository pypi dist/* + + - name: Upload the dist folder + uses: actions/upload-artifact@v4 + with: + name: dist + path: ./wrapper/dist