Make parent drivers more obvious #56
Workflow file for this run
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
| # SPDX-FileCopyrightText: 2025 AJ Walter | |
| # SPDX-License-Identifier: GPL-3.0-or-later OR MIT | |
| name: Build Toolchains and Compile | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - build/* | |
| paths: | |
| - driver/*/Containerfile | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| paths: | |
| - driver/*/Containerfile | |
| env: | |
| REPO: ghcr.io/${{ github.repository }} | |
| jobs: | |
| generate-matrix: | |
| name: Generate Matrix | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.matrix.outputs.matrix }} | |
| tag: ${{ steps.tag.outputs.tags }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: '0' | |
| - name: Get Container Tag | |
| uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 | |
| id: tag | |
| with: | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=match,pattern=build/(\d.\d.\d),group=1 | |
| # Don't tag latest here, just tag the version. | |
| flavor: | | |
| latest=false | |
| - name: Get Changed Toolchains | |
| id: changed-files | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| # Pull requests need to check back to Master for building | |
| CHANGED_FILES=$(git diff --name-only origin/master -- 'driver/*/Containerfile') | |
| elif [[ "${{ github.ref }}" == refs/tags/build/* ]]; then | |
| # Tags will always rebuild all containers for a release | |
| CHANGED_FILES=$(find driver -mindepth 2 -maxdepth 2 -name "Containerfile") | |
| else | |
| # Otherwise, just check the diff of the last commit | |
| CHANGED_FILES=$(git diff --name-only HEAD~1 -- 'driver/*/Containerfile') | |
| fi | |
| echo "CHANGED_FILES<<EOF" >> $GITHUB_ENV | |
| echo "$CHANGED_FILES" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Build Matrix | |
| uses: actions/github-script@v7 | |
| id: matrix | |
| with: | |
| script: | | |
| const repo = process.env.REPO.toLowerCase(); | |
| const changedFiles = process.env.CHANGED_FILES.trim().split("\n").filter(f => f); | |
| const driverMap = { | |
| "SDL2-Linux": "linux-sdl2", | |
| "SDL2-Miyoo": "miyoo", | |
| "SDL2-PortMaster": "portmaster", | |
| "SFML-Linux": "linux" | |
| }; | |
| const matrix = changedFiles.map(file => { | |
| const folder = file.split('/')[1]; | |
| const image = driverMap.hasOwnProperty(folder) ? driverMap[folder] : folder.toLowerCase(); | |
| return { | |
| path: file, | |
| image: `${repo}/${image}`, | |
| folder: folder | |
| }; | |
| }); | |
| core.setOutput("matrix", JSON.stringify(matrix)); | |
| build-and-publish: | |
| name: Build ${{ matrix.images.image }} | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| needs: | |
| - generate-matrix | |
| strategy: | |
| matrix: | |
| images: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Container Metadata | |
| uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 | |
| id: meta | |
| with: | |
| images: ${{ matrix.images.image }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=match,pattern=build/(\d.\d.\d),group=1 | |
| - name: Build Toolchain | |
| id: build-image | |
| uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2.13 | |
| timeout-minutes: 60 | |
| with: | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| containerfiles: ${{ matrix.images.path }} | |
| - name: Push Toolchain | |
| uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2.8 | |
| with: | |
| tags: ${{ steps.build-image.outputs.tags }} | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| extra-args: | | |
| --disable-content-trust | |
| compile: | |
| name: Build ${{ matrix.images.folder }} | |
| runs-on: ubuntu-latest | |
| needs: | |
| - generate-matrix | |
| - build-and-publish | |
| strategy: | |
| matrix: | |
| images: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} | |
| container: | |
| image: ${{ matrix.images.image }}:${{ needs.generate-matrix.outputs.tag }} | |
| options: --user root | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Build | |
| run: | | |
| mkdir -p artifacts/build | |
| mkdir -p artifacts/install | |
| cd artifacts/build | |
| CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install" ../../driver/${{ matrix.images.folder }}/build.sh | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-${{ matrix.images.folder }} | |
| path: | | |
| artifacts/install | |
| !artifacts/install/**/romfs/** |