1313 CARGO_TERM_COLOR : always
1414
1515jobs :
16- build_and_test :
17- name : Rustmail - latest
16+ build-frontend :
17+ name : Build Frontend (WASM)
1818 runs-on : ubuntu-22.04
1919 env :
2020 SQLX_OFFLINE : true
21- strategy :
22- matrix :
23- toolchain :
24- - stable
25-
2621 steps :
2722 - uses : actions/checkout@v4
2823
2924 - name : Set up Rust
30- run : rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
25+ run : rustup update stable && rustup default stable
3126
3227 - name : Install trunk and wasm target
3328 run : |
@@ -45,17 +40,44 @@ jobs:
4540 working-directory : crates/rustmail_panel
4641 run : trunk build --release --dist ../rustmail/static --config Trunk.toml
4742
48- - name : Build Rust backend
43+ - name : Upload frontend artifact
44+ uses : actions/upload-artifact@v4
45+ with :
46+ name : frontend-static
47+ path : crates/rustmail/static
48+ retention-days : 1
49+
50+ build-and-test :
51+ name : Build & Test
52+ needs : build-frontend
53+ runs-on : ubuntu-22.04
54+ env :
55+ SQLX_OFFLINE : true
56+ steps :
57+ - uses : actions/checkout@v4
58+
59+ - name : Set up Rust
60+ run : rustup update stable && rustup default stable
61+
62+ - name : Download frontend
63+ uses : actions/download-artifact@v4
64+ with :
65+ name : frontend-static
66+ path : crates/rustmail/static
67+
68+ - name : Build
4969 run : cargo build --verbose -p rustmail
5070
51- - name : Run tests
71+ - name : Test
5272 run : cargo test --verbose -p rustmail
5373
5474 create-release :
5575 name : Create Release
56- needs : build_and_test
76+ needs : build-and-test
5777 runs-on : ubuntu-22.04
5878 steps :
79+ - uses : actions/checkout@v4
80+
5981 - name : Create release
6082 env :
6183 GITHUB_TOKEN : ${{ secrets.GT_TOKEN }}
@@ -73,14 +95,31 @@ jobs:
7395 --generate-notes $prerelease
7496
7597 upload-assets :
76- needs : create-release
98+ name : Upload ${{ matrix.target }}
99+ needs : [create-release, build-frontend]
77100 strategy :
101+ fail-fast : false
78102 matrix :
79103 include :
104+ # ── Linux x86_64 (glibc) ──
80105 - target : x86_64-unknown-linux-gnu
81106 os : ubuntu-22.04
107+ # ── Linux x86_64 (musl / static) ──
108+ - target : x86_64-unknown-linux-musl
109+ os : ubuntu-22.04
110+ # ── Linux ARM64 (glibc) ──
111+ - target : aarch64-unknown-linux-gnu
112+ os : ubuntu-22.04
113+ # ── Linux ARM64 (musl / static) ──
114+ - target : aarch64-unknown-linux-musl
115+ os : ubuntu-22.04
116+ # ── macOS Intel (cross-compiled on Apple Silicon) ──
82117 - target : x86_64-apple-darwin
83- os : macos-latest
118+ os : macos-14
119+ # ── macOS Apple Silicon ──
120+ - target : aarch64-apple-darwin
121+ os : macos-14
122+ # ── Windows x64 ──
84123 - target : x86_64-pc-windows-msvc
85124 os : windows-latest
86125 runs-on : ${{ matrix.os }}
@@ -92,54 +131,30 @@ jobs:
92131 - name : Install Rust
93132 run : rustup update stable && rustup default stable
94133
95- - name : Install trunk and wasm target
96- run : |
97- rustup target add wasm32-unknown-unknown
98- cargo install trunk --locked
99-
100- - name : Install wasm-opt 125
101- run : |
102- if [ "$RUNNER_OS" == "Linux" ]; then
103- wget https://github.com/WebAssembly/binaryen/releases/download/version_125/binaryen-version_125-x86_64-linux.tar.gz
104- tar -xzf binaryen-version_125-x86_64-linux.tar.gz
105- sudo mv binaryen-version_125/bin/wasm-opt /usr/local/bin/
106- elif [ "$RUNNER_OS" == "macOS" ]; then
107- brew install binaryen
108- elif [ "$RUNNER_OS" == "Windows" ]; then
109- curl -L https://github.com/WebAssembly/binaryen/releases/download/version_125/binaryen-version_125-x86_64-windows.tar.gz -o binaryen.tar.gz
110- tar -xzf binaryen.tar.gz
111- mv binaryen-version_125/bin/wasm-opt.exe /usr/bin/
112- fi
113- wasm-opt --version
114- shell : bash
115-
116- - name : Create static directory
117- run : mkdir -p crates/rustmail/static
118- shell : bash
119-
120- - name : Build frontend
121- working-directory : crates/rustmail_panel
122- run : trunk build --release --dist ../rustmail/static --config Trunk.toml
134+ - name : Download frontend
135+ uses : actions/download-artifact@v4
136+ with :
137+ name : frontend-static
138+ path : crates/rustmail/static
123139
124- - name : Verify static files were created
140+ - name : Verify static files
125141 run : ls crates/rustmail/static
126142 shell : bash
127143
144+ - name : Install musl-tools (musl targets)
145+ if : contains(matrix.target, 'musl') && runner.os == 'Linux'
146+ run : sudo apt-get update && sudo apt-get install -y musl-tools
147+
128148 - uses : taiki-e/upload-rust-binary-action@v1
129149 with :
130-
131150 bin : rustmail
132-
133151 target : ${{ matrix.target }}
134-
135152 tar : unix
136-
137153 zip : windows
138-
139154 token : ${{ secrets.GT_TOKEN }}
140155
141156 docker-build-push :
142- name : Build and push Docker Image
157+ name : Build & Push Docker Image
143158 needs : upload-assets
144159 runs-on : ubuntu-latest
145160 env :
@@ -149,6 +164,9 @@ jobs:
149164 - name : Checkout repository
150165 uses : actions/checkout@v4
151166
167+ - name : Set up QEMU
168+ uses : docker/setup-qemu-action@v3
169+
152170 - name : Set up Docker Buildx
153171 uses : docker/setup-buildx-action@v3
154172
@@ -159,19 +177,31 @@ jobs:
159177 username : ${{ github.actor }}
160178 password : ${{ secrets.GITHUB_TOKEN }}
161179
162- - name : Download Linux binary from release
180+ - name : Download Linux binaries from release
163181 env :
164182 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
165183 run : |
166- rm -rf rustmail
167-
184+ mkdir -p bin/amd64 bin/arm64
185+
186+ # x86_64 (amd64)
168187 gh release download ${{ github.ref_name }} \
169188 --repo ${{ github.repository }} \
170189 --pattern 'rustmail-x86_64-unknown-linux-gnu.tar.gz'
171-
172190 tar -xzf rustmail-x86_64-unknown-linux-gnu.tar.gz
173- chmod +x rustmail
174- ls -lh rustmail
191+ mv rustmail bin/amd64/
192+ rm rustmail-x86_64-unknown-linux-gnu.tar.gz
193+
194+ # aarch64 (arm64)
195+ gh release download ${{ github.ref_name }} \
196+ --repo ${{ github.repository }} \
197+ --pattern 'rustmail-aarch64-unknown-linux-gnu.tar.gz'
198+ tar -xzf rustmail-aarch64-unknown-linux-gnu.tar.gz
199+ mv rustmail bin/arm64/
200+ rm rustmail-aarch64-unknown-linux-gnu.tar.gz
201+
202+ chmod +x bin/amd64/rustmail bin/arm64/rustmail
203+ echo "=== amd64 ===" && file bin/amd64/rustmail
204+ echo "=== arm64 ===" && file bin/arm64/rustmail
175205
176206 - name : Extract metadata for Docker
177207 id : meta
@@ -191,6 +221,7 @@ jobs:
191221 push : true
192222 tags : ${{ steps.meta.outputs.tags }}
193223 labels : ${{ steps.meta.outputs.labels }}
194- platforms : linux/amd64
224+ platforms : linux/amd64,linux/arm64
195225 cache-from : type=gha
196- cache-to : type=gha,mode=max
226+ cache-to : type=gha,mode=max
227+
0 commit comments