From 284bad155d914daa1243688572b9311276c90d37 Mon Sep 17 00:00:00 2001 From: Matt P <5638426+mattbruv@users.noreply.github.com> Date: Sat, 29 Jun 2024 10:56:24 -0500 Subject: [PATCH] add website building flow to build yml --- .github/workflows/build.yml | 125 +++++++++++++++++++++++------------- tools/download_tool.py | 15 +++++ 2 files changed, 97 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3fbe4288d..01a272762 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,46 +18,85 @@ jobs: version: [GQPE78] steps: - # Checkout the repository (shallow clone) - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: recursive - - # Set Git config - - name: Git config - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - - # Copy the original files to the workspace - - name: Prepare - run: cp -R /orig . - - # Build the project - - name: Build - run: | - python configure.py --wrapper wibo --map --version ${{ matrix.version }} \ - --binutils /binutils --compilers /compilers - ninja all_source build/${{ matrix.version }}/progress.json - - # Upload progress if we're on the main branch - - name: Upload progress - # If you're using a different branch, change this to match - if: github.ref == 'refs/heads/main' - continue-on-error: true - env: - # Replace with your project slug - PROGRESS_SLUG: bfbb - # Set the API key in your repository secrets - PROGRESS_API_KEY: ${{ secrets.PROGRESS_API_KEY }} - run: | - python tools/upload_progress.py -b https://progress.decomp.club/ \ - -p $PROGRESS_SLUG -v ${{ matrix.version }} \ - build/${{ matrix.version }}/progress.json - - # Upload map files - - name: Upload map - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.version }}_maps - path: build/${{ matrix.version }}/**/*.MAP + # Checkout the repository (shallow clone) + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: recursive + + - name: Checkout Website + if: github.ref == 'refs/heads/main' + uses: actions/checkout@v4 + with: + repository: bfbbdecomp/website + path: website + + # Set Git config + - name: Git config + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + + # Copy the original files to the workspace + - name: Prepare + run: cp -R /orig . + + - name: Download objdiff CLI + if: github.ref == 'refs/heads/main' + run: | + python tools/download_tool.py --tag v2.0.0-alpha.5 objdiff-cli objdiff-cli + + # Build the project + - name: Build + run: | + python configure.py --wrapper wibo --map --version ${{ matrix.version }} \ + --binutils /binutils --compilers /compilers + ninja all_source build/${{ matrix.version }}/progress.json + + # Upload progress if we're on the main branch + - name: Upload progress + # If you're using a different branch, change this to match + if: github.ref == 'refs/heads/main' + continue-on-error: true + env: + # Replace with your project slug + PROGRESS_SLUG: bfbb + # Set the API key in your repository secrets + PROGRESS_API_KEY: ${{ secrets.PROGRESS_API_KEY }} + run: | + python tools/upload_progress.py -b https://progress.decomp.club/ \ + -p $PROGRESS_SLUG -v ${{ matrix.version }} \ + build/${{ matrix.version }}/progress.json + + # Upload map files + - name: Upload map + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.version }}_maps + path: build/${{ matrix.version }}/**/*.MAP + + - name: Generate Progress Report + if: github.ref == 'refs/heads/main' + run: | + ./objdiff-cli report generate -o website/progress.json + + - name: Parse Progress + if: github.ref == 'refs/heads/main' + run: | + cd website + python progress.py progress.json json/ + + - name: Build Website + if: github.ref == 'refs/heads/main' + run: | + cd website + npm install + npm run build + + - name: Deploy Website + if: github.ref == 'refs/heads/main' + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: website/dist # The folder the action should deploy. + clean: true + single-commit: true diff --git a/tools/download_tool.py b/tools/download_tool.py index 7b386a4ba..4ff874be5 100644 --- a/tools/download_tool.py +++ b/tools/download_tool.py @@ -65,6 +65,20 @@ def wibo_url(tag: str) -> str: repo = "https://github.com/decompals/wibo" return f"{repo}/releases/download/{tag}/wibo" +def objdiffcli_url(tag: str) -> str: + uname = platform.uname() + suffix = "" + system = uname.system.lower() + if system == "darwin": + system = "macos" + elif system == "windows": + suffix = ".exe" + arch = uname.machine.lower() + if arch == "amd64": + arch = "x86_64" + + repo = "https://github.com/encounter/objdiff" + return f"{repo}/releases/download/{tag}/objdiff-cli-{system}-{arch}{suffix}" TOOLS: Dict[str, Callable[[str], str]] = { "binutils": binutils_url, @@ -72,6 +86,7 @@ def wibo_url(tag: str) -> str: "dtk": dtk_url, "sjiswrap": sjiswrap_url, "wibo": wibo_url, + "objdiff-cli": objdiffcli_url }