|
1 | | -name: Build Module ZIP |
| 1 | +name: Build |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
9 | 9 | - 'common/**' |
10 | 10 | - '*.sh' |
11 | 11 | - 'module.prop' |
| 12 | + - '.github/workflows/build.yml' |
12 | 13 | pull_request: |
13 | 14 | branches: [main] |
| 15 | + paths: |
| 16 | + - 'rust/**' |
14 | 17 | workflow_dispatch: |
15 | 18 |
|
16 | 19 | jobs: |
17 | 20 | build: |
18 | 21 | runs-on: ubuntu-latest |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + profile: [debug, release] |
| 25 | + target: |
| 26 | + - aarch64-linux-android |
| 27 | + - armv7-linux-androideabi |
| 28 | + include: |
| 29 | + - target: aarch64-linux-android |
| 30 | + abi: arm64-v8a |
| 31 | + - target: armv7-linux-androideabi |
| 32 | + abi: armeabi-v7a |
19 | 33 |
|
20 | 34 | steps: |
21 | 35 | - uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + submodules: recursive |
22 | 38 |
|
23 | | - - name: Install Rust toolchain |
24 | | - uses: dtolnay/rust-toolchain@stable |
| 39 | + - name: Setup Android NDK |
| 40 | + uses: nttld/setup-ndk@v1 |
| 41 | + id: ndk |
25 | 42 | with: |
26 | | - targets: aarch64-linux-android,armv7-linux-androideabi |
| 43 | + ndk-version: r27c |
27 | 44 |
|
28 | | - - name: Cache Rust dependencies |
29 | | - uses: actions/cache@v4 |
| 45 | + - uses: dtolnay/rust-toolchain@stable |
| 46 | + with: |
| 47 | + targets: ${{ matrix.target }} |
| 48 | + |
| 49 | + - uses: actions/cache@v4 |
30 | 50 | with: |
31 | 51 | path: | |
32 | 52 | ~/.cargo/registry |
33 | 53 | ~/.cargo/git |
34 | 54 | rust/target |
35 | | - key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} |
36 | | - restore-keys: ${{ runner.os }}-cargo- |
| 55 | + key: cargo-${{ matrix.target }}-${{ matrix.profile }}-${{ hashFiles('rust/Cargo.lock') }} |
| 56 | + restore-keys: cargo-${{ matrix.target }}-${{ matrix.profile }}- |
37 | 57 |
|
38 | | - - name: Setup Android NDK |
39 | | - uses: nttld/setup-ndk@v1 |
40 | | - id: ndk |
41 | | - with: |
42 | | - ndk-version: r27c |
| 58 | + - name: Build |
| 59 | + run: | |
| 60 | + NDK_BIN="${NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin" |
| 61 | + export PATH="${NDK_BIN}:${PATH}" |
| 62 | + export CC_aarch64_linux_android="${NDK_BIN}/aarch64-linux-android26-clang" |
| 63 | + export CC_armv7_linux_androideabi="${NDK_BIN}/armv7a-linux-androideabi26-clang" |
| 64 | + export AR_aarch64_linux_android="${NDK_BIN}/llvm-ar" |
| 65 | + export AR_armv7_linux_androideabi="${NDK_BIN}/llvm-ar" |
43 | 66 |
|
44 | | - - name: Build release and package |
| 67 | + FLAGS="" |
| 68 | + if [ "$PROFILE" = "release" ]; then |
| 69 | + FLAGS="--release" |
| 70 | + fi |
| 71 | + cd rust |
| 72 | + cargo build $FLAGS --target "$TARGET" |
45 | 73 | env: |
46 | | - ANDROID_NDK_HOME: ${{ steps.ndk.outputs.ndk-path }} |
47 | | - run: bash package.sh --no-bump |
| 74 | + PROFILE: ${{ matrix.profile }} |
| 75 | + TARGET: ${{ matrix.target }} |
| 76 | + NDK_HOME: ${{ steps.ndk.outputs.ndk-path }} |
48 | 77 |
|
49 | | - - name: Upload release ZIP |
50 | | - uses: actions/upload-artifact@v4 |
51 | | - with: |
52 | | - name: TA_enhanced-release-${{ github.sha }} |
53 | | - path: release/*.zip |
54 | | - retention-days: 30 |
| 78 | + - name: Assert debug info preserved |
| 79 | + if: matrix.profile == 'debug' |
| 80 | + run: | |
| 81 | + bin="rust/target/${TARGET}/debug/ta-enhanced" |
| 82 | + file "$bin" |
| 83 | + if ! readelf -S "$bin" | grep -q debug_info; then |
| 84 | + echo "::error::debug binary missing debug_info section" |
| 85 | + exit 1 |
| 86 | + fi |
| 87 | + env: |
| 88 | + TARGET: ${{ matrix.target }} |
55 | 89 |
|
56 | | - - name: Build debug binaries |
| 90 | + - name: Assert stripped |
| 91 | + if: matrix.profile == 'release' |
| 92 | + run: | |
| 93 | + bin="rust/target/${TARGET}/release/ta-enhanced" |
| 94 | + file "$bin" |
| 95 | + if readelf -S "$bin" | grep -q debug_info; then |
| 96 | + echo "::error::release binary still contains debug_info" |
| 97 | + exit 1 |
| 98 | + fi |
57 | 99 | env: |
58 | | - ANDROID_NDK_HOME: ${{ steps.ndk.outputs.ndk-path }} |
59 | | - run: bash rust/build.sh debug |
| 100 | + TARGET: ${{ matrix.target }} |
60 | 101 |
|
61 | | - - name: Upload debug binaries |
62 | | - uses: actions/upload-artifact@v4 |
| 102 | + - uses: actions/upload-artifact@v4 |
63 | 103 | with: |
64 | | - name: TA_enhanced-debug-${{ github.sha }} |
65 | | - path: | |
66 | | - bin/arm64-v8a/ta-enhanced |
67 | | - bin/armeabi-v7a/ta-enhanced |
| 104 | + name: bin-${{ matrix.abi }}-${{ matrix.profile }} |
| 105 | + path: rust/target/${{ matrix.target }}/${{ matrix.profile }}/ta-enhanced |
| 106 | + retention-days: 7 |
| 107 | + |
| 108 | + package: |
| 109 | + needs: build |
| 110 | + runs-on: ubuntu-latest |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v4 |
| 113 | + with: |
| 114 | + submodules: recursive |
| 115 | + |
| 116 | + - name: Download build artifacts |
| 117 | + uses: actions/download-artifact@v4 |
| 118 | + with: |
| 119 | + path: artifacts |
| 120 | + |
| 121 | + - name: Place release binaries |
| 122 | + run: | |
| 123 | + for pair in "arm64-v8a:aarch64-linux-android" "armeabi-v7a:armv7-linux-androideabi"; do |
| 124 | + abi="${pair%%:*}" |
| 125 | + target="${pair##*:}" |
| 126 | + src="artifacts/bin-${abi}-release/ta-enhanced" |
| 127 | + dst="bin/${abi}/ta-enhanced" |
| 128 | + mkdir -p "bin/${abi}" |
| 129 | + cp "$src" "$dst" |
| 130 | + chmod +x "$dst" |
| 131 | + done |
| 132 | +
|
| 133 | + - name: Read version |
| 134 | + id: ver |
| 135 | + run: | |
| 136 | + ver=$(grep '^version=' module.prop | cut -d= -f2) |
| 137 | + echo "version=${ver}" >> "$GITHUB_OUTPUT" |
| 138 | +
|
| 139 | + - name: Package release ZIP |
| 140 | + run: bash package.sh --no-build --no-bump |
| 141 | + |
| 142 | + - name: Package debug ZIP |
| 143 | + run: | |
| 144 | + MODULE_ID=$(grep '^id=' module.prop | cut -d= -f2) |
| 145 | + VER="${{ steps.ver.outputs.version }}" |
| 146 | +
|
| 147 | + for pair in "arm64-v8a:aarch64-linux-android" "armeabi-v7a:armv7-linux-androideabi"; do |
| 148 | + abi="${pair%%:*}" |
| 149 | + src="artifacts/bin-${abi}-debug/ta-enhanced" |
| 150 | + dst="bin/${abi}/ta-enhanced" |
| 151 | + cp "$src" "$dst" |
| 152 | + chmod +x "$dst" |
| 153 | + done |
| 154 | +
|
| 155 | + mkdir -p release |
| 156 | + ZIP_NAME="${MODULE_ID}-${VER}-debug.zip" |
| 157 | + zip -r9 "release/${ZIP_NAME}" . \ |
| 158 | + -x ".git/*" \ |
| 159 | + -x ".claude/*" \ |
| 160 | + -x ".mcp-vector-search/*" \ |
| 161 | + -x ".mcp.json" \ |
| 162 | + -x ".gitignore" \ |
| 163 | + -x "CLAUDE.md" \ |
| 164 | + -x "*.zip" \ |
| 165 | + -x "*.db" -x "*.db-shm" -x "*.db-wal" \ |
| 166 | + -x "logs_llm/*" \ |
| 167 | + -x "evidence_*.png" \ |
| 168 | + -x "*.swp" -x "*~" \ |
| 169 | + -x "release/*" \ |
| 170 | + -x "package.sh" \ |
| 171 | + -x "rust/*" \ |
| 172 | + -x "node_modules/*" \ |
| 173 | + -x "webui/src/*" \ |
| 174 | + -x "webui/node_modules/*" \ |
| 175 | + -x "*.map" \ |
| 176 | + -x ".git" \ |
| 177 | + -x "webui/dist/*" \ |
| 178 | + -x "webui/public/*" \ |
| 179 | + -x "webui/package.json" \ |
| 180 | + -x "webui/package-lock.json" \ |
| 181 | + -x "webui/pnpm-lock.yaml" \ |
| 182 | + -x "webui/.npmrc" \ |
| 183 | + -x "webui/vite.config.ts" \ |
| 184 | + -x "webui/tsconfig.json" \ |
| 185 | + -x "common/archive/*" \ |
| 186 | + -x "bin/archive/*" \ |
| 187 | + -x "webui-mockup/*" \ |
| 188 | + -x "bin/*/supervisor" \ |
| 189 | + -x "bin/*/keygen" \ |
| 190 | + -x "config/*" \ |
| 191 | + -x "glob" -x "os" \ |
| 192 | + -x "*.new" \ |
| 193 | + -x "vectors.db*" \ |
| 194 | + -x "webui/assets/index-CExZ91Qz.js.bak" \ |
| 195 | + -x "webui/material-symbols-outlined.woff2" \ |
| 196 | + -x "*.md" |
| 197 | +
|
| 198 | + - uses: actions/upload-artifact@v4 |
| 199 | + with: |
| 200 | + name: ta-enhanced-release-zip |
| 201 | + path: release/*-v*.zip |
| 202 | + retention-days: 30 |
| 203 | + |
| 204 | + - uses: actions/upload-artifact@v4 |
| 205 | + with: |
| 206 | + name: ta-enhanced-debug-zip |
| 207 | + path: release/*-debug.zip |
68 | 208 | retention-days: 30 |
| 209 | + |
| 210 | + release: |
| 211 | + needs: [build, package] |
| 212 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 213 | + runs-on: ubuntu-latest |
| 214 | + permissions: |
| 215 | + contents: write |
| 216 | + steps: |
| 217 | + - uses: actions/checkout@v4 |
| 218 | + |
| 219 | + - name: Read version |
| 220 | + id: ver |
| 221 | + run: | |
| 222 | + ver=$(grep '^version=' module.prop | cut -d= -f2) |
| 223 | + echo "version=${ver}" >> "$GITHUB_OUTPUT" |
| 224 | +
|
| 225 | + - uses: actions/download-artifact@v4 |
| 226 | + with: |
| 227 | + name: ta-enhanced-release-zip |
| 228 | + path: zips/release |
| 229 | + |
| 230 | + - uses: actions/download-artifact@v4 |
| 231 | + with: |
| 232 | + name: ta-enhanced-debug-zip |
| 233 | + path: zips/debug |
| 234 | + |
| 235 | + - name: Extract changelog |
| 236 | + id: notes |
| 237 | + run: | |
| 238 | + ver="${VER#v}" |
| 239 | + awk "/^## v${ver}/{flag=1; next} /^## v/{if(flag) exit} flag" CHANGELOG.md > /tmp/notes.md |
| 240 | + cat /tmp/notes.md |
| 241 | + env: |
| 242 | + VER: ${{ steps.ver.outputs.version }} |
| 243 | + |
| 244 | + - name: Create release |
| 245 | + run: | |
| 246 | + gh release delete "$VER" --yes 2>/dev/null || true |
| 247 | + gh release create "$VER" \ |
| 248 | + --title "$VER" \ |
| 249 | + --latest \ |
| 250 | + --notes-file /tmp/notes.md \ |
| 251 | + zips/release/*.zip \ |
| 252 | + zips/debug/*.zip |
| 253 | + env: |
| 254 | + VER: ${{ steps.ver.outputs.version }} |
| 255 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments