编译 #100
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: 编译 | |
| on: | |
| #push: | |
| # branches: | |
| # - master | |
| #pull_request: | |
| # branches: | |
| # - master | |
| workflow_dispatch: | |
| inputs: | |
| release: | |
| description: "是否发行" | |
| type: boolean | |
| default: true | |
| jobs: | |
| Show-Info: | |
| name: 显示信息 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 显示信息 | |
| run: | | |
| echo "发行: ${{ inputs.release }}" | |
| Linux: | |
| name: Linux 编译 | |
| runs-on: ubuntu-latest | |
| needs: Show-Info | |
| steps: | |
| # 检出代码 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 设置 JDK 21 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' # 使用 Adoptium Temurin JDK | |
| java-version: '21' | |
| # 安装 Python 3 | |
| - name: Set up Python 3 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' # 支持 3.9 到 3.13 的 Python 版本 | |
| # 安装 Gradle | |
| - name: Set up Gradle | |
| uses: gradle/gradle-build-action@v2 | |
| with: | |
| gradle-version: '8.5' | |
| # 安装构建工具 (Linux 环境) | |
| - name: Install build tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y make gcc g++ | |
| # 下载并安装构建依赖 | |
| - name: Fetch build dependencies | |
| run: | | |
| gradle -I gradle/support/fetchDependencies.gradle | |
| # 构建 Ghidra | |
| - name: Build Ghidra | |
| run: | | |
| gradle buildGhidra | |
| # 保存构建结果 | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ghidra-linux-build | |
| path: build/dist/ | |
| Windows: | |
| name: Windows 编译 | |
| runs-on: windows-latest | |
| needs: Show-Info | |
| steps: | |
| # 检出代码 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 设置 JDK 21 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' # 使用 Adoptium Temurin JDK | |
| java-version: '21' | |
| # 设置 Python 3 | |
| - name: Set up Python 3 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' # 支持 3.9 到 3.13 的 Python 版本 | |
| # 安装 Gradle | |
| - name: Set up Gradle | |
| uses: gradle/gradle-build-action@v2 | |
| with: | |
| gradle-version: '8.5' | |
| # 安装 Windows 构建工具 | |
| - name: Install Windows build tools | |
| run: | | |
| choco install visualstudio2017buildtools --yes --no-progress | |
| choco install visualstudio2017-workload-vctools --yes --no-progress | |
| choco install make --yes --no-progress | |
| # 下载并安装构建依赖 | |
| - name: Fetch build dependencies | |
| run: | | |
| gradle -I gradle/support/fetchDependencies.gradle --parallel --max-workers=8 | |
| # 构建 Ghidra | |
| - name: Build Ghidra | |
| run: | | |
| gradle buildGhidra --parallel --max-workers=8 | |
| # 保存构建结果 | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ghidra-windows-build | |
| path: build/dist/ | |
| release: | |
| name: 发行 | |
| needs: [Linux, Windows] | |
| if: ${{ inputs.release }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: 下载文件 | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: 获取日期 | |
| id: date | |
| run: echo "CURRENT_DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV | |
| - name: 自动发布发行版 | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ env.CURRENT_DATE }} - ${{ github.run_id }} | |
| tag_name: ${{ env.CURRENT_DATE }}-${{ github.run_id }} | |
| draft: false | |
| make_latest: true | |
| files: | | |
| artifacts/ghidra-windows-build/*.zip | |
| artifacts/ghidra-linux-build/*.zip |