Skip to content

Commit

Permalink
Add github action & remove openal
Browse files Browse the repository at this point in the history
  • Loading branch information
anchpop committed Aug 16, 2024
1 parent 6313711 commit a6d928d
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 164 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Release SpaceBoom

on:
release:
types: [created]

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
output_name: SpaceBoom-linux
- os: macos-latest
output_name: SpaceBoom-macos
- os: windows-latest
output_name: SpaceBoom-windows.exe

steps:
- uses: actions/checkout@v2

- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build libgl1-mesa-dev libglew-dev libglfw3-dev
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install cmake ninja glew glfw3
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install cmake ninja
- name: Configure CMake
run: |
mkdir build
cd build
cmake -GNinja ..
- name: Build
run: |
cd build
ninja
- name: Prepare release package
run: |
mkdir release
cp build/OpenGL/OpenGL release/${{ matrix.output_name }}
cp -r OpenGL/res release/res
- name: Create release artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.output_name }}
path: release

upload:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v2

- name: Create release archives
run: |
for dir in */; do
zip -r "${dir%/}.zip" "$dir"
done
- name: Upload release assets
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
const release = await github.rest.repos.getReleaseByTag({
owner,
repo,
tag: process.env.GITHUB_REF.replace('refs/tags/', '')
});
const assets = await fs.readdir('.');
for (const asset of assets) {
if (asset.endsWith('.zip')) {
await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id: release.data.id,
name: asset,
data: await fs.readFile(asset)
});
}
}
42 changes: 33 additions & 9 deletions OpenGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,43 @@ file(GLOB_RECURSE header_files "src/*.h")
find_package(OpenGL REQUIRED)

## GLFW
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLFW REQUIRED glfw3)

## OpenAL
find_package(OpenAL REQUIRED)
if(WIN32)
set(GLFW_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/OpenGL/Dependencies/GLFW/include")
set(GLFW_LIBRARY "${CMAKE_SOURCE_DIR}/OpenGL/Dependencies/GLFW/lib-vc2022")
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLFW REQUIRED glfw3)
endif()

## GLEW
find_package(GLEW REQUIRED)
if(WIN32)
set(GLEW_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/OpenGL/Dependencies/GLEW/include")
set(GLEW_LIBRARY "${CMAKE_SOURCE_DIR}/OpenGL/Dependencies/GLEW/lib/Release/x64/glew32s.lib")
else()
find_package(GLEW REQUIRED)
endif()

add_executable(${PROJECT_NAME} ${cpp_files} ${header_files})

target_include_directories(${PROJECT_NAME} PRIVATE ${OPENAL_INCLUDE_DIR} ${GlFW_INCLUDE_DIRS} ${GlEW_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS} Dependencies/OpenAL/include)

target_link_libraries(${PROJECT_NAME} -L${GLFW_LIBDIR} ${GLFW_LIBRARIES} GLEW::GLEW ${OPENGL_LIBRARIES} ${OPENAL_LIBRARY})
target_include_directories(${PROJECT_NAME} PRIVATE
${GLFW_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${OPENGL_INCLUDE_DIRS}
)

if(WIN32)
target_link_libraries(${PROJECT_NAME}
${GLFW_LIBRARY}
${GLEW_LIBRARY}
${OPENGL_LIBRARIES}
)
target_compile_definitions(${PROJECT_NAME} PRIVATE GLEW_STATIC)
else()
target_link_libraries(${PROJECT_NAME}
-L${GLFW_LIBDIR} ${GLFW_LIBRARIES}
GLEW::GLEW
${OPENGL_LIBRARIES}
)
endif()

set_property(TARGET ${PROJECT_NAME} PROPERTY PUBLIC_HEADER ${header_files})
154 changes: 0 additions & 154 deletions OpenGL/diff.txt

This file was deleted.

1 change: 0 additions & 1 deletion OpenGL/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ int main(void) {
glfwPollEvents();
}

// cleanupOpenAL();
glfwTerminate();
return 0;
}
2 changes: 2 additions & 0 deletions OpenGL/src/game_objects/Player.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <cmath>

#include "Player.h"
#include "../Input.h"
#include "Camera.h"
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ to run:
```
cd ../OpenGL
../build/OpenGL/OpenGL
```

to package:
1. You need one folder with the contents of OpenGL/res/* and the built binary to sit next to one another.

0 comments on commit a6d928d

Please sign in to comment.