Build Melee & publish GitHub Pages #3653
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: build | |
| run-name: Build Melee & publish GitHub Pages | |
| on: [push, pull_request] | |
| env: | |
| IMAGE_REPO: doldecomp/melee | |
| permissions: | |
| contents: read | |
| id-token: write | |
| packages: read | |
| pages: write | |
| jobs: | |
| build-ninja: | |
| name: Ninja | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'doldecomp/melee' | |
| container: ghcr.io/doldecomp/build-melee:main | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: [GALE01] | |
| mode: ["link", "diff"] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 2 | |
| sparse-checkout: | | |
| src | |
| extern | |
| tools | |
| config | |
| - name: Git config | |
| run: | | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| git config --global advice.detachedHead false | |
| - name: Prepare | |
| run: ln -s /orig . | |
| - name: Build | |
| run: | | |
| set -eou pipefail | |
| export RUST_LOG=error | |
| mode='${{matrix.mode}}' | |
| config_args='--compilers /compilers --max-errors 0 --verbose --version ${{matrix.version}}' | |
| function run_configure { | |
| echo "$config_args" | xargs python configure.py | |
| } | |
| case "$mode" in | |
| 'link') | |
| config_args="--map --require-protos $config_args" | |
| run_configure | |
| set +e | |
| ninja | |
| result="$?" | |
| while IFS= read -r line; do | |
| echo "$line" | |
| if [[ "$line" == *"ERROR"* ]]; then | |
| result=1 | |
| fi | |
| done < <(ninja diff) | |
| exit "$result" | |
| ;; | |
| 'diff') | |
| root='build/${{matrix.version}}' | |
| expected="$root/expected-report.json" | |
| current="$root/report.json" | |
| changes="$root/changes-report.json" | |
| head="$(git rev-parse HEAD)" | |
| function run_ninja { | |
| ninja all_source "$current" | |
| } | |
| case '${{github.event_name}}' in | |
| 'pull_request') | |
| git fetch origin HEAD | |
| git checkout FETCH_HEAD | |
| ;; | |
| 'push') | |
| git checkout 'HEAD^' | |
| ;; | |
| *) exit 1 ;; | |
| esac | |
| run_configure | |
| run_ninja | |
| cp "$current" "$expected" | |
| git checkout "$head" | |
| run_ninja | |
| build/tools/objdiff-cli report changes -o "$changes" "$expected" "$current" | |
| set +e | |
| python tools/diff_changes.py "$changes" | |
| set -e | |
| ;; | |
| *) exit 1 ;; | |
| esac | |
| - name: Upload map | |
| if: matrix.mode == 'link' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{matrix.version}}_maps | |
| path: build/${{matrix.version}}/**/*.MAP | |
| - name: Upload report | |
| if: matrix.mode == 'diff' && (success() || failure()) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{matrix.version}}_report | |
| path: build/${{matrix.version}}/report.json | |
| check-issues: | |
| name: Issues | |
| runs-on: ubuntu-latest | |
| env: | |
| REGISTRY: ghcr.io | |
| steps: | |
| - name: Get image name | |
| env: | |
| IMAGE_SUFFIX: check-issues:latest | |
| run: | | |
| echo "IMAGE=$IMAGE_REPO/$IMAGE_SUFFIX" >> $GITHUB_ENV | |
| - name: Checkout Melee repository | |
| uses: actions/checkout@v3 | |
| - name: Log into container registry | |
| uses: docker/login-action@v2.1.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull build image | |
| run: docker pull "$REGISTRY/$IMAGE" | |
| - name: Check for code issues | |
| run: | | |
| docker run --rm \ | |
| --user "$(id -u):$(id -g)" \ | |
| --volume "$PWD:/input:ro" \ | |
| "$REGISTRY/$IMAGE" | |
| gen-pages: | |
| name: Generate pages | |
| runs-on: ubuntu-latest | |
| needs: build-ninja | |
| env: | |
| REGISTRY: ghcr.io | |
| OUTPUT: ${{github.workspace}}/output | |
| steps: | |
| - name: Get image name | |
| env: | |
| IMAGE_SUFFIX: gen-pages:latest | |
| run: | | |
| echo "IMAGE=$IMAGE_REPO/$IMAGE_SUFFIX" >> $GITHUB_ENV | |
| - name: Checkout Melee repository | |
| uses: actions/checkout@v3 | |
| - name: Log into container registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull generator image | |
| run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE }} | |
| - name: Generate pages | |
| run: | | |
| mkdir -p "${{ env.OUTPUT }}" | |
| docker run --rm \ | |
| --user "$(id -u):$(id -g)" \ | |
| --volume "$PWD:/input:ro" \ | |
| --volume "${{ env.OUTPUT }}:/output" \ | |
| ${{ env.REGISTRY }}/${{ env.IMAGE }} | |
| - name: Upload GitHub Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ${{ env.OUTPUT }} | |
| deploy-pages: | |
| concurrency: | |
| group: deploy | |
| cancel-in-progress: false | |
| name: Deploy to GitHub Pages | |
| runs-on: ubuntu-latest | |
| needs: gen-pages | |
| if: github.ref_name == github.event.repository.default_branch | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Set up GitHub Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| build-nix: | |
| name: Nix | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'doldecomp/melee' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE: doldecomp/build-melee:main | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| sparse-checkout: | | |
| src | |
| extern | |
| tools | |
| config | |
| .nix | |
| - name: Log into container registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Grab Melee DOL | |
| run: | | |
| image="$REGISTRY/$IMAGE" | |
| docker pull "$image" | |
| container_id=$(docker create "$image") | |
| docker cp "$container_id":/orig . | |
| - uses: cachix/install-nix-action@v25 | |
| with: | |
| nix_path: nixpkgs=channel:nixos-unstable | |
| - uses: cachix/cachix-action@v16 | |
| with: | |
| name: doldecomp-melee | |
| authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
| - run: nix-build | |
| - run: nix-shell --run "echo OK" |