Merge pull request #129 from quarkslab/dm/ghidra-xref #86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Ghidra Extension | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "*" | |
| paths: | |
| - "bindings/python/quokka/**" | |
| - "ghidra_extension/**" | |
| - "proto/**" | |
| - "tests/dataset/sig_test" | |
| - "tests/python/tests/ghidra/**" | |
| - ".gitmodules" | |
| - ".github/workflows/ghidra.yml" | |
| pull_request: | |
| branches: ["**"] | |
| paths: | |
| - "bindings/python/quokka/**" | |
| - "ghidra_extension/**" | |
| - "proto/**" | |
| - "tests/dataset/sig_test" | |
| - "tests/python/tests/ghidra/**" | |
| - ".gitmodules" | |
| - ".github/workflows/ghidra.yml" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: {} | |
| jobs: | |
| ghidra-build: | |
| name: "Build and test Ghidra extension" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| persist-credentials: false | |
| lfs: true | |
| submodules: false | |
| - name: Checkout Ghidra submodule | |
| run: git submodule update --init third_party/ghidra | |
| - name: Resolve Ghidra version from submodule | |
| id: ghidra-version | |
| run: | | |
| TAG="$(git -C third_party/ghidra describe --tags --exact-match)" | |
| VERSION="$(echo "$TAG" | sed -n 's/^Ghidra_\([0-9]*\.[0-9]*\.[0-9]*\)_build$/\1/p')" | |
| if [[ -z "$VERSION" ]]; then | |
| echo "Error: tag '$TAG' does not match Ghidra_X.Y.Z_build" >&2 | |
| exit 1 | |
| fi | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - name: Cache Ghidra installation | |
| id: ghidra-cache | |
| uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: /opt/ghidra_${{ steps.ghidra-version.outputs.version }}_PUBLIC | |
| key: ghidra-${{ steps.ghidra-version.outputs.tag }} | |
| - name: Download Ghidra | |
| if: steps.ghidra-cache.outputs.cache-hit != 'true' | |
| run: | | |
| bash scripts/fetch_ghidra.sh --dest /opt | |
| - name: Set Ghidra environment | |
| env: | |
| GHIDRA_VERSION: ${{ steps.ghidra-version.outputs.version }} | |
| run: echo "GHIDRA_INSTALL_DIR=/opt/ghidra_${GHIDRA_VERSION}_PUBLIC" >> "$GITHUB_ENV" | |
| - name: Build, test, and install extension | |
| working-directory: ghidra_extension | |
| run: ./gradlew installExtension | |
| - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 | |
| with: | |
| python-version: "3.12" | |
| enable-cache: false | |
| - name: Create Python test environment | |
| run: | | |
| uv venv --python 3.12 | |
| uv pip install '.[test]' | |
| - name: Run Ghidra apply-back integration test | |
| run: .venv/bin/python -m pytest tests/python/tests/ghidra/test_ghidra_apply_back.py | |
| - name: Save Ghidra cache | |
| if: github.event_name == 'push' && steps.ghidra-cache.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: /opt/ghidra_${{ steps.ghidra-version.outputs.version }}_PUBLIC | |
| key: ghidra-${{ steps.ghidra-version.outputs.tag }} | |
| - name: Upload extension artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: ghidra-extension | |
| path: ghidra_extension/dist/*.zip | |
| if-no-files-found: error | |
| upload: | |
| name: Upload Ghidra extension for Release | |
| needs: [ghidra-build] | |
| if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: ghidra-extension | |
| - name: Upload to GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAG_NAME: ${{ github.ref_name }} | |
| run: | | |
| shopt -s failglob | |
| gh release upload "$TAG_NAME" ./*.zip |