Skip to content

Commit 7089bdc

Browse files
committed
Add initial GitHub CI
1 parent f78d22a commit 7089bdc

3 files changed

Lines changed: 176 additions & 0 deletions

File tree

.github/workflows/cibuild.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
build:
12+
name: Linux Native Release
13+
14+
runs-on: ubuntu-latest
15+
16+
defaults:
17+
run:
18+
shell: bash
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
25+
- name: Set reusable strings
26+
run: |
27+
preset_name=linux-release
28+
workspace_dir=${{ github.workspace }}
29+
source_dir=${workspace_dir}
30+
build_dir=${workspace_dir}/build/$preset_name
31+
install_dir=$build_dir/install
32+
echo "source_dir=$source_dir" >> "$GITHUB_ENV"
33+
echo "build_dir=$build_dir" >> "$GITHUB_ENV"
34+
echo "install_dir=$install_dir" >> "$GITHUB_ENV"
35+
echo "preset_name=$preset_name" >> "$GITHUB_ENV"
36+
37+
- name: Install packages
38+
run: |
39+
sudo apt update
40+
sudo apt install libelf-dev ninja-build -y
41+
42+
- name: Git fetch tags
43+
run: git fetch origin --tags
44+
45+
# Build
46+
47+
- name: CMake configure build
48+
working-directory: ${{ env.source_dir }}
49+
run: >
50+
cmake
51+
--preset ${{ env.preset_name }}
52+
-DCMAKE_INSTALL_PREFIX=${{ env.install_dir }}
53+
54+
- name: CMake build
55+
working-directory: ${{ env.source_dir }}
56+
run: cmake --build --preset ${{ env.preset_name }} --parallel --verbose
57+
58+
- name: Install executable
59+
run: cmake --install ${{ env.build_dir }}
60+
61+
# Artifacts
62+
63+
- name: Upload libraries
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: gamedata-gen
67+
path: ${{ env.install_dir }}/bin/gamedata-gen
68+
69+
# upload-latest-build:
70+
# name: Upload Latest Build
71+
#
72+
# needs: [build, pack-resources]
73+
# runs-on: ubuntu-latest
74+
# if: github.ref == 'refs/heads/master'
75+
# permissions:
76+
# contents: write
77+
#
78+
# steps:
79+
# - name: Download all artifacts
80+
# uses: actions/download-artifact@v4
81+
#
82+
# - name: Packing artifacts
83+
# run: 'parallel 7z a -tzip -mx=9 "{}.zip" "./{}/*" ::: *'
84+
#
85+
# - name: Create & upload latest build
86+
# env:
87+
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
# REPO_INFO: ${{ github.repository }}
89+
# run: |
90+
# # Delete old "latest" (delete step always returns true so that even if there's no release, it still uploads)
91+
# gh release delete latest --cleanup-tag --yes --repo "$REPO_INFO" || true
92+
# # Create new "latest"
93+
# gh release create latest *.zip --prerelease --title "Latest Master Build" --repo "$REPO_INFO"
94+
#
95+
# upload-release:
96+
# name: Upload Release
97+
#
98+
# needs: [build, pack-resources]
99+
# runs-on: ubuntu-latest
100+
# if: github.event_name == 'release' && github.event.action == 'published'
101+
# permissions:
102+
# contents: write
103+
#
104+
# steps:
105+
# - name: Download all artifacts
106+
# uses: actions/download-artifact@v4
107+
#
108+
# # TODO remove?
109+
# - name: Deleting every debug artifact
110+
# run: 'rm -r *-Debug'
111+
#
112+
# - name: Packing artifacts
113+
# run: 'parallel 7z a -tzip -mx=9 "{= s/neo-(.*)/neo-$GITHUB_REF_NAME-\1.zip/ =}" "./{}/*" ::: *' # TODO fix this command
114+
#
115+
# - name: Upload assets to a release
116+
# env:
117+
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118+
# REPO_INFO: ${{ github.repository }}
119+
# run: 'gh release upload "$GITHUB_REF_NAME" *.zip --clobber --repo "$REPO_INFO"'

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ target_link_libraries(gamedata-gen
3131
PkgConfig::libelf
3232
CLI11::CLI11
3333
)
34+
35+
install(
36+
TARGETS gamedata-gen
37+
)

CMakePresets.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"version": 3,
3+
"configurePresets": [
4+
{
5+
"name": "base",
6+
"hidden": true,
7+
"generator": "Ninja",
8+
"binaryDir": "${sourceDir}/build/${presetName}"
9+
},
10+
{
11+
"name": "linux",
12+
"hidden": true,
13+
"inherits": "base",
14+
"cacheVariables": {
15+
"CMAKE_C_COMPILER": "gcc",
16+
"CMAKE_CXX_COMPILER": "g++"
17+
},
18+
"condition": {
19+
"type": "equals",
20+
"lhs": "${hostSystemName}",
21+
"rhs": "Linux"
22+
}
23+
},
24+
{
25+
"name": "linux-debug",
26+
"displayName": "Linux Debug",
27+
"inherits": "linux",
28+
"cacheVariables": {
29+
"CMAKE_BUILD_TYPE": "Debug"
30+
}
31+
},
32+
{
33+
"name": "linux-release",
34+
"displayName": "Linux Release",
35+
"inherits": "linux",
36+
"cacheVariables": {
37+
"CMAKE_BUILD_TYPE": "Release"
38+
}
39+
}
40+
],
41+
"buildPresets": [
42+
{
43+
"name": "linux-debug",
44+
"displayName": "Linux Debug",
45+
"configurePreset": "linux-debug"
46+
},
47+
{
48+
"name": "linux-release",
49+
"displayName": "Linux Release",
50+
"configurePreset": "linux-release"
51+
}
52+
]
53+
}

0 commit comments

Comments
 (0)