From c620fb240a88deefb74078b62ff2a3661665aba8 Mon Sep 17 00:00:00 2001 From: SergeySeroshtan Date: Sat, 27 Apr 2024 15:29:14 -0400 Subject: [PATCH] Add build of PHP binaries to Github actions --- .github/workflows/build-linux-php.yml | 53 ++++++++++++++++++ .github/workflows/build-macos-php.yml | 64 ++++++++++++++++++++++ .github/workflows/build-windows-php.yml | 73 +++++++++++++++++++++++++ 3 files changed, 190 insertions(+) create mode 100644 .github/workflows/build-linux-php.yml create mode 100644 .github/workflows/build-macos-php.yml create mode 100644 .github/workflows/build-windows-php.yml diff --git a/.github/workflows/build-linux-php.yml b/.github/workflows/build-linux-php.yml new file mode 100644 index 000000000..69e298450 --- /dev/null +++ b/.github/workflows/build-linux-php.yml @@ -0,0 +1,53 @@ +name: build-linux-php +on: + push: + branches: + - "**" + tags: + - "*" +jobs: + build-linux-php: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + php-version: ["8.3", "8.4"] + arch: [x86_64] + name: PHP ${{ matrix.php-version }} build on ${{ matrix.os }} for arch ${{ matrix.arch }} + steps: + - name: Install PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + - name: Check PHP Version + run: php -v + - uses: actions/checkout@v4 + - name: Configure toolchain + run: | + cmake --version + python3 --version + pip3 list --outdated + pip3 install -U protobuf grpcio-tools + - name: Configure project + run: > + cmake -Cconfigs/php-config.cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DVIRGIL_PACKAGE_PLATFORM_ARCH=${{ matrix.arch }} \ + -DVIRGIL_PACKAGE_LANGUAGE_VERSION=${{ matrix.php-version }} \ + -DCPACK_OUTPUT_FILE_PREFIX=php \ + -DENABLE_CLANGFORMAT=OFF \ + -DED25519_REF10=OFF -DED25519_AMD64_RADIX_64_24K=ON \ + -Bbuild -S. + - name: Build project + run: cmake --build build -- -j$(nproc) + - name: Test project + working-directory: build + run: ctest --verbose + - name: Package project + working-directory: build + run: cpack + - name: Attach artifacts to the release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: build/php/*.tar.gz diff --git a/.github/workflows/build-macos-php.yml b/.github/workflows/build-macos-php.yml new file mode 100644 index 000000000..93bbeed4e --- /dev/null +++ b/.github/workflows/build-macos-php.yml @@ -0,0 +1,64 @@ +name: build-macos-php +on: + push: + branches: + - "main" + - "develop" + - "release/**" + - "hotfix/**" + tags: + - "*" +jobs: + build-macos-php: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-13] + php-version: ["8.3", "8.4"] + arch: [x86_64, arm64] + include: + - arch: x86_64 + optimizations: -DED25519_REF10=OFF -DED25519_AMD64_RADIX_64_24K=ON + should_test: true + - arch: arm64 + optimizations: -DED25519_REF10=ON + should_test: false + name: PHP ${{ matrix.php-version }} build on ${{ matrix.os }} for arch ${{ matrix.arch }} + steps: + - name: Install PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + - name: Check PHP Version + run: php -v + - uses: actions/checkout@v4 + - name: Configure toolchain + run: | + cmake --version + python3 --version + pip3 install protobuf grpcio-tools + - name: Configure project + run: > + cmake -Cconfigs/php-config.cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \ + -DVIRGIL_PACKAGE_PLATFORM_ARCH=${{ matrix.arch }} \ + -DVIRGIL_PACKAGE_LANGUAGE_VERSION=${{ matrix.php-version }} \ + -DCPACK_OUTPUT_FILE_PREFIX=php \ + -DENABLE_CLANGFORMAT=OFF \ + ${{ matrix.optimizations }} \ + -Bbuild -S. + - name: Build project + run: cmake --build build -- -j$(sysctl -n hw.physicalcpu) + - name: Test project + if: ${{ matrix.should_test }} + working-directory: build + run: ctest --verbose + - name: Package project + working-directory: build + run: cpack + - name: Attach artifacts to the release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: build/php/*.tar.gz diff --git a/.github/workflows/build-windows-php.yml b/.github/workflows/build-windows-php.yml new file mode 100644 index 000000000..a596b4c3b --- /dev/null +++ b/.github/workflows/build-windows-php.yml @@ -0,0 +1,73 @@ +name: build-windows-php +on: + push: + branches: + - "**" + tags: + - "*" +jobs: + build-windows-php: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest] + php-version: ["8.3"] + arch: [x86_64] + include: + - arch: x86_64 + arch-short: x64 + name: PHP ${{ matrix.php-version }} build on ${{ matrix.os }} for arch ${{ matrix.arch }} + steps: + - name: Configure toolchain + run: | + cmake --version + python3 --version + pip3 install protobuf grpcio-tools + - name: Install MSVC Dev Cmd + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.arch }} + - name: Install PHP ${{ matrix.php-version }} + id: setup-php + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + env: + phpts: ts + - name: Check PHP Version + run: php -v + - name: Download PHP development pack + run: | + $php_devel_url = "https://windows.php.net/downloads/releases/php-devel-pack-${{ steps.setup-php.outputs.php-version }}-Win32-vs16-${{ matrix.arch-short }}.zip" + $php_devel_zip = "php-devel.zip" + Invoke-WebRequest -Uri $php_devel_url -OutFile $php_devel_zip + Expand-Archive -Path $php_devel_zip -DestinationPath "c:\\tools" + Remove-Item -Path $php_devel_zip + - name: Checkout project + uses: actions/checkout@v4 + - name: Configure project + run: > + cmake -G"NMake Makefiles" + -C"configs\\php-config.cmake" + -DPHP_DEVEL_HOME="C:\\tools\\php-${{ steps.setup-php.outputs.php-version }}-devel-vs16-${{ matrix.arch-short }}" + -DVIRGIL_LIB_PYTHIA=OFF + -DCMAKE_BUILD_TYPE=Release + -DVIRGIL_PACKAGE_PLATFORM_ARCH="${{ matrix.arch }}" + -DVIRGIL_PACKAGE_LANGUAGE_VERSION="${{ matrix.php-version }}" + -DCPACK_OUTPUT_FILE_PREFIX=php + -DENABLE_CLANGFORMAT=OFF + -Bbuild -S. + - name: Build project + run: cmake --build build --parallel $NUMBER_OF_PROCESSORS + - name: Test project + if: False + working-directory: build + run: ctest --verbose + - name: Package project + working-directory: build + run: cpack + - name: Attach artifacts to the release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: build/php/*.zip