mirror of
https://github.com/msojocs/wechat-web-devtools-linux.git
synced 2025-07-07 00:02:14 +08:00
refactor: 优化构建流程
This commit is contained in:
parent
4744ec978d
commit
b2b7881e89
68
.github/workflows/release.yml
vendored
68
.github/workflows/release.yml
vendored
@ -9,7 +9,7 @@ on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
branches: [ master, reduce-wine]
|
||||
branches: [ master, actions-dev]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
# # Allows you to run this workflow manually from the Actions tab
|
||||
@ -39,8 +39,9 @@ jobs:
|
||||
pwd
|
||||
ls -l
|
||||
export ACTION_MODE=true
|
||||
npm uninstall node-gyp -g
|
||||
sudo apt-get install -y libx11-dev libxkbfile-dev p7zip-full python2 python3 libkrb5-dev gcc openssl libssh2-1-dev g++ make
|
||||
npm install node-gyp nw-gyp npm -g
|
||||
node-gyp install
|
||||
|
||||
- id: Tag
|
||||
run: |
|
||||
@ -55,65 +56,34 @@ jobs:
|
||||
echo "::set-output name=name::$name"
|
||||
|
||||
- name: Build
|
||||
run: docker-compose up
|
||||
|
||||
- name: Refactor Directory Structure
|
||||
run: |
|
||||
sudo chmod -R 777 package.nw node
|
||||
ls -l
|
||||
sudo rm -rf cache tmp .git test
|
||||
mkdir ${{ env. name }}
|
||||
sudo find -maxdepth 1 -not -name ${{ env.name }} -not -name . -exec mv {} ${{ env.name }} \;
|
||||
sudo cp -r "${{ env.name }}/package.nw/node_modules/nodegit" nodegit
|
||||
sudo cp -r "${{ env.name }}/compiler" compiler
|
||||
ls -l
|
||||
env:
|
||||
name: 'WeChat_Dev_Tools_${{ steps.tag.outputs.tag }}'
|
||||
# docker-compose up
|
||||
tools/setup-wechat-devtools-bash
|
||||
sudo chmod -R 755 package.nw
|
||||
bash tools/build-release.sh ${{ steps.tag.outputs.tag }} ${{ matrix.ARCH }}
|
||||
|
||||
- name: Compress
|
||||
- name: Compress nodegit compiler
|
||||
run: |
|
||||
ls -l
|
||||
tar -zvcf compiler.tar.gz compiler
|
||||
tar -zvcf nodegit.tar.gz nodegit
|
||||
sudo rm -rf compiler nodegit ${{ env.name }}/node_modules
|
||||
sudo cp -r package.nw/node_modules/nodegit tmp/build/nodegit
|
||||
sudo cp -r compiler tmp/build/compiler
|
||||
cd tmp/build
|
||||
ls -l
|
||||
tar -zcf compiler.tar.gz compiler
|
||||
tar -zcf nodegit.tar.gz nodegit
|
||||
sudo rm -rf compiler nodegit
|
||||
ls -l
|
||||
env:
|
||||
name: 'WeChat_Dev_Tools_${{ steps.tag.outputs.tag }}'
|
||||
|
||||
- name: Build AppImage && Pack
|
||||
- name: View Directory
|
||||
run: |
|
||||
bash ./${{ env.name }}/tools/appimage.sh
|
||||
wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
|
||||
chmod a+x appimagetool-x86_64.AppImage
|
||||
# build AppImage
|
||||
./appimagetool-x86_64.AppImage ./${{ env.name }}/tmp/AppDir ${{ env.name }}_${{ env.ARCH }}_wine.AppImage
|
||||
# pack
|
||||
sudo rm -rf compiler nodegit ${{ env.name }}/tmp
|
||||
tar -zvcf ${{ env.name }}_${{ env.ARCH }}_wine.tar.gz ${{ env.name }}
|
||||
|
||||
# reduce wine
|
||||
export NO_WINE=true
|
||||
bash ${{ env.name }}/tools/fix-core
|
||||
bash ${{ env.name }}/tools/fix-other
|
||||
bash ./${{ env.name }}/tools/appimage.sh
|
||||
# build AppImage
|
||||
./appimagetool-x86_64.AppImage ./${{ env.name }}/tmp/AppDir ${{ env.name }}_${{ env.ARCH }}_no_wine.AppImage
|
||||
sudo rm -rf compiler nodegit ${{ env.name }}/tmp
|
||||
# pack
|
||||
tar -zvcf ${{ env.name }}_${{ env.ARCH }}_no_wine.tar.gz ${{ env.name }}
|
||||
|
||||
sudo rm -rf appimagetool-x86_64.AppImage ${{ env.name }}
|
||||
ls -l
|
||||
env:
|
||||
name: 'WeChat_Dev_Tools_${{ steps.tag.outputs.tag }}'
|
||||
ARCH: '${{ matrix.ARCH }}'
|
||||
|
||||
|
||||
- name: Create release and upload artifacts
|
||||
if: startsWith(github.ref, 'refs/heads/')
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
cd tmp/build
|
||||
wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage
|
||||
chmod +x pyuploadtool-x86_64.AppImage
|
||||
./pyuploadtool-x86_64.AppImage WeChat*.AppImage *.tar.gz
|
||||
@ -127,5 +97,5 @@ jobs:
|
||||
name: ${{ steps.tag.outputs.name }}
|
||||
tag_name: ${{ steps.tag.outputs.tag }}
|
||||
files: |
|
||||
*.tar.gz
|
||||
*.AppImage
|
||||
tmp/build/*.tar.gz
|
||||
tmp/build/*.AppImage
|
76
tools/build-release.sh
Normal file
76
tools/build-release.sh
Normal file
@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 脚本执行前提,已完成支持wine的基本构建
|
||||
set -e
|
||||
root_dir=$(cd `dirname $0`/.. && pwd -P)
|
||||
tmp_dir="$root_dir/tmp"
|
||||
build_dir="$tmp_dir/build"
|
||||
version=$1
|
||||
ARCH=$2
|
||||
|
||||
success() {
|
||||
echo -e "\033[42;37m 成功 \033[0m $1"
|
||||
}
|
||||
notice() {
|
||||
echo -e "\033[36m $1 \033[0m "
|
||||
}
|
||||
|
||||
fail() {
|
||||
echo -e "\033[41;37m 失败 \033[0m $1"
|
||||
}
|
||||
|
||||
if [[ $version == '' ]];then
|
||||
fail "请指定版本"
|
||||
exit 1
|
||||
elif [[ $ARCH == '' ]];then
|
||||
fail "请指定架构"
|
||||
exit 1
|
||||
fi
|
||||
export ARCH=$ARCH
|
||||
|
||||
rm -rf "$build_dir"
|
||||
mkdir -p "$build_dir"
|
||||
|
||||
notice "下载AppImage构建工具"
|
||||
if [ $ACTION_MODE!='true' ]; then
|
||||
appimagetool_host="github.com"
|
||||
else
|
||||
appimagetool_host="download.fastgit.org"
|
||||
fi
|
||||
wget "https://$appimagetool_host/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" \
|
||||
-O "$tmp_dir/appimagetool-x86_64.AppImage"
|
||||
chmod a+x "$tmp_dir/appimagetool-x86_64.AppImage"
|
||||
|
||||
for type in wine no_wine; do
|
||||
notice "当前构建类型: $type";
|
||||
FULL_NAME="WeChat_Dev_Tools_${version}_${ARCH}_$type"
|
||||
if [[ $type == 'no_wine' ]];then
|
||||
notice "no wine handle"
|
||||
export NO_WINE=true
|
||||
bash "$root_dir/tools/fix-core"
|
||||
bash "$root_dir/tools/fix-other"
|
||||
fi
|
||||
mkdir -p "$build_dir/$FULL_NAME"
|
||||
|
||||
# 构建压缩包
|
||||
notice "COPY bin"
|
||||
\cp -rf "$root_dir/bin" "$build_dir/$FULL_NAME/bin"
|
||||
notice "COPY nwjs"
|
||||
\cp -drf "$root_dir/nwjs" "$build_dir/$FULL_NAME/nwjs"
|
||||
notice "COPY node"
|
||||
rm -rf "$build_dir/$FULL_NAME/nwjs/node"
|
||||
\cp -rf "$root_dir/node/bin/node" "$build_dir/$FULL_NAME/nwjs/node"
|
||||
notice "COPY package.nw"
|
||||
\cp -rf "$root_dir/package.nw" "$build_dir/$FULL_NAME/package.nw"
|
||||
notice "MAKE tar.gz"
|
||||
cd "$build_dir" && tar -zcf "$FULL_NAME.tar.gz" "$FULL_NAME"
|
||||
|
||||
# 构建AppImage
|
||||
notice "BUILD AppImage"
|
||||
bash "$root_dir/tools/appimage.sh"
|
||||
"$tmp_dir/appimagetool-x86_64.AppImage" "$root_dir/tmp/AppDir" "$build_dir/$FULL_NAME.AppImage"
|
||||
|
||||
# 删除构建资源
|
||||
notice "DELETE Build Source"
|
||||
rm -rf "$build_dir/$FULL_NAME"
|
||||
done
|
@ -2,6 +2,7 @@
|
||||
# 参数:
|
||||
# 1 ---- NW版本
|
||||
|
||||
set -e
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
||||
|
@ -77,16 +77,10 @@ const upgrade = function (extractPath) {
|
||||
|
||||
if (fs.existsSync(path.resolve(__dirname, "../nwjs"))) {
|
||||
if (!fs.existsSync(path.resolve(__dirname, "../nwjs/node"))) {
|
||||
fs.symlinkSync(
|
||||
path.resolve(__dirname, "../node/bin/node"),
|
||||
path.resolve(__dirname, "../nwjs/node")
|
||||
);
|
||||
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -sr ../node/bin/node node`)
|
||||
}
|
||||
if (!fs.existsSync(path.resolve(__dirname, "../nwjs/node.exe"))) {
|
||||
fs.symlinkSync(
|
||||
"node",
|
||||
path.resolve(__dirname, "../nwjs/node.exe")
|
||||
);
|
||||
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -s node node.exe`)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,11 +90,11 @@ const upgrade = function (extractPath) {
|
||||
execSync(`rm -rf ${extractPath}`);
|
||||
|
||||
if (fs.existsSync(path.resolve(__dirname, "../node/bin/node"))) {
|
||||
fs.linkSync(path.resolve(__dirname, "../node/bin/node"), path.resolve(__dirname, "../nwjs/node"));
|
||||
fs.linkSync(path.resolve(__dirname, "../node/bin/node"), path.resolve(__dirname, "../nwjs/node.exe"));
|
||||
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -sr ../node/bin/node node`)
|
||||
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -s node node.exe`)
|
||||
}
|
||||
if (fs.existsSync(path.resolve(__dirname, "../package.nw"))) {
|
||||
fs.symlinkSync(path.resolve(__dirname, "../package.nw"), path.resolve(__dirname, "../nwjs/package.nw"));
|
||||
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -sr ../package.nw package.nw`)
|
||||
}
|
||||
|
||||
resolve();
|
||||
|
Loading…
x
Reference in New Issue
Block a user