Skip to content

Commit abbab2a

Browse files
committed
Change: Switch to CMake.
Workflows are borrowed from grfcodec.
1 parent c8acce2 commit abbab2a

17 files changed

+422
-398
lines changed

.github/workflows/ci-build.yml

Lines changed: 116 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,131 @@ on:
77
- master
88

99
jobs:
10-
build:
11-
name: Build
10+
linux:
11+
name: Linux
1212

13-
runs-on: ${{ matrix.os }}
1413
strategy:
1514
fail-fast: false
1615
matrix:
1716
include:
18-
- os: windows-latest
19-
makefile: Makefile.msvc
20-
- os: ubuntu-latest
21-
makefile: Makefile
17+
- compiler: clang
18+
cxxcompiler: clang++
19+
- compiler: gcc
20+
cxxcompiler: g++
21+
22+
runs-on: ubuntu-latest
23+
env:
24+
CC: ${{ matrix.compiler }}
25+
CXX: ${{ matrix.cxxcompiler }}
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Install GCC problem matcher
32+
uses: ammaraskar/gcc-problem-matcher@master
33+
34+
- name: Build
35+
run: |
36+
mkdir build
37+
cd build
38+
39+
echo "::group::CMake"
40+
cmake ..
41+
echo "::endgroup::"
42+
43+
echo "::group::Build"
44+
echo "Running on $(nproc) cores"
45+
cmake --build . -j $(nproc)
46+
echo "::endgroup::"
47+
48+
macos:
49+
name: Mac OS
50+
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
include:
55+
- arch: arm64
56+
full_arch: arm64
57+
58+
runs-on: macos-latest
59+
env:
60+
MACOSX_DEPLOYMENT_TARGET: 10.13
61+
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
66+
- name: Install GCC problem matcher
67+
uses: ammaraskar/gcc-problem-matcher@master
68+
69+
- name: Build
70+
run: |
71+
mkdir build
72+
cd build
73+
74+
echo "::group::CMake"
75+
cmake ${GITHUB_WORKSPACE} \
76+
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.full_arch }} \
77+
# EOF
78+
echo "::endgroup::"
79+
80+
echo "::group::Build"
81+
echo "Running on $(sysctl -n hw.logicalcpu) cores"
82+
cmake --build . -j $(sysctl -n hw.logicalcpu)
83+
echo "::endgroup::"
84+
85+
windows:
86+
name: Windows
87+
88+
strategy:
89+
fail-fast: false
90+
matrix:
91+
os: [windows-latest]
92+
arch: [x86, x64]
93+
94+
runs-on: ${{ matrix.os }}
2295

2396
steps:
2497
- name: Checkout
25-
uses: actions/checkout@v1
26-
- name: Set build environment
27-
if: matrix.os == 'windows-latest'
98+
uses: actions/checkout@v4
99+
100+
- name: Install MSVC problem matcher
101+
uses: ammaraskar/msvc-problem-matcher@master
102+
103+
- name: Configure developer command prompt for ${{ matrix.arch }}
28104
uses: ilammy/msvc-dev-cmd@v1
29105
with:
30-
arch: x86
106+
arch: ${{ matrix.arch }}
107+
31108
- name: Build
32-
run: make -f ${{ matrix.makefile }}
33109
shell: bash
110+
run: |
111+
mkdir build
112+
cd build
113+
114+
echo "::group::CMake"
115+
cmake .. \
116+
-GNinja \
117+
# EOF
118+
echo "::endgroup::"
119+
120+
echo "::group::Build"
121+
cmake --build .
122+
echo "::endgroup::"
123+
124+
check_annotations:
125+
name: Check Annotations
126+
needs:
127+
- linux
128+
- macos
129+
- windows
130+
131+
if: always() && github.event_name == 'pull_request'
132+
133+
runs-on: ubuntu-latest
134+
135+
steps:
136+
- name: Check annotations
137+
uses: OpenTTD/actions/annotation-check@v5

.github/workflows/commit-checker.yml

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,12 @@ jobs:
1010

1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1414
with:
1515
fetch-depth: 4
1616

