Skip to content

Commit b2b7881

Browse files
committed
refactor: 优化构建流程
1 parent 4744ec9 commit b2b7881

File tree

5 files changed

+101
-60
lines changed

5 files changed

+101
-60
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
push:
1010
tags:
1111
- v*
12-
branches: [ master, reduce-wine]
12+
branches: [ master, actions-dev]
1313
pull_request:
1414
branches: [ master ]
1515
# # Allows you to run this workflow manually from the Actions tab
@@ -39,8 +39,9 @@ jobs:
3939
pwd
4040
ls -l
4141
export ACTION_MODE=true
42-
npm uninstall node-gyp -g
42+
sudo apt-get install -y libx11-dev libxkbfile-dev p7zip-full python2 python3 libkrb5-dev gcc openssl libssh2-1-dev g++ make
4343
npm install node-gyp nw-gyp npm -g
44+
node-gyp install
4445
4546
- id: Tag
4647
run: |
@@ -55,65 +56,34 @@ jobs:
5556
echo "::set-output name=name::$name"
5657
5758
- name: Build
58-
run: docker-compose up
59-
60-
- name: Refactor Directory Structure
6159
run: |
62-
sudo chmod -R 777 package.nw node
63-
ls -l
64-
sudo rm -rf cache tmp .git test
65-
mkdir ${{ env. name }}
66-
sudo find -maxdepth 1 -not -name ${{ env.name }} -not -name . -exec mv {} ${{ env.name }} \;
67-
sudo cp -r "${{ env.name }}/package.nw/node_modules/nodegit" nodegit
68-
sudo cp -r "${{ env.name }}/compiler" compiler
69-
ls -l
70-
env:
71-
name: 'WeChat_Dev_Tools_${{ steps.tag.outputs.tag }}'
60+
# docker-compose up
61+
tools/setup-wechat-devtools-bash
62+
sudo chmod -R 755 package.nw
63+
bash tools/build-release.sh ${{ steps.tag.outputs.tag }} ${{ matrix.ARCH }}
7264
73-
- name: Compress
65+
- name: Compress nodegit compiler
7466
run: |
7567
ls -l
76-
tar -zvcf compiler.tar.gz compiler
77-
tar -zvcf nodegit.tar.gz nodegit
78-
sudo rm -rf compiler nodegit ${{ env.name }}/node_modules
68+
sudo cp -r package.nw/node_modules/nodegit tmp/build/nodegit
69+
sudo cp -r compiler tmp/build/compiler
70+
cd tmp/build
71+
ls -l
72+
tar -zcf compiler.tar.gz compiler
73+
tar -zcf nodegit.tar.gz nodegit
74+
sudo rm -rf compiler nodegit
7975
ls -l
80-
env:
81-
name: 'WeChat_Dev_Tools_${{ steps.tag.outputs.tag }}'
8276
83-
- name: Build AppImage && Pack
77+
- name: View Directory
8478
run: |
85-
bash ./${{ env.name }}/tools/appimage.sh
86-
wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
87-
chmod a+x appimagetool-x86_64.AppImage
88-
# build AppImage
89-
./appimagetool-x86_64.AppImage ./${{ env.name }}/tmp/AppDir ${{ env.name }}_${{ env.ARCH }}_wine.AppImage
90-
# pack
91-
sudo rm -rf compiler nodegit ${{ env.name }}/tmp
92-
tar -zvcf ${{ env.name }}_${{ env.ARCH }}_wine.tar.gz ${{ env.name }}
93-
94-
# reduce wine
95-
export NO_WINE=true
96-
bash ${{ env.name }}/tools/fix-core
97-
bash ${{ env.name }}/tools/fix-other
98-
bash ./${{ env.name }}/tools/appimage.sh
99-
# build AppImage
100-
./appimagetool-x86_64.AppImage ./${{ env.name }}/tmp/AppDir ${{ env.name }}_${{ env.ARCH }}_no_wine.AppImage
101-
sudo rm -rf compiler nodegit ${{ env.name }}/tmp
102-
# pack
103-
tar -zvcf ${{ env.name }}_${{ env.ARCH }}_no_wine.tar.gz ${{ env.name }}
104-
105-
sudo rm -rf appimagetool-x86_64.AppImage ${{ env.name }}
10679
ls -l
107-
env:
108-
name: 'WeChat_Dev_Tools_${{ steps.tag.outputs.tag }}'
109-
ARCH: '${{ matrix.ARCH }}'
110-
11180
11281
- name: Create release and upload artifacts
11382
if: startsWith(github.ref, 'refs/heads/')
11483
env:
11584
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11685
run: |
86+
cd tmp/build
11787
wget -q https://github.com/TheAssassin/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage
11888
chmod +x pyuploadtool-x86_64.AppImage
11989
./pyuploadtool-x86_64.AppImage WeChat*.AppImage *.tar.gz
@@ -127,5 +97,5 @@ jobs:
12797
name: ${{ steps.tag.outputs.name }}
12898
tag_name: ${{ steps.tag.outputs.tag }}
12999
files: |
130-
*.tar.gz
131-
*.AppImage
100+
tmp/build/*.tar.gz
101+
tmp/build/*.AppImage

tools/build-release.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
# 脚本执行前提,已完成支持wine的基本构建
4+
set -e
5+
root_dir=$(cd `dirname $0`/.. && pwd -P)
6+
tmp_dir="$root_dir/tmp"
7+
build_dir="$tmp_dir/build"
8+
version=$1
9+
ARCH=$2
10+
11+
success() {
12+
echo -e "\033[42;37m 成功 \033[0m $1"
13+
}
14+
notice() {
15+
echo -e "\033[36m $1 \033[0m "
16+
}
17+
18+
fail() {
19+
echo -e "\033[41;37m 失败 \033[0m $1"
20+
}
21+
22+
if [[ $version == '' ]];then
23+
fail "请指定版本"
24+
exit 1
25+
elif [[ $ARCH == '' ]];then
26+
fail "请指定架构"
27+
exit 1
28+
fi
29+
export ARCH=$ARCH
30+
31+
rm -rf "$build_dir"
32+
mkdir -p "$build_dir"
33+
34+
notice "下载AppImage构建工具"
35+
if [ $ACTION_MODE!='true' ]; then
36+
appimagetool_host="github.com"
37+
else
38+
appimagetool_host="download.fastgit.org"
39+
fi
40+
wget "https://$appimagetool_host/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" \
41+
-O "$tmp_dir/appimagetool-x86_64.AppImage"
42+
chmod a+x "$tmp_dir/appimagetool-x86_64.AppImage"
43+
44+
for type in wine no_wine; do
45+
notice "当前构建类型: $type";
46+
FULL_NAME="WeChat_Dev_Tools_${version}_${ARCH}_$type"
47+
if [[ $type == 'no_wine' ]];then
48+
notice "no wine handle"
49+
export NO_WINE=true
50+
bash "$root_dir/tools/fix-core"
51+
bash "$root_dir/tools/fix-other"
52+
fi
53+
mkdir -p "$build_dir/$FULL_NAME"
54+
55+
# 构建压缩包
56+
notice "COPY bin"
57+
\cp -rf "$root_dir/bin" "$build_dir/$FULL_NAME/bin"
58+
notice "COPY nwjs"
59+
\cp -drf "$root_dir/nwjs" "$build_dir/$FULL_NAME/nwjs"
60+
notice "COPY node"
61+
rm -rf "$build_dir/$FULL_NAME/nwjs/node"
62+
\cp -rf "$root_dir/node/bin/node" "$build_dir/$FULL_NAME/nwjs/node"
63+
notice "COPY package.nw"
64+
\cp -rf "$root_dir/package.nw" "$build_dir/$FULL_NAME/package.nw"
65+
notice "MAKE tar.gz"
66+
cd "$build_dir" && tar -zcf "$FULL_NAME.tar.gz" "$FULL_NAME"
67+
68+
# 构建AppImage
69+
notice "BUILD AppImage"
70+
bash "$root_dir/tools/appimage.sh"
71+
"$tmp_dir/appimagetool-x86_64.AppImage" "$root_dir/tmp/AppDir" "$build_dir/$FULL_NAME.AppImage"
72+
73+
# 删除构建资源
74+
notice "DELETE Build Source"
75+
rm -rf "$build_dir/$FULL_NAME"
76+
done

tools/rebuild-node-modules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# 参数:
33
# 1 ---- NW版本
44

5+
set -e
56
SOURCE="${BASH_SOURCE[0]}"
67
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
78
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"

tools/update-node-node

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,10 @@ const upgrade = function (extractPath) {
7777

7878
if (fs.existsSync(path.resolve(__dirname, "../nwjs"))) {
7979
if (!fs.existsSync(path.resolve(__dirname, "../nwjs/node"))) {
80-
fs.symlinkSync(
81-
path.resolve(__dirname, "../node/bin/node"),
82-
path.resolve(__dirname, "../nwjs/node")
83-
);
80+
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -sr ../node/bin/node node`)
8481
}
8582
if (!fs.existsSync(path.resolve(__dirname, "../nwjs/node.exe"))) {
86-
fs.symlinkSync(
87-
"node",
88-
path.resolve(__dirname, "../nwjs/node.exe")
89-
);
83+
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -s node node.exe`)
9084
}
9185
}
9286

tools/update-nwjs-node

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ const upgrade = function (extractPath) {
9090
execSync(`rm -rf ${extractPath}`);
9191

9292
if (fs.existsSync(path.resolve(__dirname, "../node/bin/node"))) {
93-
fs.linkSync(path.resolve(__dirname, "../node/bin/node"), path.resolve(__dirname, "../nwjs/node"));
94-
fs.linkSync(path.resolve(__dirname, "../node/bin/node"), path.resolve(__dirname, "../nwjs/node.exe"));
93+
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -sr ../node/bin/node node`)
94+
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -s node node.exe`)
9595
}
9696
if (fs.existsSync(path.resolve(__dirname, "../package.nw"))) {
97-
fs.symlinkSync(path.resolve(__dirname, "../package.nw"), path.resolve(__dirname, "../nwjs/package.nw"));
97+
execSync(`cd ${path.resolve(__dirname, "../nwjs")} && ln -sr ../package.nw package.nw`)
9898
}
9999

100100
resolve();

0 commit comments

Comments
 (0)