From f648d585beb6f2853977e4bd7864500ed022f195 Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Tue, 4 Mar 2025 01:33:00 +0200 Subject: [PATCH 1/3] build(static-lib): on-demand PuNub library build Add GitHub workflow to build and add new PubNub static library versions. --- .github/workflows/build-c-static-library.yml | 360 +++++++++++++++++++ 1 file changed, 360 insertions(+) create mode 100644 .github/workflows/build-c-static-library.yml diff --git a/.github/workflows/build-c-static-library.yml b/.github/workflows/build-c-static-library.yml new file mode 100644 index 0000000..65a2fad --- /dev/null +++ b/.github/workflows/build-c-static-library.yml @@ -0,0 +1,360 @@ +name: Build C-Core SDK static library + +on: + workflow_dispatch: + inputs: + cBranch: + description: "C-Core SDK repository branch" + required: true + default: "master" + type: string + ueBranch: + description: "Unreal Engine SDK target branch" + required: true + default: "master" + type: string + ueVersion: + description: "Unreal Engine SDK version" + required: true + type: string + cBuildType: + description: "Build type" + required: true + default: "Release" + type: choice + options: + - Release + - Debug + cVerboseBuild: + description: "Verbose build" + required: true + default: false + type: boolean + featureUseProxy: + description: "[Feature] Proxy" + required: true + default: true + type: boolean + featureUseCompression: + description: "[Feature] gzip compression" + required: true + default: true + type: boolean + featureUseDecompression: + description: "[Feature] gzip decompression" + required: true + default: true + type: boolean + featureUseRetryConfiguration: + description: "[Feature] Request retry" + required: true + default: false + type: boolean + featureUseSubscribeV2: + description: "[Feature] Subscribe v2" + required: true + default: true + type: boolean + featureUseSubscribeEE: + description: "[Feature] Subscribe event engine" + required: true + default: false + type: boolean + featureUseAdvancedHistory: + description: "[Feature] Advanced history" + required: true + default: true + type: boolean + featureUseAppContext: + description: "[Feature] App Context" + required: true + default: true + type: boolean + featureUseAutoHeartbeat: + description: "[Feature] Auto heartbeat" + required: true + default: true + type: boolean + featureUseMessageReactions: + description: "[Feature] Message reactions" + required: true + default: true + type: boolean + featureUseRevokeToken: + description: "[Feature] Revoke Token" + required: true + default: false + type: boolean + featureUseGrantToken: + description: "[Feature] Grant Token" + required: true + default: false + type: boolean + featureUseFetchHistory: + description: "[Feature] Fetch History" + required: true + default: true + type: boolean + featureUseCrypto: + description: "[Feature] Crypto Module" + required: true + default: false + type: boolean + featureUseCallback: + description: "[Feature] Callback interface" + required: true + default: false + type: boolean + featureUseIPv6: + description: "[Feature] IPv6" + required: true + default: true + type: boolean + featureUseCustomDNS: + description: "[Feature] Custom DNS" + required: true + default: false + type: boolean + featureUseExternAPI: + description: "[Feature] Externs" + required: true + default: true + type: boolean + featureUseLegacyRandomIV: + description: "[Feature] Legacy Crypto random IV" + required: true + default: true + type: boolean + featureUseLogCallback: + description: "[Feature] Custom log callback" + required: true + default: true + type: boolean + customLogLevel: + description: "Custom log level" + required: true + default: "WARNING" + type: choice + options: + - TRACE + - DEBUG + - INFO + - WARNING + - ERROR + +jobs: + build: + name: Building ${{ matrix.preset }} + strategy: + matrix: + include: + # - os: windows + # runner-group: organization/windows-gh + # preset: windows-release + # build-path: c-core-sdk/windows-build + # filename: pubnub.lib + # - os: ubuntu + # runner-group: organization/Default + # preset: linux-release + # build-path: c-core-sdk/linux-build + # filename: libpubnub.a + - os: macos + runner-group: organization/macos-gh + preset: macos-release + build-path: c-core-sdk/macos-build + filename: libpubnub.a + # - os: macos + # runner-group: organization/macos-gh + # preset: macos-android-release + # build-path: c-core-sdk/android-build + # filename: libpubnub.a + # android_ndk: $ANDROID_NDK_HOME + # android_abi: arm64-v8a + # android_platform: android-21 + # toolchain: $ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake + runs-on: + group: ${{ matrix.runner-group }} + steps: + - name: Checkout Unreal Engine SDK + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ueBranch }} + token: ${{ secrets.GH_TOKEN }} + path: ue-sdk + - name: Checkout OpenSSL lib + uses: actions/checkout@v4 + with: + repository: pubnub/c-core + ref: static-openssl-lib + token: ${{ secrets.GH_TOKEN }} + path: openssl + - name: Checkout C-Core SDK + uses: actions/checkout@v4 + with: + repository: pubnub/c-core + ref: ${{ inputs.cBranch }} + token: ${{ secrets.GH_TOKEN }} + path: c-core-sdk + - name: Generate CMakePresets.json + run: | + COMMON_CACHE_VARIABLES=$(cat <<-EOF + "CMAKE_BUILD_TYPE": "${{ github.event.inputs.cBuildType }}", + "SHARED_LIB": "OFF", + "OPENSSL": "ON", + "USE_REVOKE_TOKEN_API": "ON", + "USE_GRANT_TOKEN_API": "ON", + "USE_CRYPTO_API": "ON", + "USE_PROXY": "${{ github.event.inputs.featureUseProxy == 'true' && 'ON' || 'OFF' }}", + "USE_GZIP_COMPRESSION": "${{ github.event.inputs.featureUseCompression == 'true' && 'ON' || 'OFF' }}", + "RECEIVE_GZIP_RESPONSE": "${{ github.event.inputs.featureUseDecompression == 'true' && 'ON' || 'OFF' }}", + "USE_RETRY_CONFIGURATION": "${{ github.event.inputs.featureUseRetryConfiguration == 'true' && 'ON' || 'OFF' }}", + "USE_SUBSCRIBE_V2": "${{ github.event.inputs.featureUseSubscribeV2 == 'true' && 'ON' || 'OFF' }}", + "USE_SUBSCRIBE_EVENT_ENGINE": "${{ github.event.inputs.featureUseSubscribeEE == 'true' && 'ON' || 'OFF' }}", + "USE_ADVANCED_HISTORY": "${{ github.event.inputs.featureUseAdvancedHistory == 'true' && 'ON' || 'OFF' }}", + "USE_OBJECTS_API": "${{ github.event.inputs.featureUseAppContext == 'true' && 'ON' || 'OFF' }}", + "USE_AUTO_HEARTBEAT": "${{ github.event.inputs.featureUseAutoHeartbeat == 'true' && 'ON' || 'OFF' }}", + "USE_ACTIONS_API": "${{ github.event.inputs.featureUseMessageReactions == 'true' && 'ON' || 'OFF' }}", + "USE_FETCH_HISTORY": "${{ github.event.inputs.featureUseFetchHistory == 'true' && 'ON' || 'OFF' }}", + "USE_CALLBACK_API": "${{ github.event.inputs.featureUseCallback == 'true' && 'ON' || 'OFF' }}", + "USE_IPV6": "${{ github.event.inputs.featureUseIPv6 == 'true' && 'ON' || 'OFF' }}", + "USE_SET_DNS_SERVERS": "${{ github.event.inputs.featureUseCustomDNS == 'true' && 'ON' || 'OFF' }}", + "USE_EXTERN_API": "${{ github.event.inputs.featureUseExternAPI == 'true' && 'ON' || 'OFF' }}", + "USE_LEGACY_CRYPTO_RANDOM_IV": "${{ github.event.inputs.featureUseLegacyRandomIV == 'true' && 'ON' || 'OFF' }}", + "USE_LOG_CALLBACK": "${{ github.event.inputs.featureUseLogCallback == 'true' && 'ON' || 'OFF' }}", + "SDK_VERSION_SUFFIX": "\\\\\"/Unreal/${{ github.event.inputs.ueVersion }}\\\\\"", + "LOG_LEVEL": "${{ github.event.inputs.customLogLevel }}" + EOF + + ) + + cat > "${{ github.workspace }}/c-core-sdk/CMakePresets.json" <<-EOF + { + "version": 3, + "configurePresets": [ + { + "name": "windows-release", + "description": "Release build for Windows with OpenSSL", + "generator": "Ninja", + "binaryDir": "${{ github.workspace }}/${{ matrix.build-path }}", + "cacheVariables": { + ${COMMON_CACHE_VARIABLES}, + "CMAKE_C_FLAGS": "-fdebug-prefix-map=\"$(pwd)/c-core-sdk\"=. -ffile-prefix-map=\"$(pwd)/c-core-sdk\"=.", + "CMAKE_CXX_FLAGS": "-fdebug-prefix-map=\"$(pwd)/c-core-sdk\"=. -ffile-prefix-map=\"$(pwd)/c-core-sdk\"=.", + "OPENSSL_ROOT_DIR": "${{ github.workspace }}/openssl/windows", + "CUSTOM_OPENSSL_LIB_DIR": "${{ github.workspace }}/openssl/windows/lib", + "CUSTOM_OPENSSL_INCLUDE_DIR": "${{ github.workspace }}/openssl/windows/include" + } + }, + { + "name": "linux-release", + "description": "Release build for linux with Universal Binary", + "generator": "Ninja", + "binaryDir": "${{ github.workspace }}/${{ matrix.build-path }}", + "cacheVariables": { + ${COMMON_CACHE_VARIABLES}, + "CMAKE_C_FLAGS": "-fdebug-prefix-map=\"$(pwd)/c-core-sdk\"=. -ffile-prefix-map=\"$(pwd)/c-core-sdk\"=. -fPIC", + "CMAKE_CXX_FLAGS": "-fdebug-prefix-map=\"$(pwd)/c-core-sdk\"=. -ffile-prefix-map=\"$(pwd)/c-core-sdk\"=. -fPIC", + "CMAKE_OSX_ARCHITECTURES": "x86_64" + } + }, + { + "name": "macos-release", + "description": "Release build for macOS with Universal Binary", + "generator": "Ninja", + "binaryDir": "${{ github.workspace }}/${{ matrix.build-path }}", + "cacheVariables": { + ${COMMON_CACHE_VARIABLES}, + "CMAKE_C_FLAGS": "-fdebug-prefix-map=\"$(pwd)/c-core-sdk\"=. -ffile-prefix-map=\"$(pwd)/c-core-sdk\"=. -fPIC", + "CMAKE_CXX_FLAGS": "-fdebug-prefix-map=\"$(pwd)/c-core-sdk\"=. -ffile-prefix-map=\"$(pwd)/c-core-sdk\"=. -fPIC", + "CMAKE_OSX_ARCHITECTURES": "x86_64;arm64" + } + }, + { + "name": "android-release", + "description": "Cross-compiled build for Android", + "generator": "Ninja", + "binaryDir": "${{ github.workspace }}/${{ matrix.build-path }}", + "cacheVariables": { + ${COMMON_CACHE_VARIABLES}, + "CMAKE_C_FLAGS": "-fdebug-prefix-map=\"$(pwd)/c-core-sdk\"=. -ffile-prefix-map=\"$(pwd)/c-core-sdk\"=.", + "CMAKE_CXX_FLAGS": "-fdebug-prefix-map=\"$(pwd)/c-core-sdk\"=. -ffile-prefix-map=\"$(pwd)/c-core-sdk\"=.", + "OPENSSL_ROOT_DIR": "${{ github.workspace }}/openssl/android", + "CUSTOM_OPENSSL_LIB_DIR": "${{ github.workspace }}/openssl/android/lib", + "CUSTOM_OPENSSL_INCLUDE_DIR": "${{ github.workspace }}/openssl/android/include", + "CMAKE_TOOLCHAIN_FILE": "$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake", + "ANDROID_ABI": "arm64-v8a", + "ANDROID_PLATFORM": "android-21" + } + } + ] + } + + EOF + + - name: Configure Cmake + run: cmake --fresh -S"${{ github.workspace }}"/c-core-sdk --preset=${{ matrix.preset }} + - name: Build library + run: cmake --build ${{ github.workspace }}/${{ matrix.build-path }} ${{ github.event.inputs.cVerboseBuild == 'true' && '--verbose' || '' }} + - name: Upload static library + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.preset }} + path: ${{ github.workspace }}/${{ matrix.build-path }}/${{ matrix.filename }} + retention-days: 1 + store: + name: Store built libraries + runs-on: + group: organization/Default + steps: + - name: Checkout Unreal Engine SDK + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ueBranch }} + token: ${{ secrets.GH_TOKEN }} + path: ue-sdk + - name: Checkout C-Core SDK + uses: actions/checkout@v4 + with: + repository: pubnub/c-core + ref: ${{ inputs.cBranch }} + token: ${{ secrets.GH_TOKEN }} + path: c-core-sdk + # - name: Download Windows library + # uses: actions/download-artifact@v4 + # with: + # # This is `preset` name from the build matrix. + # name: windows-release + # path: ${{ github.workspace }}/ue-sdk/Source/ThirdParty/sdk/lib/win64 + - name: Download macOS library + uses: actions/download-artifact@v4 + with: + # This is `preset` name from the build matrix. + name: macos-release + path: ${{ github.workspace }}/ue-sdk/Source/ThirdParty/sdk/lib/MacOS + # - name: Download Linux library + # uses: actions/download-artifact@v4 + # with: + # # This is `preset` name from the build matrix. + # name: linux-release + # path: ${{ github.workspace }}/ue-sdk/Source/ThirdParty/sdk/lib/ + # - name: Download Android library + # uses: actions/download-artifact@v4 + # with: + # # This is `preset` name from the build matrix. + # name: macos-android-release + # path: ${{ github.workspace }}/ue-sdk/Source/ThirdParty/sdk/lib/ + - name: Copy headers + run: | + # Clear previous headers. + rm -rf ${{ github.workspace }}/ue-sdk/Source/ThirdParty/sdk/Include + mkdir -p ${{ github.workspace }}/ue-sdk/Source/ThirdParty/sdk/Include + + cd ${{ github.workspace }}/c-core-sdk + find . \( -name '*.h' -o -name '*.hpp' \) | cpio -pdm ${{ github.workspace }}/ue-sdk/Source/ThirdParty/sdk/Include + - name: Commit changes + run: | + cd ${{ github.workspace }}/ue-sdk + + git add . + git commit -m "build(library): add new PubNub static library" + git push origin From 4a18a8d802c834b6cb3c4ea7374f01f24942082f Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Tue, 4 Mar 2025 01:42:16 +0200 Subject: [PATCH 2/3] build(workflow): reduce number of inputs --- .github/workflows/build-c-static-library.yml | 131 +++---------------- 1 file changed, 16 insertions(+), 115 deletions(-) diff --git a/.github/workflows/build-c-static-library.yml b/.github/workflows/build-c-static-library.yml index 65a2fad..97ac54c 100644 --- a/.github/workflows/build-c-static-library.yml +++ b/.github/workflows/build-c-static-library.yml @@ -17,114 +17,16 @@ on: description: "Unreal Engine SDK version" required: true type: string - cBuildType: - description: "Build type" - required: true - default: "Release" - type: choice - options: - - Release - - Debug cVerboseBuild: description: "Verbose build" required: true default: false type: boolean - featureUseProxy: - description: "[Feature] Proxy" - required: true - default: true - type: boolean - featureUseCompression: - description: "[Feature] gzip compression" - required: true - default: true - type: boolean - featureUseDecompression: - description: "[Feature] gzip decompression" - required: true - default: true - type: boolean - featureUseRetryConfiguration: - description: "[Feature] Request retry" - required: true - default: false - type: boolean - featureUseSubscribeV2: - description: "[Feature] Subscribe v2" - required: true - default: true - type: boolean - featureUseSubscribeEE: - description: "[Feature] Subscribe event engine" - required: true - default: false - type: boolean - featureUseAdvancedHistory: - description: "[Feature] Advanced history" - required: true - default: true - type: boolean - featureUseAppContext: - description: "[Feature] App Context" - required: true - default: true - type: boolean - featureUseAutoHeartbeat: - description: "[Feature] Auto heartbeat" - required: true - default: true - type: boolean - featureUseMessageReactions: - description: "[Feature] Message reactions" - required: true - default: true - type: boolean - featureUseRevokeToken: - description: "[Feature] Revoke Token" - required: true - default: false - type: boolean - featureUseGrantToken: - description: "[Feature] Grant Token" - required: true - default: false - type: boolean - featureUseFetchHistory: - description: "[Feature] Fetch History" - required: true - default: true - type: boolean - featureUseCrypto: - description: "[Feature] Crypto Module" - required: true - default: false - type: boolean - featureUseCallback: - description: "[Feature] Callback interface" - required: true - default: false - type: boolean - featureUseIPv6: - description: "[Feature] IPv6" - required: true - default: true - type: boolean - featureUseCustomDNS: - description: "[Feature] Custom DNS" - required: true - default: false - type: boolean featureUseExternAPI: description: "[Feature] Externs" required: true default: true type: boolean - featureUseLegacyRandomIV: - description: "[Feature] Legacy Crypto random IV" - required: true - default: true - type: boolean featureUseLogCallback: description: "[Feature] Custom log callback" required: true @@ -198,28 +100,28 @@ jobs: - name: Generate CMakePresets.json run: | COMMON_CACHE_VARIABLES=$(cat <<-EOF - "CMAKE_BUILD_TYPE": "${{ github.event.inputs.cBuildType }}", + "CMAKE_BUILD_TYPE": "Release", "SHARED_LIB": "OFF", "OPENSSL": "ON", "USE_REVOKE_TOKEN_API": "ON", "USE_GRANT_TOKEN_API": "ON", "USE_CRYPTO_API": "ON", - "USE_PROXY": "${{ github.event.inputs.featureUseProxy == 'true' && 'ON' || 'OFF' }}", - "USE_GZIP_COMPRESSION": "${{ github.event.inputs.featureUseCompression == 'true' && 'ON' || 'OFF' }}", - "RECEIVE_GZIP_RESPONSE": "${{ github.event.inputs.featureUseDecompression == 'true' && 'ON' || 'OFF' }}", - "USE_RETRY_CONFIGURATION": "${{ github.event.inputs.featureUseRetryConfiguration == 'true' && 'ON' || 'OFF' }}", - "USE_SUBSCRIBE_V2": "${{ github.event.inputs.featureUseSubscribeV2 == 'true' && 'ON' || 'OFF' }}", - "USE_SUBSCRIBE_EVENT_ENGINE": "${{ github.event.inputs.featureUseSubscribeEE == 'true' && 'ON' || 'OFF' }}", - "USE_ADVANCED_HISTORY": "${{ github.event.inputs.featureUseAdvancedHistory == 'true' && 'ON' || 'OFF' }}", - "USE_OBJECTS_API": "${{ github.event.inputs.featureUseAppContext == 'true' && 'ON' || 'OFF' }}", - "USE_AUTO_HEARTBEAT": "${{ github.event.inputs.featureUseAutoHeartbeat == 'true' && 'ON' || 'OFF' }}", - "USE_ACTIONS_API": "${{ github.event.inputs.featureUseMessageReactions == 'true' && 'ON' || 'OFF' }}", - "USE_FETCH_HISTORY": "${{ github.event.inputs.featureUseFetchHistory == 'true' && 'ON' || 'OFF' }}", - "USE_CALLBACK_API": "${{ github.event.inputs.featureUseCallback == 'true' && 'ON' || 'OFF' }}", - "USE_IPV6": "${{ github.event.inputs.featureUseIPv6 == 'true' && 'ON' || 'OFF' }}", - "USE_SET_DNS_SERVERS": "${{ github.event.inputs.featureUseCustomDNS == 'true' && 'ON' || 'OFF' }}", + "USE_PROXY": "ON", + "USE_GZIP_COMPRESSION": "ON", + "RECEIVE_GZIP_RESPONSE": "ON", + "USE_RETRY_CONFIGURATION": "OFF", + "USE_SUBSCRIBE_V2": "ON", + "USE_SUBSCRIBE_EVENT_ENGINE": "OFF", + "USE_ADVANCED_HISTORY": "ON", + "USE_OBJECTS_API": "ON", + "USE_AUTO_HEARTBEAT": "ON", + "USE_ACTIONS_API": "ON", + "USE_FETCH_HISTORY": "ON", + "USE_CALLBACK_API": "OFF", + "USE_IPV6": "ON", + "USE_SET_DNS_SERVERS": "OFF", "USE_EXTERN_API": "${{ github.event.inputs.featureUseExternAPI == 'true' && 'ON' || 'OFF' }}", - "USE_LEGACY_CRYPTO_RANDOM_IV": "${{ github.event.inputs.featureUseLegacyRandomIV == 'true' && 'ON' || 'OFF' }}", + "USE_LEGACY_CRYPTO_RANDOM_IV": "ON", "USE_LOG_CALLBACK": "${{ github.event.inputs.featureUseLogCallback == 'true' && 'ON' || 'OFF' }}", "SDK_VERSION_SUFFIX": "\\\\\"/Unreal/${{ github.event.inputs.ueVersion }}\\\\\"", "LOG_LEVEL": "${{ github.event.inputs.customLogLevel }}" @@ -357,4 +259,3 @@ jobs: git add . git commit -m "build(library): add new PubNub static library" - git push origin From 90c988793663846c2e70ec7069c7c39be42e339c Mon Sep 17 00:00:00 2001 From: Serhii Mamontov Date: Tue, 4 Mar 2025 01:44:10 +0200 Subject: [PATCH 3/3] chore: rename workflow --- .github/workflows/build-c-static-library.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-c-static-library.yml b/.github/workflows/build-c-static-library.yml index 97ac54c..db76c31 100644 --- a/.github/workflows/build-c-static-library.yml +++ b/.github/workflows/build-c-static-library.yml @@ -1,4 +1,4 @@ -name: Build C-Core SDK static library +name: Build static library on: workflow_dispatch: