Repository navigation
Build LuaSF packages for main @ e6038df52d7c00fd87609e927e51145afbb697c1 #18
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 packages | |
| run-name: Build LuaSF packages for ${{ github.ref_name }} @ ${{ github.sha }} | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| workflow_call: | |
| permissions: | |
| contents: read | |
| jobs: | |
| windows-vs2022: | |
| name: Windows VS2022 x64 ${{ matrix.variant_label }} | |
| runs-on: windows-2022 | |
| timeout-minutes: 120 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - variant: '' | |
| variant_label: default | |
| variant_suffix: '' | |
| sfml_tag: '3.1.0' | |
| - variant: ME | |
| variant_label: ME | |
| variant_suffix: '-ME' | |
| sfml_tag: '310ME-iOSJoystick' | |
| - variant: ME-OH | |
| variant_label: ME-OH | |
| variant_suffix: '-ME-OH' | |
| sfml_tag: '310-ME-OH-GLESVER' | |
| env: | |
| CMAKE_GENERATOR: Visual Studio 17 2022 | |
| CMAKE_GENERATOR_PLATFORM: x64 | |
| steps: | |
| - name: Checkout triggering commit | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: Validate checkout and build scripts | |
| shell: pwsh | |
| run: | | |
| $headCommit = (git rev-parse HEAD).Trim() | |
| if ($headCommit -ne $env:GITHUB_SHA) { | |
| throw "HEAD '$headCommit' does not match triggering commit '$env:GITHUB_SHA'." | |
| } | |
| $requiredScripts = @( | |
| 'init.bat', | |
| 'build.bat', | |
| 'collect_result.bat', | |
| 'pack_result.bat' | |
| ) | |
| $missingScripts = @($requiredScripts | Where-Object { -not (Test-Path -LiteralPath $_ -PathType Leaf) }) | |
| if ($missingScripts.Count -ne 0) { | |
| throw "Triggering commit is missing required scripts: $($missingScripts -join ', ')" | |
| } | |
| - name: Set up Python 3.12 x64 | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: '3.12' | |
| architecture: x64 | |
| - name: Initialize dependencies | |
| shell: cmd | |
| run: call init.bat ${{ matrix.variant }} | |
| - name: Build Release packages | |
| shell: cmd | |
| run: call build.bat Release ${{ matrix.variant }} | |
| - name: Verify VS2022 generator | |
| shell: pwsh | |
| run: | | |
| $cacheLines = Get-Content -LiteralPath 'output/build/CMakeCache.txt' | |
| if ($cacheLines -notcontains 'CMAKE_GENERATOR:INTERNAL=Visual Studio 17 2022') { | |
| throw 'The output project was not generated with Visual Studio 2022.' | |
| } | |
| if ($cacheLines -notcontains 'CMAKE_GENERATOR_PLATFORM:INTERNAL=x64') { | |
| throw 'The output project was not generated for x64.' | |
| } | |
| - name: Verify SFML variant | |
| shell: pwsh | |
| run: | | |
| $tagFile = 'third_party/SFML/.luasf-sfml-tag' | |
| if (-not (Test-Path -LiteralPath $tagFile -PathType Leaf)) { | |
| throw "Missing SFML tag marker: $tagFile" | |
| } | |
| $actualTag = [string](Get-Content -LiteralPath $tagFile -Raw) | |
| $actualTag = $actualTag.Trim() | |
| if ($actualTag -ne '${{ matrix.sfml_tag }}') { | |
| throw "Expected SFML tag '${{ matrix.sfml_tag }}', found '$actualTag'." | |
| } | |
| $variantFile = '.luasf-sfml-variant' | |
| if (-not (Test-Path -LiteralPath $variantFile -PathType Leaf)) { | |
| throw "Missing SFML variant marker: $variantFile" | |
| } | |
| $actualVariant = Get-Content -LiteralPath $variantFile -Raw | |
| if ($null -eq $actualVariant) { | |
| $actualVariant = '' | |
| } else { | |
| $actualVariant = $actualVariant.Trim() | |
| } | |
| if ($actualVariant -ne '${{ matrix.variant }}') { | |
| throw "Expected SFML variant '${{ matrix.variant }}', found '$actualVariant'." | |
| } | |
| - name: Collect Release result | |
| shell: cmd | |
| run: call collect_result.bat Release | |
| - name: Pack distributable archives | |
| shell: cmd | |
| run: call pack_result.bat | |
| - name: Verify Windows packages | |
| shell: pwsh | |
| run: | | |
| $expectedPackages = @( | |
| 'output/packages/LuaSF-source${{ matrix.variant_suffix }}.zip', | |
| 'output/packages/LuaSF-embedded${{ matrix.variant_suffix }}-Windows-x64-MSVC.zip' | |
| ) | |
| foreach ($package in $expectedPackages) { | |
| if (-not (Test-Path -LiteralPath $package -PathType Leaf)) { | |
| throw "Missing package: $package" | |
| } | |
| } | |
| $actualPackages = @(Get-ChildItem -LiteralPath 'output/packages' -File) | |
| if ($actualPackages.Count -ne $expectedPackages.Count) { | |
| throw "Expected $($expectedPackages.Count) packages, found $($actualPackages.Count): $($actualPackages.Name -join ', ')" | |
| } | |
| if (Test-Path -LiteralPath 'output/result/extension') { | |
| throw 'The collected result still contains a removed extension package.' | |
| } | |
| $requiredRuntimeDlls = @( | |
| 'LuaSF.dll', | |
| 'lua.dll', | |
| 'msvcp140.dll', | |
| 'msvcp140_atomic_wait.dll', | |
| 'vcruntime140.dll', | |
| 'vcruntime140_1.dll' | |
| ) | |
| foreach ($dll in $requiredRuntimeDlls) { | |
| $path = Join-Path 'output/result/embedded/bin' $dll | |
| if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { | |
| throw "Missing embedded runtime DLL: $path" | |
| } | |
| } | |
| if (-not (Get-ChildItem -LiteralPath 'output/result/embedded/bin' -Filter 'sfml-*.dll' -File)) { | |
| throw 'The embedded result does not contain SFML runtime DLLs.' | |
| } | |
| if (-not (Test-Path -LiteralPath 'output/result/embedded/stub/LuaSF.d.lua' -PathType Leaf)) { | |
| throw 'The embedded result does not contain the LuaSF stub.' | |
| } | |
| - name: Upload Windows packages | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: LuaSF${{ matrix.variant_suffix }}-Windows-VS2022-x64 | |
| path: output/packages/*.zip | |
| if-no-files-found: error | |
| compression-level: 0 | |
| macos-apple-silicon: | |
| name: macOS Apple Silicon arm64 ${{ matrix.variant_label }} | |
| runs-on: macos-15 | |
| timeout-minutes: 120 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - variant: '' | |
| variant_label: default | |
| variant_suffix: '' | |
| sfml_tag: '3.1.0' | |
| - variant: ME | |
| variant_label: ME | |
| variant_suffix: '-ME' | |
| sfml_tag: '310ME-iOSJoystick' | |
| - variant: ME-OH | |
| variant_label: ME-OH | |
| variant_suffix: '-ME-OH' | |
| sfml_tag: '310-ME-OH-GLESVER' | |
| env: | |
| CMAKE_OSX_ARCHITECTURES: arm64 | |
| steps: | |
| - name: Checkout triggering commit | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: Validate Apple Silicon runner, checkout, and build scripts | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [ "$(uname -m)" != "arm64" ]; then | |
| echo "Expected an Apple Silicon arm64 runner." >&2 | |
| exit 1 | |
| fi | |
| head_commit=$(git rev-parse HEAD) | |
| if [ "$head_commit" != "$GITHUB_SHA" ]; then | |
| echo "HEAD '$head_commit' does not match triggering commit '$GITHUB_SHA'." >&2 | |
| exit 1 | |
| fi | |
| for script in init.sh build.sh collect_result.sh pack_result.sh; do | |
| if [ ! -f "$script" ]; then | |
| echo "Triggering commit is missing required script: $script" >&2 | |
| exit 1 | |
| fi | |
| done | |
| libclang_path="$(brew --prefix llvm@18)/lib/libclang.dylib" | |
| if [ ! -f "$libclang_path" ]; then | |
| echo "Missing llvm@18 libclang: $libclang_path" >&2 | |
| exit 1 | |
| fi | |
| echo "LIBCLANG_PATH=$libclang_path" >> "$GITHUB_ENV" | |
| - name: Set up Python 3.12 arm64 | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: '3.12' | |
| architecture: arm64 | |
| - name: Initialize dependencies | |
| shell: sh | |
| run: sh init.sh ${{ matrix.variant }} | |
| - name: Build Release packages | |
| shell: sh | |
| run: sh build.sh Release ${{ matrix.variant }} | |
| - name: Verify arm64 output configuration | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| grep -Eq '^CMAKE_OSX_ARCHITECTURES:[^=]*=arm64$' output/build/CMakeCache.txt | |
| - name: Verify SFML variant | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [ ! -f third_party/SFML/.luasf-sfml-tag ]; then | |
| echo 'Missing SFML tag marker: third_party/SFML/.luasf-sfml-tag' >&2 | |
| exit 1 | |
| fi | |
| actual_tag=$(cat third_party/SFML/.luasf-sfml-tag) | |
| if [ "$actual_tag" != '${{ matrix.sfml_tag }}' ]; then | |
| echo "Expected SFML tag '${{ matrix.sfml_tag }}', found '$actual_tag'." >&2 | |
| exit 1 | |
| fi | |
| if [ ! -f .luasf-sfml-variant ]; then | |
| echo 'Missing SFML variant marker: .luasf-sfml-variant' >&2 | |
| exit 1 | |
| fi | |
| actual_variant=$(cat .luasf-sfml-variant) | |
| if [ "$actual_variant" != '${{ matrix.variant }}' ]; then | |
| echo "Expected SFML variant '${{ matrix.variant }}', found '$actual_variant'." >&2 | |
| exit 1 | |
| fi | |
| - name: Collect Release result | |
| shell: sh | |
| run: sh collect_result.sh Release | |
| - name: Verify macOS result | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| unexpected_dll=$(find output/result -type f -name '*.dll' -print -quit) | |
| if [ -n "$unexpected_dll" ]; then | |
| echo "Unexpected Windows DLL in macOS result: $unexpected_dll" >&2 | |
| exit 1 | |
| fi | |
| if [ -d output/result/extension ]; then | |
| echo 'The collected result still contains a removed extension package.' >&2 | |
| exit 1 | |
| fi | |
| found_binary=0 | |
| while IFS= read -r binary; do | |
| found_binary=1 | |
| architectures=$(lipo -archs "$binary") | |
| if [ "$architectures" != "arm64" ]; then | |
| echo "Expected arm64-only Mach-O binary, got '$architectures': $binary" >&2 | |
| exit 1 | |
| fi | |
| done < <(find output/result -type f \( -name '*.dylib' -o -name '*.so' \) -print) | |
| if [ "$found_binary" -eq 0 ]; then | |
| echo 'No macOS dynamic libraries were collected.' >&2 | |
| exit 1 | |
| fi | |
| if [ ! -f output/result/embedded/stub/LuaSF.d.lua ]; then | |
| echo 'The embedded result does not contain the LuaSF stub.' >&2 | |
| exit 1 | |
| fi | |
| - name: Pack distributable archives | |
| shell: sh | |
| run: sh pack_result.sh | |
| - name: Verify macOS packages | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| expected_packages=( | |
| "output/packages/LuaSF-source${{ matrix.variant_suffix }}.tar.gz" | |
| "output/packages/LuaSF-embedded${{ matrix.variant_suffix }}-macOS-ARM64-clang.tar.gz" | |
| ) | |
| for package in "${expected_packages[@]}"; do | |
| if [ ! -f "$package" ]; then | |
| echo "Missing package: $package" >&2 | |
| exit 1 | |
| fi | |
| done | |
| actual_count=$(find output/packages -mindepth 1 -maxdepth 1 -type f -print | wc -l | tr -d '[:space:]') | |
| if [ "$actual_count" -ne "${#expected_packages[@]}" ]; then | |
| echo "Expected ${#expected_packages[@]} packages, found $actual_count:" >&2 | |
| find output/packages -mindepth 1 -maxdepth 1 -type f -printf '%f\n' | sort >&2 | |
| exit 1 | |
| fi | |
| - name: Upload macOS packages | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: LuaSF${{ matrix.variant_suffix }}-macOS-AppleSilicon-arm64 | |
| path: output/packages/*.tar.gz | |
| if-no-files-found: error | |
| compression-level: 0 |