Initial commit #1
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
# This workflow automates the build process for all modes of the UE4SS project whenever a pull request is made. | ||
# It dynamically calculates the build matrix based on the modes defined in the project and manages artifact uploads based on user selections in PR comments. | ||
name: Build All Modes | ||
permissions: | ||
contents: write | ||
pull-requests: write # For adding comments to PR. | ||
on: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
paths-ignore: | ||
- 'README.md' | ||
- 'docs/**' | ||
- 'docs-export/**' | ||
# Ensure that rapid pushes to the pull request branch don't trigger this workflow multiple times. | ||
# We only care about executing this workflow for that 'latest' commit on a PR. | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
# Dynamically calculate which modes to build. | ||
# We also need to determine which modes should upload artifacts. | ||
calculate-matrix: | ||
name: Calculate job matrix | ||
runs-on: ubuntu-latest | ||
outputs: | ||
# JSON array with the following schema: | ||
# [ | ||
# { | ||
# "mode": "Game__Shipping__Win64", | ||
# "artifact": false | ||
# }, | ||
# ... | ||
# ] | ||
matrix: ${{ steps.calculate-artifacts.outputs.matrix }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive # Clone the submodule so we can query xmake on the entire project. | ||
token: ${{ secrets.UEPSEUDO_PAT }} | ||
# Build modes are supplied by xmake, so we have to download and setup the xmake environment. | ||
- name: Setup xmake | ||
uses: xmake-io/github-action-setup-xmake@v1 | ||
with: | ||
xmake-version: "2.9.2" | ||
actions-cache-folder: '.xmake-cache' # This auto-cache functionality only works on linux runners. | ||
# `xmake ci --dump=modes` returns a JSON array of all UE4SS modes that xmake knows how to build. | ||
- name: Get xmake Modes | ||
id: get-xmake-modes | ||
shell: pwsh | ||
run: | | ||
$modes = (xmake ci --dump=modes) | ||
echo "all_modes=$modes" >> $env:GITHUB_OUTPUT | ||
# We now compare the user selected artifacts with the xmake mode list to generate the finalized matrix. | ||
- name: Finalize Mode Matrix | ||
uses: actions/github-script@v7 | ||
id: calculate-artifacts | ||
env: | ||
ALL_MODES: '${{steps.get-xmake-modes.outputs.all_modes}}' | ||
REQUESTED_MODES: '["Game__Shipping__Win64", "Game__Debug__Win64"]' | ||
with: | ||
result-encoding: string | ||
retries: 3 # Retry in case REST requests fail transitively. | ||
script: | | ||
const { ALL_MODES, REQUESTED_MODES } = process.env; | ||
const modeSchema = JSON.parse(ALL_MODES).map(m => ({mode: m, artifact: REQUESTED_MODES.has(m) ? REQUESTED_MODES.get(m) : false})); | ||
core.setOutput('matrix', JSON.stringify(modeSchema)); | ||
# Build UE4SS for each mode we received from the `calculate_matrix` job. | ||
build: | ||
name: ${{ matrix.mode }} | ||
needs: [ calculate-matrix ] # Ensure the mode/artifact matrix has been generated before we launch this job. | ||
strategy: | ||
fail-fast: false # Disable fast failing because we want to cancel other modes if one fails. | ||
matrix: | ||
# Use our generated matrix to populate the `include` array. | ||
include: ${{ fromJSON(needs.calculate-matrix.outputs.matrix) }} | ||
# Run our reusable workflow for each mode in our matrix. | ||
uses: ./.github/msvc_build_ue4ss.yml | ||
secrets: inherit # Inherit secrets from this workflow to safely pass `secrets.UE4SS_PAT` to our reusable workflow. | ||
with: | ||
build-mode: ${{ matrix.mode }} | ||
commit-sha: ${{ github.sha }} # This is the SHA of the PR merge result, not the HEAD of the PR branch! | ||
should-upload-artifact: ${{ matrix.artifact }} | ||
# JSON that declares what files to upload for specific xmake targets. | ||
# The supplied format should be compatible with the output of `xmake ci --dump=targets`. | ||
# This specifies that the `UE4SS` target should upload its target file and symbol file. | ||
# Ex. UE4SS.dll + UE4SS.pdb | ||
artifact-list: '{"UE4SS": ["target", "symbol"]}' | ||
artifact-retention-days: 14 |