Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Build

on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]
workflow_dispatch: {}

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: ubuntu-latest
triplet: x64-linux
artifact_name: black-hole-linux-x64
- os: windows-latest
triplet: x64-windows
artifact_name: black-hole-windows-x64

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set vcpkg path (Linux)
if: runner.os == 'Linux'
run: echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> "$GITHUB_ENV"

- name: Set vcpkg path (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" >> $env:GITHUB_ENV

- name: Install Linux native deps (X11/OpenGL/GLU headers for GLFW/GLEW)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libgl1-mesa-dev \
libglu1-mesa-dev \
libx11-dev \
libxrandr-dev \
libxinerama-dev \
libxcursor-dev \
libxi-dev \
libxext-dev \
pkg-config

- name: Cache vcpkg packages
uses: actions/cache@v4
with:
path: |
${{ env.VCPKG_ROOT }}/installed
~/.cache/vcpkg/archives
${{ runner.os == 'Windows' && '%LOCALAPPDATA%\\vcpkg\\archives' || '' }}
key: vcpkg-${{ matrix.triplet }}-${{ hashFiles('vcpkg.json') }}
restore-keys: |
vcpkg-${{ matrix.triplet }}-

- name: Install dependencies via vcpkg manifest
run: |
"${{ env.VCPKG_ROOT }}/vcpkg" install --triplet ${{ matrix.triplet }}
shell: bash

- name: Configure CMake
run: |
cmake -B build -S . \
-DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \
-DCMAKE_BUILD_TYPE=Release
shell: bash

- name: Build
run: cmake --build build --config Release --parallel

- name: Stage release artifact
shell: bash
run: |
mkdir -p staging
if [ -d "build/Release" ]; then
cp -r build/Release/. staging/
else
find build -maxdepth 1 -type f -executable -exec cp {} staging/ \;
cp build/*.vert build/*.frag build/*.comp staging/ 2>/dev/null || true
fi
cp README.md staging/ 2>/dev/null || true
ls -la staging

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: staging/
if-no-files-found: error

release:
name: Publish GitHub Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Zip each platform artifact
run: |
cd artifacts
for dir in */; do
name="${dir%/}"
(cd "$name" && zip -r "../${name}.zip" .)
done
ls -la

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*.zip
generate_release_notes: true
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ project(BlackHoleSim)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (MSVC)
add_compile_options(/utf-8)
endif()
# Dependencies
find_package(GLEW REQUIRED)
find_package(glfw3 CONFIG REQUIRED)
Expand Down
Loading