diff --git a/.github/workflows/dev-binary.yml b/.github/workflows/dev-binary.yml new file mode 100644 index 0000000000..62018d1492 --- /dev/null +++ b/.github/workflows/dev-binary.yml @@ -0,0 +1,138 @@ +name: Dev binary + +# Builds unsigned, untagged herdr binaries from the current branch so they can be +# downloaded and swapped in manually. Mirrors the release workflow's build job +# (same targets, same Zig/libghostty-vt settings) but publishes nothing: the +# binaries are uploaded as workflow artifacts only. + +on: + workflow_dispatch: + push: + branches: + - claude/** + +permissions: + contents: read + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + RUST_TOOLCHAIN_VERSION: 1.96.1 + +concurrency: + group: dev-binary-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + permissions: + contents: read + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + name: herdr-linux-x86_64 + - target: aarch64-unknown-linux-musl + os: ubuntu-latest + name: herdr-linux-aarch64 + - target: x86_64-apple-darwin + os: macos-latest + name: herdr-macos-x86_64 + - target: aarch64-apple-darwin + os: macos-latest + name: herdr-macos-aarch64 + + runs-on: ${{ matrix.os }} + env: + LIBGHOSTTY_VT_OPTIMIZE: ReleaseFast + LIBGHOSTTY_VT_SIMD: 'true' + + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + with: + persist-credentials: false + + - name: Install Rust + uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # v1 + with: + toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} + targets: ${{ matrix.target }} + + - name: Install Zig + if: runner.os != 'macOS' + uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2.2.1 + with: + version: 0.15.2 + + - name: Restore Homebrew Zig cache + if: runner.os == 'macOS' + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: ~/Library/Caches/Homebrew/downloads + key: homebrew-zig-0.15-${{ runner.os }}-${{ runner.arch }} + restore-keys: | + homebrew-zig-0.15-${{ runner.os }}- + + - name: Install patched Zig on macOS + if: runner.os == 'macOS' + run: | + HOMEBREW_NO_AUTO_UPDATE=1 brew install zig@0.15 + echo "$(brew --prefix zig@0.15)/bin" >> "$GITHUB_PATH" + "$(brew --prefix zig@0.15)/bin/zig" version + + - name: Prefer official Ubuntu mirrors over Azure + if: runner.os == 'Linux' + run: | + if [ -f /etc/apt/apt-mirrors.txt ]; then + sudo sed -i '/azure.archive.ubuntu.com/d' /etc/apt/apt-mirrors.txt + echo "Using apt mirrors:" + cat /etc/apt/apt-mirrors.txt + fi + + - name: Install Linux build tools + if: runner.os == 'Linux' + run: | + sudo find /etc/apt/sources.list.d -type f \( -iname '*microsoft*' -o -iname '*azure-cli*' \) -print -delete + sudo apt-get update + sudo apt-get install -y cmake ninja-build musl-tools gcc-aarch64-linux-gnu crossbuild-essential-arm64 + + - name: Install macOS build tools + if: runner.os == 'macOS' + run: HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake ninja + + - name: Set Linux aarch64 linker + if: matrix.target == 'aarch64-unknown-linux-musl' + run: echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV + + - name: Cache Rust artifacts + uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 + with: + key: dev-binary-${{ matrix.target }} + + - name: Remove Zig caches + run: rm -rf .zig-cache vendor/libghostty-vt/.zig-cache vendor/libghostty-vt/zig-out + + - name: Build + run: cargo build --release --locked --target ${{ matrix.target }} + + - name: Rename binary + run: cp target/${{ matrix.target }}/release/herdr ${{ matrix.name }} + + - name: Record build provenance + run: | + { + echo "commit=${GITHUB_SHA}" + echo "target=${{ matrix.target }}" + echo "built_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)" + } > ${{ matrix.name }}.provenance.txt + ./${{ matrix.name }} --version >> ${{ matrix.name }}.provenance.txt 2>&1 || true + cat ${{ matrix.name }}.provenance.txt + + - name: Upload artifact + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: ${{ matrix.name }} + path: | + ${{ matrix.name }} + ${{ matrix.name }}.provenance.txt