Skip to content

Commit 57c8f6c

Browse files
committed
Add ubuntu build working pipeline
1 parent b620233 commit 57c8f6c

7 files changed

Lines changed: 87 additions & 56 deletions

File tree

.github/workflows/linux-build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Ubuntu gcc Build & Package
2+
on:
3+
push: { branches: [ main, master ], tags: [ 'v*' ] }
4+
pull_request:
5+
jobs:
6+
build-ubuntu:
7+
runs-on: ubuntu-latest
8+
env:
9+
BUILD_TYPE: Release
10+
BUILD_DIR: build-ubuntu-x64
11+
OUTPUT_DIR: ${{ github.workspace }}/build-ubuntu-x64
12+
steps:
13+
- uses: actions/checkout@v4
14+
with: { fetch-depth: 0 }
15+
- name: Install system deps
16+
run: |
17+
sudo apt-get update
18+
sudo apt-get install -y \
19+
build-essential cmake zip \
20+
libx11-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev \
21+
libgl1-mesa-dev libudev-dev \
22+
libopenal-dev libvorbis-dev libflac-dev \
23+
freeglut3-dev
24+
- name: Clean build dir
25+
run: rm -rf "$BUILD_DIR"
26+
- uses: actions/cache@v4
27+
with:
28+
path: ${{ env.BUILD_DIR }}/_deps
29+
key: ${{ runner.os }}-gcc-${{ env.BUILD_TYPE }}-cmake-deps-${{ hashFiles('cmake/**', '**/CMakeLists.txt') }}
30+
- name: Configure (CMake, gcc)
31+
run: cmake -S . -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE="$BUILD_TYPE"
32+
- name: Build
33+
run: cmake --build "$BUILD_DIR" --config "$BUILD_TYPE" --parallel
34+
- name: Verify outputs
35+
run: |
36+
[ -f "$OUTPUT_DIR/SuperMario" ] || (echo "bin missing" && exit 1)
37+
[ -d "$OUTPUT_DIR/res" ] || (echo "res missing" && exit 1)
38+
- name: Package zip (Linux)
39+
run: |
40+
ZIP="SuperMario-linux-x64-${BUILD_TYPE}.zip"
41+
rm -f "$ZIP"
42+
zip -r "$ZIP" "$OUTPUT_DIR/SuperMario" "$OUTPUT_DIR/res"
43+
- uses: actions/upload-artifact@v4
44+
with:
45+
name: SuperMario-linux-x64-${{ env.BUILD_TYPE }}
46+
path: SuperMario-linux-x64-${{ env.BUILD_TYPE }}.zip
47+
if-no-files-found: error
48+
- name: Upload to GitHub Release (on tag)
49+
if: startsWith(github.ref, 'refs/tags/v')
50+
uses: softprops/action-gh-release@v2
51+
with:
52+
files: SuperMario-linux-x64-${{ env.BUILD_TYPE }}.zip
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/win64-build.yml

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,60 @@
11
name: Windows x64 Build & Package
2-
32
on:
4-
push:
5-
branches: [ main, master ]
6-
tags: [ 'v*' ]
3+
push: { branches: [ main, master ], tags: [ 'v*' ] }
74
pull_request:
8-
95
jobs:
10-
build:
6+
build-windows:
117
runs-on: windows-latest
12-
138
env:
149
BUILD_TYPE: Release
1510
OUTPUT_DIR: Build
1611
ARCH: x64
17-
BUILD_DIR: build-x64 # per-arch build directory
18-
12+
BUILD_DIR: build-x64
1913
steps:
20-
- name: Checkout
21-
uses: actions/checkout@v4
22-
with:
23-
fetch-depth: 0
24-
25-
- name: Show toolchain versions
14+
- uses: actions/checkout@v4
15+
with: { fetch-depth: 0 }
16+
- name: Toolchain info
2617
shell: pwsh
2718
run: |
2819
cmake --version
2920
ninja --version || echo "Ninja not used (VS generator expected)"
30-
31-
# Ensure a clean build dir to avoid generator/platform mismatch
32-
- name: Clean build dir (if exists)
21+
- name: Clean build dir
3322
shell: pwsh
3423
run: |
3524
if (Test-Path $env:BUILD_DIR) { Remove-Item -Recurse -Force $env:BUILD_DIR }
36-
37-
# Cache only the per-arch _deps to avoid re-downloading SFML/tinyxml2
38-
- name: Cache CMake deps
39-
uses: actions/cache@v4
25+
- uses: actions/cache@v4
4026
with:
41-
path: |
42-
${{ env.BUILD_DIR }}/_deps
27+
path: ${{ env.BUILD_DIR }}/_deps
4328
key: ${{ runner.os }}-${{ env.ARCH }}-${{ env.BUILD_TYPE }}-cmake-deps-${{ hashFiles('cmake/**', '**/CMakeLists.txt') }}
44-
4529
- name: Configure (CMake, x64)
4630
shell: pwsh
4731
run: >
48-
cmake -S . -B $env:BUILD_DIR
49-
-A $env:ARCH
50-
-DCMAKE_BUILD_TYPE=$env:BUILD_TYPE
51-
32+
cmake -S . -B $env:BUILD_DIR -A $env:ARCH -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE
5233
- name: Build
5334
shell: pwsh
5435
run: cmake --build $env:BUILD_DIR --config $env:BUILD_TYPE --parallel
55-
56-
# Validate outputs: only the exe and res/ are required
5736
- name: Verify outputs
5837
shell: pwsh
5938
run: |
6039
$binDir = Join-Path $PWD $env:OUTPUT_DIR
61-
$exe = Join-Path $binDir "SuperMario.exe"
62-
$res = Join-Path $binDir "res"
63-
if (-not (Test-Path $exe)) { throw "SuperMario.exe not found at $exe" }
64-
if (-not (Test-Path $res)) { throw "res folder not found at $res" }
65-
Write-Host "Artifacts OK: $exe and $res"
66-
67-
- name: Package zip (exe + res/)
40+
if (-not (Test-Path (Join-Path $binDir "SuperMario.exe"))) { throw "exe missing" }
41+
if (-not (Test-Path (Join-Path $binDir "res"))) { throw "res missing" }
42+
- name: Package zip (Windows)
6843
shell: pwsh
6944
run: |
7045
$binDir = Join-Path $PWD $env:OUTPUT_DIR
71-
$exe = Join-Path $binDir "SuperMario.exe"
72-
$res = Join-Path $binDir "res"
73-
$zipName = "SuperMario-x64-${{ env.BUILD_TYPE }}.zip"
74-
if (Test-Path $zipName) { Remove-Item $zipName -Force }
75-
Compress-Archive -Path $exe, $res -DestinationPath $zipName
76-
Write-Host "Created $zipName"
77-
78-
- name: Upload artifact
79-
uses: actions/upload-artifact@v4
46+
$zip = "SuperMario-windows-x64-${{ env.BUILD_TYPE }}.zip"
47+
if (Test-Path $zip) { Remove-Item $zip -Force }
48+
Compress-Archive -Path (Join-Path $binDir "SuperMario.exe"), (Join-Path $binDir "res") -DestinationPath $zip
49+
- uses: actions/upload-artifact@v4
8050
with:
81-
name: SuperMario-x64-${{ env.BUILD_TYPE }}
82-
path: SuperMario-x64-${{ env.BUILD_TYPE }}.zip
51+
name: SuperMario-windows-x64-${{ env.BUILD_TYPE }}
52+
path: SuperMario-windows-x64-${{ env.BUILD_TYPE }}.zip
8353
if-no-files-found: error
84-
8554
- name: Upload to GitHub Release (on tag)
8655
if: startsWith(github.ref, 'refs/tags/v')
8756
uses: softprops/action-gh-release@v2
8857
with:
89-
files: SuperMario-x64-${{ env.BUILD_TYPE }}.zip
58+
files: SuperMario-windows-x64-${{ env.BUILD_TYPE }}.zip
9059
env:
9160
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ target_link_libraries(SuperMario
107107
)
108108

