name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Cache Ghidra installation and config
uses: actions/cache@v4
with:
path: |
~/.local/share/ghidra-cli
~/.config/ghidra-cli
~/Library/Application Support/ghidra-cli
~/Library/Preferences/ghidra-cli
~/AppData/Local/ghidra-cli
~/AppData/Roaming/ghidra-cli
key: ghidra-${{ matrix.os }}-v5
- name: Cache Ghidra projects
uses: actions/cache@v4
with:
path: |
~/.cache/ghidra-cli/projects
~/Library/Caches/ghidra-cli/projects
~/AppData/Local/ghidra-cli/projects
key: ghidra-projects-${{ matrix.os }}-v4-${{ hashFiles('tests/fixtures/sample_binary.rs') }}
- name: Build
run: cargo build --verbose
- name: Build test fixture
run: rustc --edition 2021 -o tests/fixtures/sample_binary tests/fixtures/sample_binary.rs
- name: Setup Ghidra
run: |
DOCTOR_OUTPUT=$(cargo run -- doctor 2>&1 || true)
echo "$DOCTOR_OUTPUT"
if echo "$DOCTOR_OUTPUT" | grep -q "analyzeHeadless: OK"; then
echo "Ghidra already installed (cache hit), skipping setup"
else
echo "Ghidra not found, running setup..."
cargo run -- setup
fi
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create test project
run: |
cargo run -- import tests/fixtures/sample_binary --project ci-test --program sample_binary || true
cargo run -- analyze --project ci-test --program sample_binary || true
shell: bash
timeout-minutes: 20
- name: Run unit tests
run: cargo test --lib --verbose
- name: Run CLI tests
run: cargo test --test e2e --test output_format_integration --verbose
- name: Run read-only integration tests
run: cargo test --test readonly_tests --test command_tests --verbose -- --nocapture
timeout-minutes: 30
env:
RUST_LOG: info
- name: Stop bridge before mutation tests
run: cargo run -- stop --project ci-test || true
shell: bash
- name: Run mutation integration tests
run: cargo test --test comment_tests --test symbol_tests --test patch_tests --test type_tests --test script_tests --verbose -- --nocapture
timeout-minutes: 30
env:
RUST_LOG: info
- name: Stop bridge before infrastructure tests
run: cargo run -- stop --project ci-test || true
shell: bash
- name: Run infrastructure tests
run: cargo test --test daemon_tests --test reliability_tests --test project_tests --verbose -- --nocapture
timeout-minutes: 30
env:
RUST_LOG: info
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Create archive (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../ghidra-cli-${{ github.ref_name }}-${{ matrix.target }}.tar.gz ghidra
cd ../../..
- name: Create archive (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../ghidra-cli-${{ github.ref_name }}-${{ matrix.target }}.zip ghidra.exe
cd ../../..
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ghidra-cli-${{ matrix.target }}
path: ghidra-cli-${{ github.ref_name }}-${{ matrix.target }}.*
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
files: artifacts/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
name: Publish to crates.io
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}