-
Notifications
You must be signed in to change notification settings - Fork 93
160 lines (139 loc) · 5.53 KB
/
cmake-multi-platform.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: CMake on multiple platforms
on:
push:
branches: [ "core4", "feature/*" ]
paths-ignore:
- '.github/workflows/**.yml'
- '!.github/workflows/cmake-multi-platform.yml'
pull_request:
branches: [ "core4" ]
paths-ignore:
- '.github/workflows/**.yml'
- '!.github/workflows/cmake-multi-platform.yml'
env:
DEFAULT_BRANCH: core4
IMAGE_NAME: ryzomcore-tools
jobs:
strings:
runs-on: ubuntu-latest
outputs:
build-output-dir: ${{ steps.strings.outputs.build-output-dir }}
build-version: ${{ steps.strings.outputs.build-version }}
docker-image-tag: ${{ steps.strings.outputs.docker-image-tag }}
steps:
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
COMMIT_HASH=${{ github.sha }}
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "$DEFAULT_BRANCH" ] && VERSION=latest
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo VERSION=$VERSION
echo IMAGE_ID=$IMAGE_ID
echo "build-version=${VERSION}+sha.${COMMIT_HASH:0:8}" >> "$GITHUB_OUTPUT"
echo "docker-image-tag=${IMAGE_ID}:${VERSION}" >> "$GITHUB_OUTPUT"
build:
needs: [ strings ]
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
matrix:
os: [ ubuntu-22.04, ubuntu-20.04 ]
build_type: [ Release ]
build_preset: [ release ]
c_compiler: [ gcc ]
include:
- os: ubuntu-22.04
c_compiler: gcc
cpp_compiler: g++
ubuntu_version: 22.04
- os: ubuntu-20.04
c_compiler: gcc
cpp_compiler: g++
ubuntu_version: 20.04
steps:
- uses: lukka/[email protected]
- uses: actions/checkout@v4
- name: Dependencies
run: |
sudo apt update
sudo apt install --yes software-properties-common
wget --quiet https://packages.microsoft.com/config/ubuntu/${{ matrix.ubuntu_version }}/packages-microsoft-prod.deb
sudo dpkg --install packages-microsoft-prod.deb
sudo apt update
sudo apt install --yes \
build-essential ccache \
bison autoconf automake \
libpng-dev \
libjpeg-dev \
libgif-dev libfreetype6-dev \
freeglut3-dev \
liblua5.2-dev libluabind-dev libcpptest-dev \
libogg-dev libvorbis-dev libopenal-dev \
libavcodec-dev libavformat-dev libavdevice-dev libswscale-dev libpostproc-dev \
libmysqlclient-dev \
libxml2-dev \
libcurl4-openssl-dev libssl-dev \
libsquish-dev \
liblzma-dev \
libgsf-1-dev \
qtbase5-dev qttools5-dev qttools5-dev-tools \
libmsquic
wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic.h
wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/msquic_posix.h
wget https://raw.githubusercontent.com/microsoft/msquic/main/src/inc/quic_sal_stub.h
sudo mv msquic.h msquic_posix.h quic_sal_stub.h /usr/include/
- name: Configure CMake
run: >
cmake --preset linux-default
-DWITH_MSQUIC=ON
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
- name: Build
run: cmake --build --preset ${{ matrix.build_preset }}
- name: Unit Tests
run: ctest --preset default
- uses: actions/upload-artifact@v4
if: (success() || failure()) && matrix.os == 'ubuntu-22.04'
with:
name: test-results
if-no-files-found: error
path: ${{ needs.strings.outputs.build-output-dir }}/**/reports/*.xml
- name: Package
run: cpack --preset default
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-package
path: ${{ needs.strings.outputs.build-output-dir }}/ryzomcore-*
if-no-files-found: error
docker:
runs-on: ubuntu-latest
needs: [ strings, build ]
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ubuntu-22.04-package
path: ${{ needs.strings.outputs.build-output-dir }}
- name: Build the Docker image
run: |
docker build . --file docker/Dockerfile --tag "${{ needs.strings.outputs.docker-image-tag }}"
docker save --output=${{ needs.strings.outputs.build-output-dir }}/docker-$IMAGE_NAME-${{ needs.strings.outputs.build-version }} "${{ needs.strings.outputs.docker-image-tag }}"
- uses: actions/upload-artifact@v4
with:
name: docker
path: ${{ needs.strings.outputs.build-output-dir }}/docker-*
if-no-files-found: error
- name: Push image
if: ${{ github.ref == format('refs/heads/{0}', env.DEFAULT_BRANCH) }}
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
docker push "${{ needs.strings.outputs.docker-image-tag }}"