Skip to content

Commit c138e9e

Browse files
committed
CI: Update scripts
1 parent 920d6f2 commit c138e9e

9 files changed

Lines changed: 97 additions & 600 deletions

File tree

.github/workflows/ci.yml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,50 @@ jobs:
1313
build:
1414
strategy:
1515
matrix:
16-
runs-on: [windows-2019, ubuntu-20.04]
16+
os:
17+
- runs-on: windows-2022
18+
suffix: ci-windows
19+
- runs-on: ubuntu-22.04
20+
suffix: ci-linux
1721

1822
# The type of runner that the job will run on
19-
runs-on: ${{ matrix.runs-on }}
23+
runs-on: ${{ matrix.os.runs-on }}
2024

2125
# Steps represent a sequence of tasks that will be executed as part of the job
2226
steps:
2327
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2428
- uses: actions/checkout@v3.3.0
2529
with:
2630
submodules: recursive
27-
28-
- name: Set up Python 3.8
29-
uses: actions/setup-python@v4.5.0
30-
with:
31-
python-version: 3.8
32-
31+
fetch-depth: 0 # Required for automatic versioning
32+
3333
- name: Install Ubuntu packages
34-
if: matrix.runs-on == 'ubuntu-20.04'
34+
if: matrix.os.runs-on == 'ubuntu-22.04'
3535
run: |
3636
sudo dpkg --add-architecture i386
3737
sudo apt update || true
38-
sudo apt install -y libc6:i386 ninja-build gcc-9-multilib g++-9-multilib libssl1.1:i386 libssl-dev:i386 zlib1g-dev:i386
38+
sudo apt install -y libc6:i386 linux-libc-dev:i386 ninja-build gcc-multilib g++-multilib
3939
4040
- name: Build release
4141
id: build
4242
run: |
43-
python ./scripts/build_release.py --build-type release --vs 2019 --toolset v141_xp --linux-compiler gcc-9 --out-dir ./_build_out --cmake-args="-DWARNINGS_ARE_ERRORS=ON" --github-actions
43+
cmake --preset github-actions
44+
cmake --build --preset github-actions
45+
cmake --install ${{github.workspace}}/_build/github-actions --config RelWithDebInfo --prefix ${{github.workspace}}/_build/ci-install
46+
47+
# Prepare artifact
48+
- name: Prepare artifact
49+
id: prepare_artifact
50+
run: >
51+
python scripts/package_target.py
52+
--build-dir ${{github.workspace}}/_build/github-actions
53+
--install-dir ${{github.workspace}}/_build/ci-install
54+
--artifact-dir ${{github.workspace}}/_build/ci-artifact
55+
--suffix ${{ matrix.os.suffix }}
4456
57+
# Upload result
4558
- name: Upload build result
46-
uses: actions/upload-artifact@v4.6.0
59+
uses: actions/upload-artifact@v4
4760
with:
48-
name: ${{ steps.build.outputs.artifact_name }}
49-
path: ./_build_out/WeaponMod-*.zip
61+
name: ${{ steps.prepare_artifact.outputs.artifact_name }}
62+
path: ${{github.workspace}}/_build/ci-artifact

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ include(InputFilesList)
1717
include(WinXPSupport)
1818
include(GitVersionSemverfier)
1919

20+
# This will be used by CI build scripts
21+
file( WRITE ${CMAKE_BINARY_DIR}/version.txt ${GIT_SEM_VERSION} )
22+
23+
message( "Version: ${GIT_SEM_VERSION} (from Git)" )
24+
2025
project( WeaponMod VERSION "${GIT_MAJOR}.${GIT_MINOR}.${GIT_PATCH}" )
2126
include( PlatformInfo )
2227

CMakePresets.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
},
2323
{
2424
"name": "github-actions",
25-
"inherits": ["base"],
26-
"generator": "Ninja Multi-Config",
25+
"inherits": ["platform-generator", "base"],
2726
"cacheVariables": {
2827
"GNU_FORCE_COLORED_OUTPUT": false,
2928
"WARNINGS_ARE_ERRORS": true

cmake/GitVersionSemverfier.cmake

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
4242
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
4343
OUTPUT_VARIABLE GIT_HASH
4444
OUTPUT_STRIP_TRAILING_WHITESPACE)
45+
# Replace slash in Git branch name
46+
string( REPLACE "/" "-" GIT_BRANCH ${GIT_BRANCH} )
47+
4548
if(NOT _git_code EQUAL 128)
4649
string(REGEX MATCH "(.*)-([0-9]+)-g(.+)" _git_result "${_git_result}")
4750
set(GIT_TAG ${CMAKE_MATCH_1})
@@ -65,9 +68,10 @@ if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
6568
if(GIT_SKIP GREATER 0)
6669
math(EXPR GIT_MINOR "${GIT_MINOR} + 1" OUTPUT_FORMAT DECIMAL)
6770
string(REGEX REPLACE "(v[0-9]+\.)([0-9]+)(\.[0-9]+)(.*)" "\\1${GIT_MINOR}.0\\4" GIT_TAG "${GIT_TAG}")
68-
set(GIT_SEM_VERSION "${GIT_TAG}${_git_delimiter}dev.${GIT_SKIP}+${GIT_HASH}.${GIT_BRANCH}")
71+
set(GIT_SEM_VERSION "${GIT_TAG}${_git_delimiter}dev.${GIT_SKIP}+${GIT_BRANCH}.${GIT_HASH}")
72+
set(GIT_PATCH 0)
6973
else()
70-
set(GIT_SEM_VERSION "${GIT_TAG}+${GIT_HASH}.${GIT_BRANCH}")
74+
set(GIT_SEM_VERSION "${GIT_TAG}+${GIT_BRANCH}.${GIT_HASH}")
7175
endif()
7276

7377
execute_process(COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD --
@@ -77,6 +81,7 @@ if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
7781
OUTPUT_STRIP_TRAILING_WHITESPACE)
7882
if(_git_dirty EQUAL 1)
7983
set(GIT_SEM_VERSION "${GIT_SEM_VERSION}.m")
84+
message("Git working tree is dirty!")
8085
endif()
8186

8287
#if(CMAKE_SCRIPT_MODE_FILE)
@@ -87,13 +92,13 @@ if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
8792
#endif()
8893

8994
string(REGEX REPLACE "v(.*)" "\\1" GIT_SEM_VERSION "${GIT_SEM_VERSION}")
95+
set(GIT_SUCCESS TRUE)
9096
else()
9197
set(GIT_MAJOR 0)
9298
set(GIT_MINOR 0)
9399
set(GIT_PATCH 0)
94100
set(GIT_SKIP 0)
95101
set(GIT_TAG "v0.0.0")
96-
set(GIT_SEM_VERSION "0.0.0+0000000.error")
102+
set(GIT_SEM_VERSION "0.0.0+error.0000000")
103+
set(GIT_SUCCESS FALSE)
97104
endif()
98-
99-
message("Version: ${GIT_SEM_VERSION}")

0 commit comments

Comments
 (0)