Skip to content

cp

cp #150

Workflow file for this run

name: '🏦 Build'
env:
VERSION: 0.0.0
PACKAGE_SUFFIX: '-pre.42'
# PACKAGE_SUFFIX: ''
ASM_VERSION: 0.0.0
BUILD_TYPE: Release
VCPKG_HASH: f8be6942c0c5abd48bb325726d57af9ac39e251d
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
jobs:
# builds native binary for all supported OSes
build-native:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
name: Windows x64
arch: x64
vcpkg_triplet: x64-windows-static
vcpkg_config: Release
dotnet_rid: win-x64
- os: ubuntu-latest
name: Linux x64
arch: x64
vcpkg_triplet: x64-linux
vcpkg_config: MinSizeRel
dotnet_rid: linux-x64
fail-fast: false
name: 'build: ${{ matrix.name }}'
env:
VCPKG_DEFAULT_VCPKG_TRIPLET: ${{ matrix.vcpkg_triplet }}
VCPKG_TRIPLET: ${{ matrix.vcpkg_triplet }}
VCPKG_CONFIG: ${{ matrix.vcpkg_config }}
DOTNET_RID: ${{ matrix.dotnet_rid }}
CMAKE_OPTIONS: ${{ matrix.cmake_options }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Linux GLFW depdendencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get --yes install libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev pkg-config
- uses: friendlyanon/setup-vcpkg@v1
# seems like the absense of commit hash expects vcpkg submodule, i don't want that
with:
committish: ${{ env.VCPKG_HASH }}
# set to false to clear any cache in case of build errors
cache: false
- name: configure
run: cmake -B build -S . -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" -D "VCPKG_TARGET_TRIPLET=${{ env.VCPKG_TRIPLET }}" ${{ env.CMAKE_OPTIONS }}
working-directory: .
- name: build
run: cmake --build build --config ${{ env.VCPKG_CONFIG }}
working-directory: .
- name: debug
run: ls -R
working-directory: .
- uses: actions/upload-artifact@v4
name: Collect Artifacts
with:
name: native-${{ matrix.dotnet_rid }}
path: |
xbin/**/*
if-no-files-found: error
# create a unified fat native binary
make-fat-native:
runs-on: ubuntu-latest
needs: build-native
name: '🎡 fat artifact'
steps:
- uses: actions/download-artifact@v4
with:
pattern: native-*
path: xbin/
merge-multiple: true
- name: debug
run: ls -R
working-directory: .
- uses: actions/upload-artifact@v4
name: Collect Artifacts
with:
name: native-fat
compression-level: 9
if-no-files-found: error
path: |
xbin/**/*
build-managed:
needs: make-fat-native
runs-on: ubuntu-latest
name: 'Build managed + nuget'
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: native-fat
path: xbin/
- name: debug
run: ls -R
working-directory: .
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
10.0.x
- name: Build
run: dotnet build dotnet/Grey.sln -c release /p:Version=${{ env.VERSION }}${{ env.PACKAGE_SUFFIX }} /p:FileVersion=$VERSION /p:AssemblyVersion=$ASM_VERSION
- name: version
run: echo $VERSION >> docs/version.txt
- name: 🔢 prep release notes
run: |
grep -m 2 -B 1000 '^## ' docs/release-notes.md | tail -n +3 | head -n -2 > docs/version-notes.md
cat docs/version-notes.md
- uses: actions/upload-artifact@v4
name: Collect Artifacts
with:
name: dotnet
compression-level: 9
if-no-files-found: error
path: |
dotnet/Grey/bin/Release/**/*nupkg
docs/release-notes.md
docs/version-notes.md
docs/version.txt
build-demo-apps:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
name: Windows x64
arch: x64
vcpkg_triplet: x64-windows-static
vcpkg_config: Release
dotnet_rid: win-x64
- os: ubuntu-latest
name: Linux x64
arch: x64
vcpkg_triplet: x64-linux
vcpkg_config: MinSizeRel
dotnet_rid: linux-x64
fail-fast: false
name: 'demo app: ${{ matrix.name }}'
needs:
- make-fat-native
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/download-artifact@v4
with:
name: native-fat
path: xbin/
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
10.0.x
- name: Publish
run: dotnet publish dotnet/ConsoleDemo/ -r ${{ matrix.dotnet_rid }} --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:IncludeNativeLibrariesForSelfExtract=true
- name: Setup screenshot tools (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y xvfb scrot mesa-utils libgl1-mesa-dri libegl1 libglu1-mesa xterm
- name: Run app and capture screenshot (Linux)
if: runner.os == 'Linux'
run: |
# Start Xvfb with GLX extension
Xvfb :99 -screen 0 1920x1080x24 +extension GLX +render -noreset &
export DISPLAY=:99
# Use software rendering
export LIBGL_ALWAYS_SOFTWARE=1
export MESA_GL_VERSION_OVERRIDE=3.3
# Wait for Xvfb to be ready
sleep 2
# Verify display is working
glxinfo | head -20 || echo "GLX not available"
# Start xterm (optional, for debugging)
xterm &
# Run the app in background
chmod +x dotnet/ConsoleDemo/bin/Release/net10.0/${{ matrix.dotnet_rid }}/publish/ConsoleDemo
dotnet/ConsoleDemo/bin/Release/net10.0/${{ matrix.dotnet_rid }}/publish/ConsoleDemo 2>&1 | tee app.log &
APP_PID=$!
# Wait for app to render
sleep 5
# Capture screenshot
mkdir -p screenshots
scrot screenshots/demo-${{ matrix.dotnet_rid }}.png
# Show app logs
cat app.log || true
# Kill the app
kill $APP_PID || true
- name: Run app and capture screenshot (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# Start the app in background
$app = Start-Process -FilePath "dotnet\ConsoleDemo\bin\Release\net10.0\${{ matrix.dotnet_rid }}\publish\ConsoleDemo.exe" -PassThru
# Wait for app to render
Start-Sleep -Seconds 5
# Capture screenshot using PowerShell
New-Item -ItemType Directory -Force -Path screenshots
Add-Type -AssemblyName System.Windows.Forms,System.Drawing
$screens = [System.Windows.Forms.Screen]::AllScreens
$bounds = $screens[0].Bounds
$bitmap = New-Object System.Drawing.Bitmap $bounds.Width, $bounds.Height
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
$graphics.CopyFromScreen($bounds.Location, [System.Drawing.Point]::Empty, $bounds.Size)
$bitmap.Save("screenshots\demo-${{ matrix.dotnet_rid }}.png", [System.Drawing.Imaging.ImageFormat]::Png)
$graphics.Dispose()
$bitmap.Dispose()
# Kill the app
Stop-Process -Id $app.Id -Force -ErrorAction SilentlyContinue
- name: Flatten files for artifact upload
shell: bash
run: |
mkdir -p flat-output
# Copy published binaries
find dotnet/ConsoleDemo/bin/Release/net10.0/${{ matrix.dotnet_rid }}/publish/ -type f -exec cp {} flat-output/ \;
# Copy screenshots if they exist
find screenshots/ -type f -exec cp {} flat-output/ \; 2>/dev/null || true
ls -la flat-output/
- uses: actions/upload-artifact@v4
name: Collect Artifacts
with:
name: dotnet-demo-${{ matrix.dotnet_rid }}
compression-level: 9
if-no-files-found: error
path: flat-output/
release:
name: '🕋 Release library'
runs-on: ubuntu-latest
needs:
- build-managed
if: github.ref == 'refs/heads/master'
steps:
- name: ⬇️ Download Library binaries
uses: actions/download-artifact@v4
with:
name: dotnet
path: dotnet
- name: debug
run: ls -R
working-directory: .
- name: print release notes
run: cat dotnet/docs/release-notes.md
- name: 📦 Publish to NuGet
run: dotnet nuget push dotnet/dotnet/Grey/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate