-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from onerain88/feat/npm-release
支持 NPMJS 发布
- Loading branch information
Showing
6 changed files
with
194 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
# 发布 npm | ||
# sh ./script/deploy_npm.sh registry.npmjs.org {authToken} ./Assets/TapTap/Common | ||
# sh ./script/deploy_npm.sh nexus.tapsvc.com/repository/npm-registry {authToken} ./Assets/TapTap/Common | ||
|
||
# 接收参数 | ||
|
||
echo $1 | ||
echo $2 | ||
echo $3 | ||
|
||
# 仓库 | ||
registry=$1 | ||
|
||
# 认证方式 | ||
authToken=$2 | ||
|
||
# 模块目录 | ||
modulePath=$3 | ||
|
||
echo "Package: $modulePath" | ||
|
||
cd $modulePath | ||
|
||
echo email=bot@xd.com > .npmrc | ||
echo registry=https://$registry/ >> .npmrc | ||
echo //$registry/:always-auth=true >> .npmrc | ||
echo //$registry/:_authToken=$authToken >> .npmrc | ||
|
||
# 发布 | ||
npm publish --access public | ||
|
||
rm -rf .npmrc | ||
|
||
cd - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
# 发布 upm | ||
|
||
REPO_GIT_URL="git@github.com:leancloud/csharp-sdk-upm.git" | ||
|
||
upmPath=$1 | ||
tagPrefix=$2 | ||
version=$3 | ||
|
||
# push 到 GitHub | ||
upmTag=$tagPrefix-$version | ||
|
||
cd $upmPath | ||
|
||
git init | ||
git config user.name "leancloud-bot"; | ||
git config user.email "ci@leancloud.cn"; | ||
git add . | ||
git commit -m $version .; | ||
git tag $upmTag | ||
# git push origin $version | ||
git push -f $REPO_GIT_URL $upmTag | ||
|
||
cd - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#!/bin/sh | ||
VERSION_REGEX="^([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$" | ||
|
||
UNITY_PATH="/Applications/Unity/Hub/Editor/2020.3.36f1c1/Unity.app/Contents/MacOS/Unity" | ||
|
||
|
||
# 从 Releases 下载 | ||
download() { | ||
releaseURL=$1 | ||
upmPath=$2 | ||
# Plugins | ||
zipFile=`basename "$releaseURL"` | ||
curl -L $releaseURL -o $zipFile | ||
unzip $zipFile -d $upmPath | ||
rm $zipFile | ||
} | ||
|
||
# 去掉依赖中的重复文件 | ||
diff() { | ||
srcPath=$1 | ||
dstPath=$2 | ||
for df in `ls $dstPath`: | ||
do | ||
for sf in `ls $srcPath`: | ||
do | ||
if cmp -s $dstPath/$df $srcPath/$sf | ||
then | ||
rm $dstPath/$df | ||
break | ||
fi | ||
done | ||
done | ||
} | ||
|
||
# 生成 package.json | ||
package() { | ||
packageJson=$1 | ||
upmPath=$2 | ||
|
||
cat $packageJson | sed 's/__VERSION__/'$version'/' > $upmPath/package.json | ||
} | ||
|
||
# 生成 .meta | ||
generateMetas() { | ||
upmPath=$1 | ||
|
||
# 创建 Unity 工程 | ||
unityProject=./Unity/UnityProject | ||
$UNITY_PATH -batchmode -quit -createProject $unityProject | ||
|
||
# 将 UPM 包移动到 Unity Project 下 | ||
unityAssetsPath=$unityProject/Assets | ||
mv $upmPath/* $unityAssetsPath/ | ||
|
||
# 使用 Unity Editor 打开工程,生成 .meta 文件 | ||
$UNITY_PATH -batchmode -quit -nographics -silent-crashes -projectPath $unityProject | ||
|
||
mv $unityAssetsPath/* $upmPath/ | ||
|
||
# 移除临时 Unity 工程 | ||
rm -rf $unityProject | ||
} | ||
|
||
# 发布流程 | ||
|
||
version=$1 | ||
|
||
if [[ !($version =~ $VERSION_REGEX) ]]; then | ||
echo 'Invalid version' | ||
exit | ||
fi | ||
|
||
if !(test -f $UNITY_PATH); then | ||
echo 'Unity does NOT exist.' | ||
exit | ||
fi | ||
|
||
STORAGE_RELEASE_URL="https://github.com/leancloud/csharp-sdk/releases/download/$version/LeanCloud-SDK-Storage-Unity.zip" | ||
REALTIME_RELEASE_URL="https://github.com/leancloud/csharp-sdk/releases/download/$version/LeanCloud-SDK-Realtime-Unity.zip" | ||
PLAY_RELEASE_URL="https://github.com/leancloud/csharp-sdk/releases/download/$version/LeanCloud-SDK-Play-Unity.zip" | ||
|
||
upmStoragePath="upm-storage" | ||
upmRealtimePath="upm-realtime" | ||
upmPlayPath="upm-play" | ||
|
||
# 下载 | ||
download $STORAGE_RELEASE_URL $upmStoragePath | ||
download $REALTIME_RELEASE_URL $upmRealtimePath | ||
download $PLAY_RELEASE_URL $upmPlayPath | ||
|
||
# 去重 | ||
diff $upmRealtimePath/Plugins $upmPlayPath/Plugins | ||
diff $upmStoragePath/Plugins $upmRealtimePath/Plugins | ||
|
||
# 打包 | ||
package ./Unity/storage.package.json $upmStoragePath | ||
package ./Unity/realtime.package.json $upmRealtimePath | ||
package ./Unity/play.package.json $upmPlayPath | ||
|
||
# 生成 .meta | ||
generateMetas $upmStoragePath | ||
generateMetas $upmRealtimePath | ||
generateMetas $upmPlayPath | ||
|
||
# 发布 Github UPM | ||
storageTag="storage" | ||
realtimeTag="realtime" | ||
playTag="play" | ||
|
||
sh ./script/deploy-upm.sh $upmStoragePath $storageTag $version | ||
sh ./script/deploy-upm.sh $upmRealtimePath $realtimeTag $version | ||
sh ./script/deploy-upm.sh $upmPlayPath $playTag $version | ||
|
||
发布 NPMJS | ||
sh ./script/deploy-npm.sh $NPMJS_REGISTRY $NPMJS_TOKEN $upmStoragePath | ||
sh ./script/deploy-npm.sh $NPMJS_REGISTRY $NPMJS_TOKEN $upmRealtimePath | ||
sh ./script/deploy-npm.sh $NPMJS_REGISTRY $NPMJS_TOKEN $upmPlayPath | ||
|
||
# 发布 Tap NPM | ||
sh ./script/deploy-npm.sh $TAP_NPM_REGISTRY $TAP_NPM_TOKEN $upmStoragePath | ||
sh ./script/deploy-npm.sh $TAP_NPM_REGISTRY $TAP_NPM_TOKEN $upmRealtimePath | ||
sh ./script/deploy-npm.sh $TAP_NPM_REGISTRY $TAP_NPM_TOKEN $upmPlayPath | ||
|
||
# 移除 SDK 包 | ||
rm -rf $upmStoragePath | ||
rm -rf $upmRealtimePath | ||
rm -rf $upmPlayPath |