workflows: Optimize and reduce binary size (#76)

* workflows: Optimize and reduce binary size

Signed-off-by: dopaemon <polarisdp@gmail.com>

* workflows: add tags osusergo

Signed-off-by: dopaemon <polarisdp@gmail.com>

---------

Signed-off-by: dopaemon <polarisdp@gmail.com>
This commit is contained in:
Trần Nguyễn Tuấn Anh
2024-04-16 17:42:21 +07:00
committed by GitHub
parent 52db4e5332
commit 5726e64b9f
+5 -4
View File
@@ -31,10 +31,9 @@ jobs:
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get update && sudo apt-get install upx -yq
if [ "${{ matrix.platform }}" == "arm64" ]; then
sudo apt install gcc-aarch64-linux-gnu
elif [ "${{ matrix.platform }}" == "armv7" ]; then
@@ -71,13 +70,15 @@ jobs:
#### Build Sing-Box
git clone -b v1.8.7 https://github.com/SagerNet/sing-box
cd sing-box
go build -tags with_v2ray_api,with_clash_api,with_grpc,with_quic,with_ech -o sing-box ./cmd/sing-box
go build -v -gcflags=all="-l -B -C" -mod=mod -trimpath -ldflags "-s -w -buildid= -extldflags '-static'" -a -tags='netgo osusergo static_build with_v2ray_api with_clash_api with_grpc with_quic with_ech' -o sing-box ./cmd/sing-box
upx --ultra-brute -9 -v --lzma --best --force sing-box
cd ..
### Build s-ui
cd backend
go build -o ../sui main.go
go build -v -gcflags=all="-l -B -C" -mod=mod -trimpath -ldflags "-s -w -buildid= -extldflags '-static'" -a -tags='netgo osusergo static_build sqlite_omit_load_extension' -o ../sui main.go
cd ..
upx --ultra-brute -9 -v --lzma --best --force sui
mkdir s-ui
cp sui s-ui/