Skip to content

Commit

Permalink
workflows: Optimize and reduce binary size (#76)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
dopaemon committed Apr 16, 2024
1 parent 52db4e5 commit 5726e64
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,25 +70,27 @@ 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/
cp s-ui.service s-ui/
cp sing-box.service s-ui/
mkdir s-ui/bin
cp sing-box/sing-box s-ui/bin/
cp runSingbox.sh s-ui/bin/
- name: Package
run: tar -zcvf s-ui-linux-${{ matrix.platform }}.tar.gz s-ui

- name: Upload
uses: svenstaro/upload-release-action@v2
with:
Expand Down

0 comments on commit 5726e64

Please sign in to comment.