Skip to content

Commit

Permalink
chore: publish for Atlas (#1252)
Browse files Browse the repository at this point in the history
* chore: do not package native sdk into napi.zip, download native sdk when npm install

* chore: sync.yml

* chore: code format

* chore: format

* chore: fix error name

---------

Co-authored-by: 夏羊群 <[email protected]>
  • Loading branch information
xiayangqun and 夏羊群 authored Dec 20, 2024
1 parent 9a24f58 commit 2d21800
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions scripts/downloadPrebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,27 @@ 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') {
downloadUrl = native_sdk_win;
} 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;
};

Expand Down
19 changes: 19 additions & 0 deletions scripts/publishCN/common.sh
Original file line number Diff line number Diff line change
@@ -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"
22 changes: 22 additions & 0 deletions scripts/publishCN/rewrite-dep.sh
Original file line number Diff line number Diff line change
@@ -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}
22 changes: 22 additions & 0 deletions scripts/publishCN/rewrite-example.sh
Original file line number Diff line number Diff line change
@@ -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."
21 changes: 21 additions & 0 deletions scripts/zipBuild.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
const fs = require('fs');
const path = require('path');

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 =
Expand All @@ -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;

0 comments on commit 2d21800

Please sign in to comment.