|
25 | 25 | fail-fast: false |
26 | 26 | matrix: |
27 | 27 | include: |
28 | | - # The Linux builds need the runner's glibc, 2.35, or newer. |
29 | | - - { runner: ubuntu-22.04, target: x86_64-unknown-linux-gnu } |
30 | | - - { runner: ubuntu-22.04-arm, target: aarch64-unknown-linux-gnu } |
| 28 | + # Zig links Linux against glibc 2.17, OpenTUI's floor. zig_sha is the archive's, from ziglang.org. |
| 29 | + - runner: ubuntu-24.04 |
| 30 | + target: x86_64-unknown-linux-gnu |
| 31 | + zig: x86_64-linux-gnu.2.17 |
| 32 | + zig_sha: 3581863e3cbcfd0fce0efc682ce7e9e93da96668a977791d356a26d2a7e9b17a |
| 33 | + - runner: ubuntu-24.04-arm |
| 34 | + target: aarch64-unknown-linux-gnu |
| 35 | + zig: aarch64-linux-gnu.2.17 |
| 36 | + zig_sha: a1546d5646eb184437918d6635ca6b762a0e889eac09cef720ee7a1ed3fe7795 |
31 | 37 | - { runner: macos-15-intel, target: x86_64-apple-darwin } |
32 | 38 | - { runner: macos-15, target: aarch64-apple-darwin } |
33 | 39 | - { runner: windows-2025, target: x86_64-pc-windows-msvc, exe: .exe } |
@@ -56,14 +62,40 @@ jobs: |
56 | 62 | version=0.0.0-$GITHUB_SHA |
57 | 63 | if [[ $GITHUB_REF == refs/tags/cli-rs-v* ]]; then version=${GITHUB_REF_NAME#cli-rs-v}; fi |
58 | 64 | echo "OPENCODE_VERSION=$version" >> "$GITHUB_ENV" |
| 65 | + # Zig 0.17.1 as the C and C++ compiler and the linker. The wrapper drops flags zig rejects: cc's --target, and |
| 66 | + # rustc's Cortex-A53 erratum fix on aarch64. |
| 67 | + - if: matrix.zig |
| 68 | + working-directory: ${{ runner.temp }} |
| 69 | + run: | |
| 70 | + file=zig-$(uname -m)-linux-0.17.1 |
| 71 | + curl -fsSL --retry 3 -o zig.tar.xz "https://ziglang.org/download/0.17.1/$file.tar.xz" |
| 72 | + echo "${{ matrix.zig_sha }} zig.tar.xz" | sha256sum -c |
| 73 | + tar -xJf zig.tar.xz |
| 74 | + for tool in cc c++; do |
| 75 | + cat > "zig-$tool" <<EOF |
| 76 | + #!/bin/sh |
| 77 | + for a; do shift; case \$a in --target=*|-Wl,--fix-cortex-a53-843419) ;; *) set -- "\$@" "\$a" ;; esac; done |
| 78 | + exec "$PWD/$file/zig" $tool -target ${{ matrix.zig }} "\$@" |
| 79 | + EOF |
| 80 | + chmod +x "zig-$tool" |
| 81 | + done |
| 82 | + triple=$(tr a-z- A-Z_ <<< "${{ matrix.target }}") |
| 83 | + { echo "CARGO_TARGET_${triple}_LINKER=$PWD/zig-cc"; echo "CC_${triple,,}=$PWD/zig-cc" |
| 84 | + echo "CXX_${triple,,}=$PWD/zig-c++"; echo "CXXSTDLIB_${triple,,}=c++"; } >> "$GITHUB_ENV" |
59 | 85 | # rustup reads rust-toolchain.toml; `bun run cargo` first fetches OpenTUI's native library from its release. |
60 | 86 | - run: rustup toolchain install |
61 | 87 | - run: bun run cargo build --locked --profile dist --bin opencode-native |
| 88 | + - name: Check glibc 2.17 and no libstdc++ |
| 89 | + if: matrix.zig |
| 90 | + run: "! readelf -dV target/dist/opencode-native | grep -E 'GLIBC_2\\.(1[89]|[2-9][0-9])|libstdc\\+\\+'" |
62 | 91 | - name: Package |
63 | 92 | run: | |
64 | 93 | name=opencode-native-$OPENCODE_VERSION-${{ matrix.target }} |
65 | 94 | mkdir -p "dist/$name" |
66 | 95 | cp "target/dist/opencode-native${{ matrix.exe }}" "dist/$name/" |
| 96 | + # Our licence, and OpenTUI's licences (FFmpeg's among them) from its native release zip. |
| 97 | + cp ../../LICENSE "dist/$name/" |
| 98 | + cp -r .opentui/*/host/licenses "dist/$name/" |
67 | 99 | tar -C dist -czf "dist/$name.tar.gz" "$name" |
68 | 100 | ls -l "dist/$name" "dist/$name.tar.gz" |
69 | 101 | - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
|
0 commit comments