109109
if (UNIX AND NOT APPLE)
110-
target_link_libraries(SuperMario stdc++ m pthread)
110+
target_link_libraries(SuperMario
111+
PRIVATE
112+
m
113+
pthread)
111114
endif()
112115

113116
add_custom_command(TARGET SuperMario POST_BUILD

build.sh

100644100755
File mode changed.

readme.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# SuperMarioHD
2-
![Build](https://github.com/PfAndrey/SuperMarioHD/actions/workflows/win64-build.yml/badge.svg)
2+
![Windows x64](https://img.shields.io/github/actions/workflow/status/PfAndrey/SuperMarioHD/win64-build.yml?branch=master&label=windows%20x64&logo=windows&logoColor=white)
3+
![Ubuntu gcc](https://img.shields.io/github/actions/workflow/status/PfAndrey/SuperMarioHD/linux-build.yml?branch=master&label=ubuntu%20gcc&logo=ubuntu&logoColor=white)
34
![Latest Tag](https://img.shields.io/github/v/tag/PfAndrey/SuperMarioHD?display_name=tag)
45
![MARIO logo](https://github.com/PfAndrey/supermariohd/blob/master/res/Screen.jpg?raw=true)
5-
Cross-platform HD remake of Super Mario Bros. (NES, 1985).
6-
Project was created for learning purposes only.
6+
Cross-platform HD remake of Super Mario Bros. (NES, 1985).
7+
Project was created for learning purposes only.
78
The game demo on the YouTube: https://youtu.be/RJ181cc_AMI
89

910
## Windows

source/enemies/Koopa.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#include "SuperMarioGame.hpp"
1+
#include <cmath>
2+
3+
#include "SuperMarioGame.hpp"
24
#include "Koopa.hpp"
35

46
struct StateActions {

source/enemies/Lakity.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <cmath>
2+
13
#include "SuperMarioGame.hpp"
24
#include "Lakity.hpp"
35

0 commit comments

Comments
 (0)