1717
- name: Get pull-request commits
18-
run: |
19-
set -x
20-
# actions/checkout did a merge checkout of the pull-request. As such, the first
21-
# commit is the merge commit. This means that on HEAD^ is the base branch, and
22-
# on HEAD^2 are the commits from the pull-request. We now check if those trees
23-
# have a common parent. If not, we fetch a few more commits till we do. In result,
24-
# the log between HEAD^ and HEAD^2 will be the commits in the pull-request.
25-
DEPTH=4
26-
while [ -z "$(git merge-base HEAD^ HEAD^2)" ]; do
27-
# Prevent infinite recursion
28-
if [ ${DEPTH} -gt 256 ]; then
29-
echo "No common parent between '${GITHUB_HEAD_REF}' and '${GITHUB_BASE_REF}'." >&2
30-
exit 1
31-
fi
32-
33-
git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --deepen=${DEPTH} origin HEAD
34-
DEPTH=$(( ${DEPTH} * 4 ))
35-
done
36-
37-
# Just to show which commits we are going to evaluate.
38-
git log --oneline HEAD^..HEAD^2
39-
40-
- name: Checkout commit-checker
41-
uses: actions/checkout@v2
42-
with:
43-
repository: OpenTTD/OpenTTD-git-hooks
44-
path: git-hooks
45-
ref: master
18+
uses: OpenTTD/actions/checkout-pull-request@v5
4619

4720
- name: Check commits
48-
run: |
49-
set -x
50-
HOOKS_DIR=./git-hooks/hooks GIT_DIR=.git ./git-hooks/hooks/check-commits.sh HEAD^..HEAD^2
51-
echo "Commit checks passed"
21+
uses: OpenTTD/OpenTTD-git-hooks@main

.github/workflows/release.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
source:
10+
name: Source
11+
12+
runs-on: ubuntu-20.04
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Generate .version
19+
run: |
20+
cmake -DWRITE_VERSION=1 -P generate_version.cmake
21+
22+
- name: Create bundles
23+
run: |
24+
FOLDER_NAME=catcodec-${{ github.event.release.tag_name }}
25+
26+
# Rename the folder to catcodec-NNN
27+
mkdir ${FOLDER_NAME}
28+
find . -maxdepth 1 -not -name . -not -name .git -not -name ${FOLDER_NAME} -exec mv {} ${FOLDER_NAME}/ \;
29+
30+
mkdir -p build/bundles
31+
32+
echo "::group::Create tarball (xz) bundle"
33+
tar --xz -cvf build/bundles/${FOLDER_NAME}-source.tar.xz ${FOLDER_NAME}
34+
echo "::endgroup::"
35+
36+
echo "::group::Create zip bundle"
37+
zip -9 -r build/bundles/${FOLDER_NAME}-source.zip ${FOLDER_NAME}
38+
echo "::endgroup::"
39+
40+
- name: Store bundles
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
gh release upload ${{ github.event.release.tag_name }} build/bundles/*
45+
46+
windows:
47+
needs: source
48+
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
arch: [x86, x64]
53+
54+
name: Windows (${{ matrix.arch }})
55+
56+
runs-on: windows-latest
57+
58+
steps:
59+
- name: Prepare build dir for gh usage
60+
shell: bash
61+
run: |
62+
git init build
63+
cd build
64+
git remote add origin ${{ github.event.repository.html_url }}
65+
66+
- name: Download source
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
shell: bash
70+
run: |
71+
cd build
72+
gh release download ${{ github.event.release.tag_name }} -p "*.xz" -D ..
73+
74+
- name: Unpack source
75+
shell: bash
76+
run: |
77+
tar --xz -xf *-source.tar.xz --strip-components=1
78+
79+
- name: Install MSVC problem matcher
80+
uses: ammaraskar/msvc-problem-matcher@master
81+
82+
- name: Configure developer command prompt for ${{ matrix.arch }}
83+
uses: ilammy/msvc-dev-cmd@v1
84+
with:
85+
arch: ${{ matrix.arch }}
86+
87+
- name: Build
88+
shell: bash
89+
run: |
90+
cd build
91+
92+
echo "::group::CMake"
93+
cmake .. \
94+
-GNinja \
95+
-DCMAKE_BUILD_TYPE=Release \
96+
# EOF
97+
echo "::endgroup::"
98+
99+
echo "::group::Build"
100+
cmake --build .
101+
echo "::endgroup::"
102+
103+
- name: Create bundles
104+
shell: bash
105+
run: |
106+
cd build
107+
echo "::group::Run CPack"
108+
cpack
109+
echo "::endgroup::"
110+
111+
- name: Store bundles
112+
env:
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
shell: bash
115+
run: |
116+
cd build
117+
gh release upload ${{ github.event.release.tag_name }} bundles/*

0 commit comments

Comments
 (0)