diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 000000000..759c8b42b --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,23 @@ +name: Sync to shengwang + +on: + workflow_dispatch: + +jobs: + move-to-shengwang: + runs-on: ubuntu-latest + steps: + - name: Sync to shengwang + uses: AgoraIO-Extensions/actions/.github/actions/shengwang-sync@sync + with: + target-repo: 'Shengwang-Electron-SDK' + source-repo: 'Electron-SDK' + github-token: ${{ secrets.GH_TOKEN }} + target-branch: ${{ github.ref_name }} + github-email: ${{ secrets.GIT_EMAIL }} + github-private-key: ${{ secrets.GH_PRIVATE_KEY }} + github-username: ${{ secrets.GIT_USERNAME }} + pre-command: | + sh scripts/publishCN/rewrite-dep.sh + sh scripts/publishCN/rewrite-example.sh + create-pr: true diff --git a/CMakeLists.txt b/CMakeLists.txt index ccdafb507..e7e15b5e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ file(GLOB TARGET_AGORA_NODE_EXT_FILE if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") set(AGORA_IRIS_PROJECT_ARCH "MAC") set(AGORA_RTC_SDK_PATH - ${CMAKE_CURRENT_SOURCE_DIR}/native/Agora_Native_SDK_for_Mac_FULL/libs + ${CMAKE_CURRENT_SOURCE_DIR}/native/*_Native_SDK_for_Mac_FULL/libs ) # native rtc sdk library set(AGORA_RTC_SDK_LIBRARY @@ -101,7 +101,7 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") ${CMAKE_CURRENT_SOURCE_DIR}/native) file(GLOB AGORA_RTC_SDK_LIBRARY - ${AGORA_RTC_SDK_PATH}/Agora_Native_SDK_for_Windows_FULL/sdk/${AGORA_RTC_PROJECT_ARCH}/*.dll + ${AGORA_RTC_SDK_PATH}/*_Native_SDK_for_Windows_FULL/sdk/${AGORA_RTC_PROJECT_ARCH}/*.dll ) # iris sdk path diff --git a/scripts/downloadPrebuild.js b/scripts/downloadPrebuild.js index c680a619f..32ecca1a7 100644 --- a/scripts/downloadPrebuild.js +++ b/scripts/downloadPrebuild.js @@ -29,6 +29,8 @@ const getDownloadURL = () => { return downloadUrl; }; +// If native_stk_url is not defined in app/packaging.json, +// it will be read from agora-electron-sdk/packaging.json const getNativeDownloadURL = () => { let downloadUrl = ''; if (platform === 'win32') { @@ -36,6 +38,18 @@ const getNativeDownloadURL = () => { } else if (platform === 'darwin') { downloadUrl = native_sdk_mac; } + + if (!downloadUrl) { + const { + agora_electron: { native_sdk_win, native_sdk_mac }, + } = require('../package.json'); + if (platform === 'win32') { + downloadUrl = native_sdk_win; + } else if (platform === 'darwin') { + downloadUrl = native_sdk_mac; + } + } + return downloadUrl; }; diff --git a/scripts/publishCN/common.sh b/scripts/publishCN/common.sh new file mode 100644 index 000000000..0f8daf1bb --- /dev/null +++ b/scripts/publishCN/common.sh @@ -0,0 +1,19 @@ +# common.sh +#!/bin/bash + +old_package_name='agora-electron-sdk' +new_package_name='shengwang-electron-sdk' + +#./package.json +old_name="\"name\": \"agora-electron-sdk\"" +new_name="\"name\": \"shengwang-electron-sdk\"" + +old_description="\"description\": \"agora-electron-sdk\"" +new_description="\"description\": \"shengwang-electron-sdk\"" + +old_yarn_link="yarn example link agora-electron-sdk" +new_yarn_link="yarn example link shengwang-electron-sdk" + +# node_modules +old_node_modules="node_modules/agora-electron-sdk" +new_node_modules="node_modules/shengwang-electron-sdk" diff --git a/scripts/publishCN/rewrite-dep.sh b/scripts/publishCN/rewrite-dep.sh new file mode 100644 index 000000000..d868d8660 --- /dev/null +++ b/scripts/publishCN/rewrite-dep.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e +MY_PATH=$(realpath $(dirname "$0")) +PROJECT_ROOT=$(realpath ${MY_PATH}/../..) +. ${PROJECT_ROOT}/scripts/publishCN/common.sh + +change_file=${PROJECT_ROOT}/package.json +sed "s/${old_name}/${new_name}/g" ${change_file} >tmp && mv tmp ${change_file} +sed "s/${old_description}/${new_description}/g" ${change_file} >tmp && mv tmp ${change_file} +sed "s/${old_yarn_link}/${new_yarn_link}/g" ${change_file} >tmp && mv tmp ${change_file} + +change_file=${PROJECT_ROOT}/tsconfig.json +sed "s/${old_package_name}/${new_package_name}/g" ${change_file} >tmp && mv tmp ${change_file} + +change_file=${PROJECT_ROOT}/.github/workflows/publish.yml +sed "s/${old_package_name}/${new_package_name}/g" ${change_file} >tmp && mv tmp ${change_file} + +change_file=${PROJECT_ROOT}/ci/packager-mac.sh +sed "s#${old_node_modules}#${new_node_modules}#g" ${change_file} >tmp && mv tmp ${change_file} + +change_file=${PROJECT_ROOT}/ci/packager-win.ps1 +sed "s#${old_node_modules}#${new_node_modules}#g" ${change_file} >tmp && mv tmp ${change_file} diff --git a/scripts/publishCN/rewrite-example.sh b/scripts/publishCN/rewrite-example.sh new file mode 100644 index 000000000..8eb17c2c8 --- /dev/null +++ b/scripts/publishCN/rewrite-example.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e +MY_PATH=$(realpath $(dirname "$0")) +PROJECT_ROOT=$(realpath ${MY_PATH}/../..) +. ${PROJECT_ROOT}/scripts/publishCN/common.sh + +change_dir="${PROJECT_ROOT}/example/src" + +find "$change_dir" -type f | while read -r file; do + sed -i.bak "s/${old_package_name}/${new_package_name}/g" "$file" + echo "Replaced in $file" +done + +change_file=${PROJECT_ROOT}/example/package.json +sed "s/${old_package_name}/${new_package_name}/g" ${change_file} >tmp && mv tmp ${change_file} + +change_file=${PROJECT_ROOT}/example/webpack.renderer.additions.js +sed "s/${old_package_name}/${new_package_name}/g" ${change_file} >tmp && mv tmp ${change_file} + +find "$change_dir" -name "*.bak" -type f -delete + +echo "All replacements completed successfully, and backup files have been deleted." diff --git a/scripts/zipBuild.js b/scripts/zipBuild.js index ccf06a4b2..40030dac4 100644 --- a/scripts/zipBuild.js +++ b/scripts/zipBuild.js @@ -1,3 +1,4 @@ +const fs = require('fs'); const path = require('path'); const { exec } = require('shelljs'); @@ -5,7 +6,25 @@ const { exec } = require('shelljs'); const logger = require('./logger'); const { getOS } = require('./util'); +const keepList = ['AgoraRtcWrapper', 'agora_node_ext']; + +const filesMove = (src, dest, keepList) => { + fs.readdirSync(src).forEach((file) => { + const filePath = path.join(src, file); + const shouldKeep = keepList.some((pattern) => file.includes(pattern)); + if (!shouldKeep) { + const destPath = path.join(dest, file); + fs.renameSync(filePath, destPath); + } + }); +}; + const zipBuild = async () => { + const temp_native = path.join(__dirname, '..', 'build', 'temp_native'); + const build_release = path.join(__dirname, '..', 'build', 'Release'); + fs.mkdirSync(temp_native); + filesMove(build_release, temp_native, keepList); + const isMac = getOS() === 'mac'; const fileListStr = ` build${path.sep}Release js types package.json`; const shellStr = @@ -14,6 +33,8 @@ const zipBuild = async () => { if (code !== 0) { logger.error(stderr); } + filesMove(temp_native, build_release, []); + fs.rmdirSync(temp_native, { recursive: true }); }; module.exports = zipBuild;