55 tags :
66 - ' v*'
77
8+ env :
9+ BINARY_NAME : proxy-convert
10+ RUST_BACKTRACE : 1
11+
812jobs :
913 build :
10- name : Build on ${{ matrix.os }} - ${{ matrix.target }}
14+ name : Build ${{ matrix.target }}
1115 runs-on : ${{ 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
2333 - os : windows-latest
2434 target : x86_64-pc-windows-msvc
35+ - os : windows-latest
36+ target : aarch64-pc-windows-msvc
2537
2638 steps :
27- - name : Checkout code
39+ - name : Checkout
2840 uses : actions/checkout@v4
2941
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
42+ - name : Install Rust toolchain
43+ uses : dtolnay/rust-toolchain@stable
44+ with :
45+ targets : ${{ matrix.target }}
46+
47+ - name : Cache cargo
48+ uses : Swatinem/rust-cache@2
49+ with :
50+ key : ${{ matrix.target }}
51+ shared-key : release
4152
42- - name : Set up Rust
53+ - name : Install Linux deps (glibc cross)
54+ if : matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-gnu'
4355 run : |
44- rustup update stable
45- rustup target add ${{ matrix.target }}
56+ sudo apt-get update
57+ sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
4658
47- - name : Set environment variables for ARM cross-compilation (Ubuntu only )
59+ - name : Set env for Linux aarch64 cross (glibc )
4860 if : matrix.os == 'ubuntu-latest' && matrix.target == 'aarch64-unknown-linux-gnu'
4961 run : |
5062 echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
5163 echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
5264 echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar" >> $GITHUB_ENV
53- 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
5665
57- - name : Build project
66+ - name : Install musl (Linux static, x86_64 only)
67+ if : matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-musl'
68+ run : sudo apt-get update && sudo apt-get install -y musl-tools
69+
70+ - name : Build
5871 run : cargo build --release --target ${{ matrix.target }} --verbose
5972
6073 - name : Test binary
74+ shell : bash
6175 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)
76+ if [ "${{ matrix.os }}" = "windows-latest" ]; then
77+ exe=" target/${{ matrix.target }}/release/${{ env.BINARY_NAME }} .exe"
6478 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)
79+ exe=" target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}"
6680 fi
67- if [ -n "$binary_path " ]; then
68- $binary_path --version
81+ if [ -f "$exe " ]; then
82+ "$exe" --version
6983 else
70- echo "No executable binary found. "
84+ echo "Binary not found: $exe "
7185 exit 1
7286 fi
73- shell : bash
74- env :
75- RUST_BACKTRACE : 1
7687
77- - name : Package binary
88+ - name : Package
7889 shell : bash
7990 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")
83- 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")
86- 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"
91+ if [ "${{ matrix.os }}" = "windows-latest" ]; then
92+ exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}.exe"
93+ out="${{ env.BINARY_NAME }}-${{ matrix.target }}.zip"
94+ mkdir -p release
95+ cp "$exe" release/
96+ (cd release && 7z a "$out" "${{ env.BINARY_NAME }}.exe")
9397 else
94- tar czvf "$binary_name-${{ matrix.target }}.tar.gz" "$binary_name"
95- echo "Packaged file: ./release/$binary_name-${{ matrix.target }}.tar.gz"
98+ exe="target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}"
99+ out="${{ env.BINARY_NAME }}-${{ matrix.target }}.tar.gz"
100+ mkdir -p release
101+ cp "$exe" release/
102+ (cd release && tar czvf "$out" "${{ env.BINARY_NAME }}")
96103 fi
97- cd ..
98-
104+ echo "PACKAGE_PATH=release/$out" >> $GITHUB_ENV
105+
99106 - name : Upload artifact
100107 uses : actions/upload-artifact@v4
101108 with :
102109 name : ${{ matrix.target }}
103- path : |
104- release/*.zip
105- release/*.tar.gz
106- if-no-files-found : error
110+ path : ${{ env.PACKAGE_PATH }}
107111
108112 release :
109113 name : Create Release
@@ -113,13 +117,12 @@ jobs:
113117 contents : write
114118
115119 steps :
116- - name : Download all artifacts
120+ - name : Download artifacts
117121 uses : actions/download-artifact@v4
118122 with :
119123 path : artifacts
120124
121125 - name : Create Release
122- id : create_release
123126 uses : softprops/action-gh-release@v2
124127 env :
125128 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -129,5 +132,5 @@ jobs:
129132 draft : false
130133 prerelease : false
131134 files : |
132- artifacts/** /*.zip
133- artifacts/** /*.tar.gz
135+ artifacts/*/*.tar.gz
136+ artifacts/*/*.zip
0 commit comments