Update GitHub Actions workflow for improved CMake configuration and packaging
- Changed the vcpkg Git commit ID to a specific version for consistency in builds. - Refactored the CMake configuration steps to use PowerShell syntax, enhancing readability and maintainability. - Improved the packaging process for Windows, macOS, and Linux by utilizing PowerShell commands and ensuring proper handling of binaries, assets, and documentation. - Added checks for the existence of required files and directories, providing clearer error messages and improving the robustness of the workflow.
This commit is contained in:
220
.github/workflows/release.yml
vendored
220
.github/workflows/release.yml
vendored
@@ -172,7 +172,7 @@ jobs:
|
|||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
with:
|
with:
|
||||||
vcpkgGitCommitId: '4bee3f5aae7aefbc129ca81c33d6a062b02fcf3b'
|
vcpkgGitCommitId: '2024.01.12'
|
||||||
runVcpkgInstall: true
|
runVcpkgInstall: true
|
||||||
vcpkgJsonGlob: '**/vcpkg.json'
|
vcpkgJsonGlob: '**/vcpkg.json'
|
||||||
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
|
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
|
||||||
@@ -248,95 +248,93 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
Write-Host "Configuring CMake for Windows build..."
|
Write-Host "Configuring CMake for Windows build..."
|
||||||
Write-Host "Build type: ${{ env.BUILD_TYPE }}"
|
Write-Host "Build type: ${{ env.BUILD_TYPE }}"
|
||||||
Write-Host "YAZE_BUILD_TESTS will be set to OFF"
|
Write-Host "Platform: ${{ matrix.cmake_generator_platform }}"
|
||||||
|
|
||||||
# Check if vcpkg is available
|
# Build configuration parameters
|
||||||
|
$cmakeArgs = @(
|
||||||
|
"-B", "build",
|
||||||
|
"-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}",
|
||||||
|
"-DCMAKE_POLICY_VERSION_MINIMUM=3.16",
|
||||||
|
"-DYAZE_BUILD_TESTS=OFF",
|
||||||
|
"-DYAZE_BUILD_EMU=OFF",
|
||||||
|
"-DYAZE_ENABLE_ROM_TESTS=OFF",
|
||||||
|
"-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF",
|
||||||
|
"-DYAZE_INSTALL_LIB=OFF",
|
||||||
|
"-G", "${{ matrix.cmake_generator }}",
|
||||||
|
"-A", "${{ matrix.cmake_generator_platform }}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add vcpkg toolchain if available
|
||||||
if ((Test-Path "${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake") -and ($env:VCPKG_AVAILABLE -ne "false")) {
|
if ((Test-Path "${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake") -and ($env:VCPKG_AVAILABLE -ne "false")) {
|
||||||
Write-Host "Using vcpkg toolchain..."
|
Write-Host "Using vcpkg toolchain..."
|
||||||
cmake -B build `
|
$cmakeArgs += "-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||||
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} `
|
$cmakeArgs += "-DYAZE_MINIMAL_BUILD=OFF"
|
||||||
-DCMAKE_POLICY_VERSION_MINIMUM=3.16 `
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" `
|
|
||||||
-DYAZE_BUILD_TESTS=OFF `
|
|
||||||
-DYAZE_BUILD_EMU=OFF `
|
|
||||||
-DYAZE_ENABLE_ROM_TESTS=OFF `
|
|
||||||
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF `
|
|
||||||
-DYAZE_INSTALL_LIB=OFF `
|
|
||||||
-DYAZE_MINIMAL_BUILD=OFF `
|
|
||||||
-G "${{ matrix.cmake_generator }}" `
|
|
||||||
-A ${{ matrix.cmake_generator_platform }}
|
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Using minimal build configuration (vcpkg not available)..."
|
Write-Host "Using minimal build configuration (vcpkg not available)..."
|
||||||
cmake -B build `
|
$cmakeArgs += "-DYAZE_MINIMAL_BUILD=ON"
|
||||||
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} `
|
}
|
||||||
-DCMAKE_POLICY_VERSION_MINIMUM=3.16 `
|
|
||||||
-DYAZE_BUILD_TESTS=OFF `
|
# Run CMake configuration
|
||||||
-DYAZE_BUILD_EMU=OFF `
|
& cmake @cmakeArgs
|
||||||
-DYAZE_ENABLE_ROM_TESTS=OFF `
|
if ($LASTEXITCODE -ne 0) {
|
||||||
-DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF `
|
Write-Host "CMake configuration failed!"
|
||||||
-DYAZE_INSTALL_LIB=OFF `
|
exit 1
|
||||||
-DYAZE_MINIMAL_BUILD=ON `
|
|
||||||
-G "${{ matrix.cmake_generator }}" `
|
|
||||||
-A ${{ matrix.cmake_generator_platform }}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "CMake configuration completed successfully"
|
Write-Host "CMake configuration completed successfully"
|
||||||
|
|
||||||
# Verify the configuration
|
|
||||||
Write-Host "Verifying CMake configuration..."
|
|
||||||
Write-Host "Checking if test targets are present..."
|
|
||||||
cmake --build build --target help 2>&1 | findstr "yaze_test" || echo "yaze_test target not found (good!)"
|
|
||||||
Write-Host "Configuration verification completed"
|
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
- name: Build
|
- name: Build
|
||||||
shell: bash
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
echo "Building YAZE for ${{ matrix.name }}..."
|
Write-Host "Building YAZE for ${{ matrix.name }}..."
|
||||||
cmake --build build --config ${{ env.BUILD_TYPE }} --parallel
|
cmake --build build --config ${{ env.BUILD_TYPE }} --parallel
|
||||||
echo "Build completed successfully!"
|
Write-Host "Build completed successfully!"
|
||||||
|
|
||||||
# For Windows, also create a package using CMake's packaging system
|
# For Windows, also create a package using CMake's packaging system
|
||||||
if [[ "${{ runner.os }}" == "Windows" ]]; then
|
if ("${{ runner.os }}" -eq "Windows") {
|
||||||
echo "Creating Windows package using CMake..."
|
Write-Host "Creating Windows package using CMake..."
|
||||||
cmake --build build --config ${{ env.BUILD_TYPE }} --target package
|
cmake --build build --config ${{ env.BUILD_TYPE }} --target package
|
||||||
echo "CMake package created successfully!"
|
Write-Host "CMake package created successfully!"
|
||||||
fi
|
}
|
||||||
|
|
||||||
# Test executable functionality
|
# Test executable functionality
|
||||||
- name: Test executable functionality
|
- name: Test executable functionality
|
||||||
shell: bash
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
set -e
|
Write-Host "Testing executable for ${{ matrix.name }}..."
|
||||||
|
|
||||||
echo "Testing executable for ${{ matrix.name }}..."
|
|
||||||
|
|
||||||
# Determine executable path based on platform
|
# Determine executable path based on platform
|
||||||
if [[ "${{ runner.os }}" == "Windows" ]]; then
|
if ("${{ runner.os }}" -eq "Windows") {
|
||||||
exePath="build/bin/${{ env.BUILD_TYPE }}/yaze.exe"
|
$exePath = "build\bin\${{ env.BUILD_TYPE }}\yaze.exe"
|
||||||
elif [[ "${{ runner.os }}" == "macOS" ]]; then
|
} elseif ("${{ runner.os }}" -eq "macOS") {
|
||||||
exePath="build/bin/yaze.app/Contents/MacOS/yaze"
|
$exePath = "build/bin/yaze.app/Contents/MacOS/yaze"
|
||||||
else
|
} else {
|
||||||
exePath="build/bin/yaze"
|
$exePath = "build/bin/yaze"
|
||||||
fi
|
}
|
||||||
|
|
||||||
if [ -f "$exePath" ]; then
|
if (Test-Path $exePath) {
|
||||||
echo "✓ Executable found: $exePath"
|
Write-Host "✓ Executable found: $exePath"
|
||||||
|
|
||||||
# Test that it's not the test main
|
# Test that it's not the test main
|
||||||
testResult=$($exePath --help 2>&1 || true)
|
try {
|
||||||
exitCode=$?
|
$testResult = & $exePath --help 2>&1
|
||||||
|
$exitCode = $LASTEXITCODE
|
||||||
|
} catch {
|
||||||
|
$testResult = $_.Exception.Message
|
||||||
|
$exitCode = 1
|
||||||
|
}
|
||||||
|
|
||||||
if echo "$testResult" | grep -q "Google Test\|gtest"; then
|
if ($testResult -match "Google Test|gtest") {
|
||||||
echo "ERROR: Executable is running test main instead of app main!"
|
Write-Host "ERROR: Executable is running test main instead of app main!"
|
||||||
echo "Output: $testResult"
|
Write-Host "Output: $testResult"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
}
|
||||||
|
|
||||||
echo "✓ Executable runs correctly (exit code: $exitCode)"
|
Write-Host "✓ Executable runs correctly (exit code: $exitCode)"
|
||||||
|
|
||||||
# Display file info
|
# Display file info
|
||||||
if [[ "${{ runner.os }}" == "Windows" ]]; then
|
if ("${{ runner.os }}" -eq "Windows") {
|
||||||
fileSize=$(stat -c%s "$exePath" 2>/dev/null || echo "0")
|
fileSize=$(stat -c%s "$exePath" 2>/dev/null || echo "0")
|
||||||
else
|
else
|
||||||
fileSize=$(stat -f%z "$exePath" 2>/dev/null || stat -c%s "$exePath" 2>/dev/null || echo "0")
|
fileSize=$(stat -f%z "$exePath" 2>/dev/null || stat -c%s "$exePath" 2>/dev/null || echo "0")
|
||||||
@@ -350,78 +348,82 @@ jobs:
|
|||||||
|
|
||||||
# Package
|
# Package
|
||||||
- name: Package
|
- name: Package
|
||||||
shell: bash
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
echo "Packaging for ${{ matrix.name }}..."
|
Write-Host "Packaging for ${{ matrix.name }}..."
|
||||||
|
|
||||||
if [[ "${{ runner.os }}" == "Windows" ]]; then
|
if ("${{ runner.os }}" -eq "Windows") {
|
||||||
# Windows packaging - prefer CMake package if available
|
# Windows packaging - prefer CMake package if available
|
||||||
echo "Creating Windows package..."
|
Write-Host "Creating Windows package..."
|
||||||
|
|
||||||
# Check if CMake created a package
|
# Check if CMake created a package
|
||||||
if [ -f "build/yaze-*.zip" ]; then
|
$cmakePackages = Get-ChildItem "build" -Filter "yaze-*.zip" -ErrorAction SilentlyContinue
|
||||||
echo "Using CMake-generated package..."
|
if ($cmakePackages) {
|
||||||
cp build/yaze-*.zip ${{ matrix.artifact_name }}.zip
|
Write-Host "Using CMake-generated package..."
|
||||||
echo "CMake package copied successfully"
|
Copy-Item $cmakePackages[0].FullName "${{ matrix.artifact_name }}.zip"
|
||||||
else
|
Write-Host "CMake package copied successfully"
|
||||||
echo "CMake package not found, creating manual package..."
|
} else {
|
||||||
mkdir -p package
|
Write-Host "CMake package not found, creating manual package..."
|
||||||
|
New-Item -ItemType Directory -Path "package" -Force | Out-Null
|
||||||
|
|
||||||
# Copy main executable and DLLs
|
# Copy main executable and DLLs
|
||||||
echo "Copying binaries..."
|
Write-Host "Copying binaries..."
|
||||||
if [ -d "build/bin/${{ env.BUILD_TYPE }}" ]; then
|
$binPath = "build\bin\${{ env.BUILD_TYPE }}"
|
||||||
cp -r build/bin/${{ env.BUILD_TYPE }}/* package/
|
if (-not (Test-Path $binPath)) {
|
||||||
elif [ -d "build/bin/Debug" ]; then
|
$binPath = "build\bin\Debug"
|
||||||
cp -r build/bin/Debug/* package/
|
}
|
||||||
else
|
if (Test-Path $binPath) {
|
||||||
echo "ERROR: No binaries found in build/bin/"
|
Copy-Item "$binPath\*" "package\" -Recurse -Force
|
||||||
|
} else {
|
||||||
|
Write-Host "ERROR: No binaries found in build/bin/"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
}
|
||||||
|
|
||||||
# Copy assets
|
# Copy assets
|
||||||
echo "Copying assets..."
|
Write-Host "Copying assets..."
|
||||||
if [ -d "assets" ]; then
|
if (Test-Path "assets") {
|
||||||
cp -r assets package/
|
Copy-Item "assets" "package\" -Recurse -Force
|
||||||
else
|
} else {
|
||||||
echo "WARNING: assets directory not found"
|
Write-Host "WARNING: assets directory not found"
|
||||||
fi
|
}
|
||||||
|
|
||||||
# Copy documentation
|
# Copy documentation
|
||||||
echo "Copying documentation..."
|
Write-Host "Copying documentation..."
|
||||||
cp LICENSE package/ 2>/dev/null || echo "LICENSE not found"
|
if (Test-Path "LICENSE") { Copy-Item "LICENSE" "package\" }
|
||||||
cp README.md package/ 2>/dev/null || echo "README.md not found"
|
if (Test-Path "README.md") { Copy-Item "README.md" "package\" }
|
||||||
|
|
||||||
# Copy vcpkg DLLs if available (for Windows builds with vcpkg)
|
# Copy vcpkg DLLs if available (for Windows builds with vcpkg)
|
||||||
if [ -d "vcpkg/installed/${{ matrix.vcpkg_triplet }}/bin" ]; then
|
$vcpkgBinPath = "vcpkg\installed\${{ matrix.vcpkg_triplet }}\bin"
|
||||||
echo "Copying vcpkg DLLs..."
|
if (Test-Path $vcpkgBinPath) {
|
||||||
cp vcpkg/installed/${{ matrix.vcpkg_triplet }}/bin/*.dll package/ 2>/dev/null || echo "No vcpkg DLLs found"
|
Write-Host "Copying vcpkg DLLs..."
|
||||||
fi
|
Copy-Item "$vcpkgBinPath\*.dll" "package\" -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
# List package contents for verification
|
# List package contents for verification
|
||||||
echo "Package contents:"
|
Write-Host "Package contents:"
|
||||||
ls -la package/
|
Get-ChildItem "package" -Recurse
|
||||||
|
|
||||||
# Use PowerShell Compress-Archive for Windows
|
# Use PowerShell Compress-Archive for Windows
|
||||||
powershell -Command "Compress-Archive -Path 'package\*' -DestinationPath '${{ matrix.artifact_name }}.zip' -Force"
|
Compress-Archive -Path "package\*" -DestinationPath "${{ matrix.artifact_name }}.zip" -Force
|
||||||
fi
|
}
|
||||||
|
|
||||||
elif [[ "${{ runner.os }}" == "macOS" ]]; then
|
} elseif ("${{ runner.os }}" -eq "macOS") {
|
||||||
# macOS packaging using dedicated script
|
# macOS packaging using dedicated script
|
||||||
VERSION_NUM=$(echo "${{ needs.validate-and-prepare.outputs.tag_name }}" | sed 's/^v//')
|
$versionNum = "${{ needs.validate-and-prepare.outputs.tag_name }}" -replace "^v", ""
|
||||||
./scripts/create-macos-bundle.sh "$VERSION_NUM" "${{ matrix.artifact_name }}"
|
& ./scripts/create-macos-bundle.sh $versionNum "${{ matrix.artifact_name }}"
|
||||||
|
|
||||||
else
|
} else {
|
||||||
# Linux packaging
|
# Linux packaging
|
||||||
mkdir package
|
New-Item -ItemType Directory -Path "package" -Force | Out-Null
|
||||||
cp build/bin/yaze package/
|
Copy-Item "build/bin/yaze" "package/"
|
||||||
cp -r assets package/ 2>/dev/null || echo "assets directory not found"
|
if (Test-Path "assets") { Copy-Item "assets" "package/" -Recurse }
|
||||||
cp -r docs package/ 2>/dev/null || echo "docs directory not found"
|
if (Test-Path "docs") { Copy-Item "docs" "package/" -Recurse }
|
||||||
cp LICENSE package/ 2>/dev/null || echo "LICENSE not found"
|
if (Test-Path "LICENSE") { Copy-Item "LICENSE" "package/" }
|
||||||
cp README.md package/ 2>/dev/null || echo "README.md not found"
|
if (Test-Path "README.md") { Copy-Item "README.md" "package/" }
|
||||||
tar -czf ${{ matrix.artifact_name }}.tar.gz -C package .
|
& tar -czf "${{ matrix.artifact_name }}.tar.gz" -C package .
|
||||||
fi
|
}
|
||||||
|
|
||||||
echo "Packaging completed successfully!"
|
Write-Host "Packaging completed successfully!"
|
||||||
|
|
||||||
# Create release with artifacts
|
# Create release with artifacts
|
||||||
- name: Upload to Release
|
- name: Upload to Release
|
||||||
|
|||||||
Reference in New Issue
Block a user