|
| 1 | +name: Native Builds |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [opened, edited, synchronize] |
| 5 | +permissions: |
| 6 | + pull-requests: write |
| 7 | + contents: write |
| 8 | +env: |
| 9 | + # A space-separated list of paths to native libraries to build. |
| 10 | + NATIVE_LIBRARY_PATHS: "sources/SDL/Native" |
| 11 | + # A space-separated list of submodule paths for each native library path. Use _ if a submodule is not used - this must |
| 12 | + # match the number of spaces in NATIVE_LIBRARY_PATHS. |
| 13 | + NATIVE_LIBRARY_SUBMODULE_PATHS: "eng/submodules/sdl" |
| 14 | + # A space-separated list of shorthands to the native library paths that will build the native library for each native |
| 15 | + # library path. This must match the number of spaces in NATIVE_LIBRARY_PATHS. If a shorthand builds multiple native |
| 16 | + # binary paths, these will be deduplicated. |
| 17 | + NATIVE_LIBRARY_SHORTHANDS: "SDL" |
| 18 | +jobs: |
| 19 | + prerequisites: |
| 20 | + name: PR Check |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v3 |
| 24 | + - id: parse |
| 25 | + name: Determine which native libraries the user has asked to build, and where to look for changes. |
| 26 | + run: ./workflow-stage1.sh |
| 27 | + working-directory: eng/native/buildsystem |
| 28 | + env: |
| 29 | + PR_COMMENT: ${{ github.event.pull_request.body }} |
| 30 | + - uses: dorny/paths-filter@v3 |
| 31 | + id: filter |
| 32 | + name: Determine which natives need to be rebuilt. |
| 33 | + with: |
| 34 | + filters: ${{ steps.parse.outputs.workflow_filters }} |
| 35 | + - name: Find a warning message from a previous run, if applicable. |
| 36 | + uses: peter-evans/find-comment@v3 |
| 37 | + id: fc |
| 38 | + with: |
| 39 | + issue-number: ${{ github.event.number }} |
| 40 | + comment-author: "github-actions[bot]" |
| 41 | + body-includes: "Some of the native library builds modified in this PR were not referenced in the PR description." |
| 42 | + - id: strat |
| 43 | + name: Create the matrix strategy for the native builds. |
| 44 | + run: ./workflow-stage2.sh |
| 45 | + working-directory: eng/native/buildsystem |
| 46 | + env: |
| 47 | + NATIVE_LIBRARY_APPLICABLE_SHORTHANDS: ${{ join(fromJSON(steps.filter.outputs.changes), ' ') }} |
| 48 | + NATIVE_LIBRARY_USER_REFERENCED_SHORTHANDS: ${{ steps.parse.outputs.targets_referenced }} |
| 49 | + PR_EXISTING_NOTICE_ID: ${{ steps.fc.outputs.comment-id }} |
| 50 | + - name: Write a comment if needed. |
| 51 | + if: ${{ steps.strat.outputs.comment_to_write }} |
| 52 | + uses: peter-evans/create-or-update-comment@v4 |
| 53 | + with: |
| 54 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 55 | + issue-number: ${{ github.event.number }} |
| 56 | + body: ${{ steps.strat.outputs.comment_to_write }} |
| 57 | + edit-mode: replace |
| 58 | + outputs: |
| 59 | + matrix_strategy: ${{ steps.strat.outputs.matrix_strategy }} |
| 60 | + targets_referenced: ${{ steps.parse.outputs.targets_referenced }} |
| 61 | + build: |
| 62 | + needs: [prerequisites] |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + flat: ${{ fromJSON(needs.prerequisites.outputs.matrix_strategy) }} |
| 66 | + runs-on: ${{ (startsWith(matrix.flat.runtime, 'osx') || startsWith(matrix.flat.runtime, 'ios') || startsWith(matrix.flat.runtime, 'tvos')) && 'macos-latest' || startsWith(matrix.flat.runtime, 'win') && 'windows-latest' || 'ubuntu-latest' }} |
| 67 | + name: ${{ matrix.flat.target }} / ${{ matrix.flat.runtime }} |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v3 |
| 70 | + - run: ${{ format('.{0}{1}', startsWith(matrix.flat.runtime, 'win') && '\' || '/', matrix.flat.exec) }} |
| 71 | + working-directory: ${{ matrix.flat.dir }} |
| 72 | + - uses: actions/upload-artifact@v4 |
| 73 | + with: |
| 74 | + name: natives-${{ matrix.flat.target }}-${{ matrix.flat.runtime }} |
| 75 | + path: | |
| 76 | + ${{ matrix.flat.dir }}/runtimes/${{ matrix.flat.runtime }}/**/* |
| 77 | + ${{ matrix.flat.dir}}/lib/*${{ matrix.flat.runtime }}*/**/* |
| 78 | + commit: |
| 79 | + name: Commit Binaries |
| 80 | + needs: [prerequisites, build] |
| 81 | + runs-on: ubuntu-latest |
| 82 | + if: ${{ needs.prerequisites.outputs.targets_referenced }} |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v4 |
| 85 | + with: |
| 86 | + ref: ${{ github.head_ref }} |
| 87 | + - name: Download All Artifacts |
| 88 | + uses: actions/download-artifact@v4 |
| 89 | + with: |
| 90 | + pattern: natives-* |
| 91 | + merge-multiple: true |
| 92 | + - name: Commit Artifacts |
| 93 | + run: | |
| 94 | + git config --local user.email "9011267+dotnet-bot@users.noreply.github.com" |
| 95 | + git config --local user.name "The Silk.NET Automaton" |
| 96 | + git add . |
| 97 | + git commit -m "Update native binaries for ${{ github.sha }}" |
| 98 | + git push |
0 commit comments