Merge pull request #7 from apple1417/master #30
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: CI | |
| on: | |
| push: {} | |
| pull_request: {} | |
| workflow_dispatch: | |
| inputs: | |
| new-release-tag: | |
| description: > | |
| New Release Tag. If given, creates a (draft) full release using the given tag. | |
| type: string | |
| required: false | |
| jobs: | |
| build-windows: | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| preset: [ | |
| "clang-x86-release", | |
| "clang-x64-release", | |
| "msvc-x86-release", | |
| "msvc-x64-release", | |
| ] | |
| steps: | |
| - name: Setup Clang | |
| if: startswith(matrix.preset, 'clang') | |
| uses: egor-tensin/setup-clang@v1 | |
| - name: Add MSVC to PATH | |
| if: startswith(matrix.preset, 'msvc') | |
| uses: TheMrMilchmann/setup-msvc-dev@v3 | |
| with: | |
| arch: ${{ fromJSON('["x86", "x64"]')[contains(matrix.preset, 'x64')] }} | |
| - name: Setup CMake and Ninja | |
| uses: lukka/get-cmake@latest | |
| - name: Checkout repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Configure CMake | |
| working-directory: ${{ env.GITHUB_WORKSPACE }} | |
| run: cmake . --preset ${{ matrix.preset }} | |
| - name: Build | |
| working-directory: ${{ env.GITHUB_WORKSPACE }} | |
| run: cmake --build out/build/${{ matrix.preset }} --target install | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.preset }} | |
| path: out/install/${{ matrix.preset }}/ | |
| build-ubuntu: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| toolchain: | |
| - preset: clang-cross-x86-release | |
| container: clang-cross | |
| - preset: clang-cross-x64-release | |
| container: clang-cross | |
| - preset: llvm-mingw-x86-release | |
| container: llvm-mingw | |
| - preset: llvm-mingw-x64-release | |
| container: llvm-mingw | |
| - preset: mingw-x86-release | |
| container: mingw | |
| - preset: mingw-x64-release | |
| container: mingw | |
| steps: | |
| - name: Checkout repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build | |
| uses: devcontainers/[email protected] | |
| with: | |
| cacheFrom: ghcr.io/bl-sdk/${{ matrix.toolchain.container }}:latest | |
| configFile: .devcontainer/${{ matrix.toolchain.container }}/devcontainer.json | |
| push: never | |
| # The git watcher cmake thinks something's unsafe? Doesn't happen to me locally. | |
| runCmd: | | |
| git config --global --add safe.directory `pwd` | |
| set -e | |
| cmake . --preset ${{ matrix.toolchain.preset }} -G Ninja | |
| cmake --build out/build/${{ matrix.toolchain.preset }} --target install | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.toolchain.preset }} | |
| path: out/install/${{ matrix.toolchain.preset }}/ | |
| # ============================================================================== | |
| clang-tidy: | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| preset: [ | |
| "clang-x86-release", | |
| "clang-x64-release", | |
| ] | |
| steps: | |
| - name: Setup Clang | |
| if: startswith(matrix.preset, 'clang') | |
| uses: egor-tensin/setup-clang@v1 | |
| - name: Setup CMake and Ninja | |
| uses: lukka/get-cmake@latest | |
| # Needed for clang tidy to enable `-export-fixes` | |
| - name: Install pyyaml | |
| run: pip install pyyaml | |
| - name: Checkout repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Configure CMake | |
| working-directory: ${{ env.GITHUB_WORKSPACE }} | |
| run: cmake . --preset ${{ matrix.preset }} -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On | |
| - name: Remove `.modmap`s from compile commands | |
| run: | | |
| (Get-Content "out\build\${{ matrix.preset }}\compile_commands.json") ` | |
| -replace "@CMakeFiles.+?\.modmap", "" ` | |
| | Set-Content ` | |
| -Path "out\build\${{ matrix.preset }}\compile_commands.json" | |
| - name: Run clang-tidy | |
| working-directory: ${{ env.GITHUB_WORKSPACE }} | |
| run: | | |
| python (Get-Command run-clang-tidy).Source ` | |
| -p "out\build\${{ matrix.preset }}" ` | |
| -export-fixes clang-tidy-fixes.yml ` | |
| $([Regex]::Escape("$pwd\src") + ".+\.(c|cpp|h|hpp)$") | |
| - name: Process clang-tidy warnings | |
| uses: asarium/clang-tidy-action@v1 | |
| with: | |
| fixesFile: clang-tidy-fixes.yml | |
| clang-format: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Setup Clang | |
| if: startswith(matrix.preset, 'clang') | |
| uses: egor-tensin/setup-clang@v1 | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Run clang-format | |
| run: | | |
| clang-format ` | |
| -n -Werror ` | |
| $(Get-ChildItem ` | |
| src ` | |
| -File ` | |
| -Recurse ` | |
| -Include ("*.c", "*.cpp", "*.h", "*.hpp") ` | |
| | % FullName) | |
| spelling: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Check spelling | |
| uses: crate-ci/typos@master | |
| # ============================================================================== | |
| release-draft-full: | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.ref == 'refs/heads/master' | |
| && github.repository == 'bl-sdk/pluginloader' | |
| && inputs.new-release-tag != '' | |
| needs: | |
| - build-ubuntu | |
| - build-windows | |
| - clang-tidy | |
| - clang-format | |
| - spelling | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ~/releases | |
| - name: Zip artifacts | |
| shell: bash | |
| run: | | |
| cd ~/releases | |
| for folder in */ ; do | |
| cd "$folder" | |
| zip -r "${folder%/}.zip" . | |
| cd .. | |
| done | |
| - name: Create new release tag | |
| uses: rickstaa/action-create-tag@v1 | |
| with: | |
| tag: ${{ inputs.new-release-tag }} | |
| - name: Upload releases | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ inputs.new-release-tag }} | |
| files: "/home/runner/releases/*/*.zip" | |
| fail_on_unmatched_files: true | |
| draft: true | |
| generate_release_notes: true |