Skip to content

Commit 10e020f

Browse files
authored
feat: architecture upgrade (#1)
* feat: architecture upgrade * feat: optimize validate and template command * feat: use protocol type definition * feat: 🎸 update singbox protocol * feat: 🎸 add clash default template * feat: support export clash config * fix: fix vmess protocol convert logic * feat: compatible old singbox protocol, optimize the format of source config * feat: update github ci,update source info handle logic * fix: fix ci issue * feat: update ci * feat: update architecture --------- Co-authored-by: messica <bitxwave@163.com>
1 parent 1782216 commit 10e020f

File tree

144 files changed

+10718
-2933
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+10718
-2933
lines changed

.github/workflows/build.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Verify all release targets build (no packaging). Run on push to main and on pull_request.
2+
name: Build (all targets)
3+
4+
on:
5+
push:
6+
branches: [main, master]
7+
pull_request:
8+
branches: [main, master]
9+
10+
env:
11+
BINARY_NAME: proxy-convert
12+
RUST_BACKTRACE: 1
13+
14+
jobs:
15+
build:
16+
name: Build ${{ matrix.target }}
17+
runs-on: ${{ matrix.runner || matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- os: ubuntu-latest
23+
target: x86_64-unknown-linux-gnu
24+
- os: ubuntu-latest
25+
target: aarch64-unknown-linux-gnu
26+
- os: ubuntu-latest
27+
target: x86_64-unknown-linux-musl
28+
- os: macos-14
29+
target: x86_64-apple-darwin
30+
- os: macos-14
31+
target: aarch64-apple-darwin
32+
- os: windows-latest
33+
target: x86_64-pc-windows-msvc
34+
- os: windows-latest
35+
target: aarch64-pc-windows-msvc
36+
runner: windows-11-arm
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Install Rust toolchain
42+
uses: dtolnay/rust-toolchain@v1
43+
with:
44+
toolchain: stable
45+
targets: ${{ matrix.target }}
46+
47+
- name: Cache cargo
48+
uses: Swatinem/rust-cache@v2.8.2
49+
with:
50+
key: ${{ matrix.target }}
51+
52+
- name: Install Linux deps (glibc cross)
53+
if: matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-gnu'
54+
run: |
55+
sudo apt-get update
56+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross binutils-aarch64-linux-gnu
57+
58+
- name: Set env for Linux aarch64 cross
59+
if: matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-gnu'
60+
run: |
61+
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
62+
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
63+
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV
64+
echo "RANLIB_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ranlib" >> $GITHUB_ENV
65+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
66+
67+
- name: Install musl (x86_64)
68+
if: matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-musl'
69+
run: sudo apt-get update && sudo apt-get install -y musl-tools
70+
71+
- name: Set env for musl (x86_64)
72+
if: matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-musl'
73+
run: echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> $GITHUB_ENV
74+
75+
- name: Build
76+
run: cargo build --release --target ${{ matrix.target }} --verbose
77+
78+
- name: Test binary
79+
shell: bash
80+
run: |
81+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
82+
exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe"
83+
else
84+
exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}"
85+
fi
86+
if [ ! -f "$exe" ]; then
87+
echo "Binary not found: $exe"
88+
exit 1
89+
fi
90+
# Only run binary on native target (cross-compiled binaries cannot run on host)
91+
if [ "${{ matrix.os }}" = "ubuntu-latest" ] && [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
92+
"$exe" --version
93+
elif [ "${{ matrix.os }}" = "windows-latest" ] && { [ "${{ matrix.target }}" = "x86_64-pc-windows-msvc" ] || [ "${{ matrix.target }}" = "aarch64-pc-windows-msvc" ]; }; then
94+
"$exe" --version
95+
elif [ "${{ matrix.os }}" = "macos-14" ] && [ "${{ matrix.target }}" = "aarch64-apple-darwin" ]; then
96+
"$exe" --version
97+
else
98+
echo "Skipping execution (cross-compiled target)."
99+
fi

.github/workflows/release.yml

Lines changed: 80 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,105 +5,125 @@ on:
55
tags:
66
- 'v*'
77

8+
env:
9+
BINARY_NAME: proxy-convert
10+
RUST_BACKTRACE: 1
11+
812
jobs:
913
build:
10-
name: Build on ${{ matrix.os }} - ${{ matrix.target }}
11-
runs-on: ${{ matrix.os }}
14+
name: Build ${{ matrix.target }}
15+
runs-on: ${{ matrix.runner || matrix.os }}
1216
strategy:
17+
fail-fast: false
1318
matrix:
1419
include:
20+
# Linux glibc + musl static
1521
- os: ubuntu-latest
1622
target: x86_64-unknown-linux-gnu
17-
# - os: ubuntu-latest
18-
# target: aarch64-unknown-linux-gnu
19-
- os: macos-latest
23+
- os: ubuntu-latest
24+
target: aarch64-unknown-linux-gnu
25+
- os: ubuntu-latest
26+
target: x86_64-unknown-linux-musl
27+
# macOS
28+
- os: macos-14
2029
target: x86_64-apple-darwin
21-
- os: macos-latest
30+
- os: macos-14
2231
target: aarch64-apple-darwin
32+
# Windows (aarch64 使用 windows-11-arm runner,os 名称仍为 windows-latest)
2333
- os: windows-latest
2434
target: x86_64-pc-windows-msvc
35+
- os: windows-latest
36+
target: aarch64-pc-windows-msvc
37+
runner: windows-11-arm
2538

2639
steps:
27-
- name: Checkout code
40+
- name: Checkout
2841
uses: actions/checkout@v4
2942

30-
- name: Install system dependencies (Ubuntu only)
31-
if: matrix.os == 'ubuntu-latest'
32-
run: |
33-
sudo apt-get update
34-
sudo apt-get install -y build-essential
35-
sudo apt-get install -y libssl-dev
36-
if [ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]; then
37-
sudo apt-get install -y gcc-aarch64-linux-gnu
38-
sudo apt-get install -y g++-aarch64-linux-gnu
39-
sudo apt-get install -y libc6-dev-arm64-cross
40-
fi
43+
- name: Install Rust toolchain
44+
uses: dtolnay/rust-toolchain@v1
45+
with:
46+
toolchain: stable
47+
targets: ${{ matrix.target }}
48+
49+
- name: Cache cargo
50+
uses: Swatinem/rust-cache@v2.8.2
51+
with:
52+
key: ${{ matrix.target }}
53+
shared-key: release
4154

42-
- name: Set up Rust
55+
- name: Install Linux deps (glibc cross)
56+
if: matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-gnu'
4357
run: |
44-
rustup update stable
45-
rustup target add ${{ matrix.target }}
58+
sudo apt-get update
59+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross binutils-aarch64-linux-gnu
4660
47-
- name: Set environment variables for ARM cross-compilation (Ubuntu only)
61+
- name: Set env for Linux aarch64 cross (glibc)
4862
if: matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-gnu'
4963
run: |
5064
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
5165
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
5266
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV
5367
echo "RANLIB_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ranlib" >> $GITHUB_ENV
54-
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
55-
echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV
68+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
5669
57-
- name: Build project
70+
- name: Install musl (Linux static, x86_64 only)
71+
if: matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-musl'
72+
run: sudo apt-get update && sudo apt-get install -y musl-tools
73+
74+
- name: Set env for musl (x86_64)
75+
if: matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-musl'
76+
run: echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> $GITHUB_ENV
77+
78+
- name: Build
5879
run: cargo build --release --target ${{ matrix.target }} --verbose
5980

6081
- name: Test binary
82+
shell: bash
6183
run: |
62-
if [ "${{ matrix.os }}" == "windows-latest" ]; then
63-
binary_path=$(find target/${{ matrix.target }}/release -maxdepth 1 -type f -name "*.exe" | head -n 1)
84+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
85+
exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe"
6486
else
65-
binary_path=$(find target/${{ matrix.target }}/release -maxdepth 1 -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) | head -n 1)
87+
exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}"
6688
fi
67-
if [ -n "$binary_path" ]; then
68-
$binary_path --version
69-
else
70-
echo "No executable binary found."
89+
if [ ! -f "$exe" ]; then
90+
echo "Binary not found: $exe"
7191
exit 1
7292
fi
73-
shell: bash
74-
env:
75-
RUST_BACKTRACE: 1
93+
# Only run binary on native target (cross-compiled binaries cannot run on host)
94+
if [ "${{ matrix.os }}" = "ubuntu-latest" ] && [ "${{ matrix.target }}" = "x86_64-unknown-linux-gnu" ]; then
95+
"$exe" --version
96+
elif [ "${{ matrix.os }}" = "windows-latest" ] && { [ "${{ matrix.target }}" = "x86_64-pc-windows-msvc" ] || [ "${{ matrix.target }}" = "aarch64-pc-windows-msvc" ]; }; then
97+
"$exe" --version
98+
elif [ "${{ matrix.os }}" = "macos-14" ] && [ "${{ matrix.target }}" = "aarch64-apple-darwin" ]; then
99+
"$exe" --version
100+
else
101+
echo "Skipping execution (cross-compiled target)."
102+
fi
76103
77-
- name: Package binary
104+
- name: Package
78105
shell: bash
79106
run: |
80-
if [ "${{ matrix.os }}" == "windows-latest" ]; then
81-
binary_path=$(find target/${{ matrix.target }}/release -maxdepth 1 -type f -name "*.exe" | head -n 1)
82-
binary_name=$(basename "$binary_path")
107+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
108+
exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe"
109+
out="${{ env.BINARY_NAME }}-${{ matrix.target }}.zip"
110+
mkdir -p release
111+
cp "$exe" release/
112+
(cd release && 7z a "$out" "${{ env.BINARY_NAME }}.exe")
83113
else
84-
binary_path=$(find target/${{ matrix.target }}/release -maxdepth 1 -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) | head -n 1)
85-
binary_name=$(basename "$binary_path")
114+
exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}"
115+
out="${{ env.BINARY_NAME }}-${{ matrix.target }}.tar.gz"
116+
mkdir -p release
117+
cp "$exe" release/
118+
(cd release && tar czvf "$out" "${{ env.BINARY_NAME }}")
86119
fi
87-
mkdir -p ./release
88-
cp "$binary_path" release/"$binary_name"
89-
cd release
90-
if [ "${{ matrix.os }}" == "windows-latest" ]; then
91-
7z a "$binary_name-${{ matrix.target }}.zip" "$binary_name"
92-
echo "Packaged file: ./release/$binary_name-${{ matrix.target }}.zip"
93-
else
94-
tar czvf "$binary_name-${{ matrix.target }}.tar.gz" "$binary_name"
95-
echo "Packaged file: ./release/$binary_name-${{ matrix.target }}.tar.gz"
96-
fi
97-
cd ..
98-
120+
echo "PACKAGE_PATH=release/$out" >> $GITHUB_ENV
121+
99122
- name: Upload artifact
100123
uses: actions/upload-artifact@v4
101124
with:
102125
name: ${{ matrix.target }}
103-
path: |
104-
release/*.zip
105-
release/*.tar.gz
106-
if-no-files-found: error
126+
path: ${{ env.PACKAGE_PATH }}
107127

108128
release:
109129
name: Create Release
@@ -113,13 +133,12 @@ jobs:
113133
contents: write
114134

115135
steps:
116-
- name: Download all artifacts
136+
- name: Download artifacts
117137
uses: actions/download-artifact@v4
118138
with:
119139
path: artifacts
120140

121141
- name: Create Release
122-
id: create_release
123142
uses: softprops/action-gh-release@v2
124143
env:
125144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -129,5 +148,5 @@ jobs:
129148
draft: false
130149
prerelease: false
131150
files: |
132-
artifacts/**/*.zip
133-
artifacts/**/*.tar.gz
151+
artifacts/*/*.tar.gz
152+
artifacts/*/*.zip

0 commit comments

Comments
 (0)