Update build.yml #51
This file contains 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: "build" | |
on: | |
push: | |
branches: | |
- release | |
jobs: | |
draft_release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
body: | | |
🚀 This release contains necessary jars to run Ghidra.js on different platforms. See README.md of this repo for more details. | |
draft: true | |
prerelease: false | |
build: | |
needs: [draft_release] | |
name: "Build" | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
include: | |
- ghidra: "10.4" | |
ghidra-url: "https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.4_build/ghidra_10.4_PUBLIC_20230928.zip" | |
ghidra-sha256: "6911d674798f145f8ea723fdd3eb67a8fae8c7be92e117bca081e6ef66acac19" | |
ghidra-filename: "ghidra_10.4_PUBLIC_20230928.zip" | |
ghidra-folder: "ghidra_10.4_PUBLIC" | |
- os: ubuntu-latest | |
javet-id: "javet" | |
build-prefix: "linux" | |
- os: windows-latest | |
javet-id: "javet" | |
build-prefix: "windows" | |
- os: macos-latest | |
javet-id: "javet-macos" | |
build-prefix: "macos" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Install coreutils for macOS | |
if: matrix.os == 'macOS-latest' | |
run: brew install coreutils | |
- name: Install Zip | |
if: matrix.os == 'windows-latest' | |
run: choco install zip | |
- uses: actions/checkout@v2 | |
- name: Cache Ghidra | |
uses: actions/cache@v2 | |
id: cache-ghidra | |
with: | |
path: ~/ghidra | |
key: ${{ runner.os }}-${{ matrix.ghidra }} | |
- name: Get Ghidra | |
if: steps.cache-ghidra.outputs.cache-hit != 'true' | |
run: | | |
curl -L ${{ matrix.ghidra-url }} > ${{ matrix.ghidra-filename }} | |
ls ${{ matrix.ghidra-filename }} | |
echo "${{ matrix.ghidra-sha256 }} ${{ matrix.ghidra-filename }}" | sha256sum -c | |
unzip ${{ matrix.ghidra-filename }} -d $HOME/ghidra | |
shell: bash | |
- uses: actions/setup-java@v2 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Set Up SDK Environment | |
run: | | |
curl -s "https://get.sdkman.io?rcupdate=false" | bash | |
source "$HOME/.sdkman/bin/sdkman-init.sh" | |
sdk install gradle 7.4 | |
sdk use gradle 7.4 | |
sdk default gradle 7.4 | |
shell: bash | |
- name: Build and Install | |
run: | | |
source "$HOME/.sdkman/bin/sdkman-init.sh" | |
./build.sh ${{ matrix.javet-id }} $HOME/ghidra/${{ matrix.ghidra-folder }} | |
ls dist/javet | |
unzip dist/javet/Ghidra.js.zip -d $HOME/ghidra/${{ matrix.ghidra-folder }}/Ghidra/Extensions | |
shell: bash | |
- name: Test | |
run: | | |
mkdir -p project | |
($HOME/ghidra/${{ matrix.ghidra-folder }}/support/analyzeHeadless project TestProject -deleteProject -preScript examples/test.js -import examples/exe/yes || echo [!] non-zero exit status) &>output.txt | |
cat output.txt | |
isOk=$(cat output.txt | grep "[*] ok") | |
echo isOk: $isOk | |
cat output.txt | |
[ -z "$isOk" ] && exit 1 | |
shell: bash | |
- name: Upload | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.draft_release.outputs.upload_url }} | |
asset_path: dist/javet/Ghidra.js.zip | |
asset_name: ${{ matrix.build-prefix }}-Ghidra.js-Javet-Ghidra_${{ matrix.ghidra }}.zip | |
asset_content_type: application/zip |