-
Notifications
You must be signed in to change notification settings - Fork 4
209 lines (187 loc) · 7.09 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: CMake on multiple platforms
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
create_or_update_release:
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.release_tag.outputs.release_tag }} # Expose release tag as output
steps:
- uses: actions/checkout@v4
- name: Set Release Tag to Current Date
id: release_tag
run: |
RELEASE_TAG="v$(date +'%Y-%m-%d')" # Use only the current date for the release tag (e.g., v20250104)
echo "Release tag: $RELEASE_TAG"
echo "::set-output name=release_tag::$RELEASE_TAG" # Set the release tag as an output variable
- name: Check if Release Already Exists
id: release_exists
run: |
RELEASE_TAG="${{ steps.release_tag.outputs.release_tag }}"
EXISTING_RELEASE=$(gh release view $RELEASE_TAG --json tagName --jq ".tagName" || echo "null")
echo "Existing release tag: $EXISTING_RELEASE"
echo "Wanted release tag : $RELEASE_TAG"
# Check if release exists and if the tag matches
if [ "$EXISTING_RELEASE" == "$RELEASE_TAG" ]; then
echo "Release tag $RELEASE_TAG already exists. Skipping creation."
echo "release_exists=true" >> $GITHUB_ENV
else
echo "Release does not exist or tags do not match. Creating new release."
echo "release_exists=false" >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create New Release (if necessary)
if: env.release_exists == 'false'
run: |
RELEASE_TAG="${{ steps.release_tag.outputs.release_tag }}"
echo "Creating release with tag $RELEASE_TAG"
gh release create $RELEASE_TAG --title "Release $RELEASE_TAG" --notes "Release created on $RELEASE_TAG"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build_and_upload:
needs: create_or_update_release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] #, windows-latest]
build_type: [Release]
include:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
# - os: ubuntu-latest
# c_compiler: clang
# cpp_compiler: clang++
# For Windows, use MSVC as the compiler
# - os: windows-latest
# c_compiler: msvc
# cpp_compiler: msvc
steps:
- uses: actions/checkout@v4
- name: Install Dependencies (Including gh)
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update
sudo apt-get install -y \
libssl-dev \
libluajit-5.1-dev \
protobuf-c-compiler \
libprotobuf-c-dev \
libopus-dev \
libsndfile1-dev \
libuv1-dev \
gh
elif [ "$RUNNER_OS" == "Windows" ]; then
echo "Windows dependencies installed via vcpkg"
fi
shell: bash
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Install vcpkg for MSVC (Windows only)
if: matrix.os == 'windows-latest'
uses: lukka/run-vcpkg@v11
with:
runVcpkgInstall: true
doNotUpdateVcpkg: true
vcpkgJsonGlob: "**/vcpkg.json"
env:
VCPKG_DEFAULT_TRIPLET: "x64-windows"
- name: Configure CMake
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
cmake -B ${{ steps.strings.outputs.build-output-dir }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-G "Visual Studio 16 2019"
else
cmake -B ${{ steps.strings.outputs.build-output-dir }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-S ${{ github.workspace }}
fi
shell: bash
- name: Build
run: |
cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --build-config ${{ matrix.build_type }}
- name: Zip GCC .so Files
if: matrix.c_compiler == 'gcc'
run: |
GCC_SO_FILES=$(find ${{ steps.strings.outputs.build-output-dir }} -name '*.so' -type f)
echo "Found GCC .so files: $GCC_SO_FILES"
ZIP_FILE="release-gcc.zip"
zip -r $ZIP_FILE $GCC_SO_FILES
echo "Zipped GCC .so files into $ZIP_FILE"
working-directory: ${{ github.workspace }}
- name: Zip Clang .so Files
if: matrix.c_compiler == 'clang'
run: |
CLANG_SO_FILES=$(find ${{ steps.strings.outputs.build-output-dir }} -name '*.so' -type f)
echo "Found Clang .so files: $CLANG_SO_FILES"
ZIP_FILE="release-clang.zip"
zip -r $ZIP_FILE $CLANG_SO_FILES
echo "Zipped Clang .so files into $ZIP_FILE"
working-directory: ${{ github.workspace }}
- name: Zip MSVC Files
if: matrix.c_compiler == 'msvc'
run: |
MSVC_DLL_FILES=$(find ${{ steps.strings.outputs.build-output-dir }} -name '*.dll' -type f)
echo "Found MSVC .dll files: $MSVC_DLL_FILES"
ZIP_FILE="release-msvc.zip"
Compress-Archive -Path $MSVC_DLL_FILES -DestinationPath $ZIP_FILE
echo "Zipped MSVC .dll files into $ZIP_FILE"
shell: powershell
- name: Upload GCC .so Zip to Release
if: matrix.c_compiler == 'gcc'
run: |
RELEASE_TAG="${{ needs.create_or_update_release.outputs.release_tag }}"
ZIP_FILE="release-gcc.zip"
if [ -f "$ZIP_FILE" ]; then
echo "Uploading $ZIP_FILE to release $RELEASE_TAG"
gh release upload $RELEASE_TAG $ZIP_FILE --clobber
else
echo "Error: $ZIP_FILE does not exist."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Clang .so Zip to Release
if: matrix.c_compiler == 'clang'
run: |
RELEASE_TAG="${{ needs.create_or_update_release.outputs.release_tag }}"
ZIP_FILE="release-clang.zip"
if [ -f "$ZIP_FILE" ]; then
echo "Uploading $ZIP_FILE to release $RELEASE_TAG"
gh release upload $RELEASE_TAG $ZIP_FILE --clobber
else
echo "Error: $ZIP_FILE does not exist."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload MSVC .dll Zip to Release
if: matrix.c_compiler == 'msvc'
run: |
RELEASE_TAG="${{ needs.create_or_update_release.outputs.release_tag }}"
ZIP_FILE="release-msvc.zip"
if [ -f "$ZIP_FILE" ]; then
echo "Uploading $ZIP_FILE to release $RELEASE_TAG"
gh release upload $RELEASE_TAG $ZIP_FILE --clobber
else
echo "Error: $ZIP_FILE not found."
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}