@@ -55,37 +55,106 @@ jobs:
5555
5656 - name : Install Rust
5757 uses : dtolnay/rust-toolchain@stable
58+ with :
59+ toolchain : 1.93.0
60+
61+ - name : Add musl target
62+ run : rustup target add x86_64-unknown-linux-musl
63+
64+ - name : Install musl toolchain
65+ run : |
66+ sudo apt-get update
67+ sudo apt-get install -y musl-tools
5868
5969 - name : Cache Rust dependencies
70+ uses : Swatinem/rust-cache@v2
71+ with :
72+ workspaces : |
73+ anycode-backend -> target
74+
75+ - name : Build Linux x86_64 musl binary
76+ working-directory : ./anycode-backend
77+ run : cargo build --release --target x86_64-unknown-linux-musl
78+
79+ - name : Package as tar.gz
80+ working-directory : ./anycode-backend
81+ run : |
82+ mkdir -p dist-release
83+ strip target/x86_64-unknown-linux-musl/release/anycode
84+ cp target/x86_64-unknown-linux-musl/release/anycode dist-release/
85+ tar -czf anycode-linux-x86_64-musl.tar.gz -C dist-release anycode
86+
87+ - name : Upload to release
88+ if : startsWith(github.ref, 'refs/tags/')
89+ uses : softprops/action-gh-release@v2
90+ with :
91+ files : anycode-backend/anycode-linux-x86_64-musl.tar.gz
92+ tag_name : ${{ github.ref_name }}
93+ name : Release ${{ github.ref_name }}
94+
95+ build-linux-arm64 :
96+ name : Build for Linux ARM64
97+ runs-on : ubuntu-latest
98+ steps :
99+ - uses : actions/checkout@v4
100+
101+ - name : Setup Node.js
102+ uses : actions/setup-node@v4
103+ with :
104+ node-version : ' 24'
105+
106+ - name : Install pnpm
107+ uses : pnpm/action-setup@v4
108+
109+ - name : Get pnpm store directory
110+ shell : bash
111+ run : |
112+ echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
113+
114+ - name : Setup pnpm cache
60115 uses : actions/cache@v4
61116 with :
62- path : |
63- ~/.cargo/bin/
64- ~/.cargo/registry/index/
65- ~/.cargo/registry/cache/
66- ~/.cargo/git/db/
67- anycode-backend/target/
68- key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
117+ path : ${{ env.STORE_PATH }}
118+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
69119 restore-keys : |
70- ${{ runner.os }}-cargo-
120+ ${{ runner.os }}-pnpm-store-
121+
122+ - name : Install dependencies
123+ run : pnpm install --frozen-lockfile
124+
125+ - name : Build frontend
126+ working-directory : ./anycode
127+ run : pnpm build
71128
72- - name : Build Linux x86_64 binary
129+ - name : Verify frontend build
73130 working-directory : ./anycode-backend
74- run : cargo build --release
131+ run : |
132+ if [ ! -d "dist" ] || [ -z "$(ls -A dist)" ]; then
133+ echo "Error: dist directory is empty or missing"
134+ exit 1
135+ fi
136+ echo "Frontend build verified: $(ls -la dist | head -5)"
137+
138+ - name : Build Linux aarch64 musl binary
139+ uses : houseabsolute/actions-rust-cross@v1
140+ with :
141+ command : build
142+ target : aarch64-unknown-linux-musl
143+ args : " --release"
144+ working-directory : ./anycode-backend
75145
76146 - name : Package as tar.gz
77147 working-directory : ./anycode-backend
78148 run : |
79149 mkdir -p dist-release
80- strip target/release/anycode
81- cp target/release/anycode dist-release/
82- tar -czf anycode-linux-x86_64.tar.gz -C dist-release anycode
150+ cp target/aarch64-unknown-linux-musl/release/anycode dist-release/
151+ tar -czf anycode-linux-aarch64-musl.tar.gz -C dist-release anycode
83152
84153 - name : Upload to release
85154 if : startsWith(github.ref, 'refs/tags/')
86155 uses : softprops/action-gh-release@v2
87156 with :
88- files : anycode-backend/anycode-linux-x86_64 .tar.gz
157+ files : anycode-backend/anycode-linux-aarch64-musl .tar.gz
89158 tag_name : ${{ github.ref_name }}
90159 name : Release ${{ github.ref_name }}
91160
@@ -132,22 +201,17 @@ jobs:
132201 fi
133202 echo "Frontend build verified: $(ls -la dist | head -5)"
134203
135- - name : Install Rust targets
136- run : |
137- rustup target add aarch64-apple-darwin x86_64-apple-darwin
204+ - name : Install Rust
205+ uses : dtolnay/rust-toolchain@stable
206+ with :
207+ toolchain : 1.93.0
208+ targets : aarch64-apple-darwin,x86_64-apple-darwin
138209
139210 - name : Cache Rust dependencies
140- uses : actions/ cache@v4
211+ uses : Swatinem/rust- cache@v2
141212 with :
142- path : |
143- ~/.cargo/bin/
144- ~/.cargo/registry/index/
145- ~/.cargo/registry/cache/
146- ~/.cargo/git/db/
147- anycode-backend/target/
148- key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
149- restore-keys : |
150- ${{ runner.os }}-cargo-
213+ workspaces : |
214+ anycode-backend -> target
151215
152216 - name : Build macOS binaries
153217 working-directory : ./anycode-backend
@@ -177,4 +241,3 @@ jobs:
177241 files : anycode-backend/anycode-universal-apple-darwin.tar.gz
178242 tag_name : ${{ github.ref_name }}
179243 name : Release ${{ github.ref_name }}
180-
0 commit comments