forked from Vita3K/Vita3K
-
Notifications
You must be signed in to change notification settings - Fork 1
185 lines (160 loc) · 6.57 KB
/
c-cpp.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
name: C/C++ CI
on: [push, pull_request]
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Format check
run: .github/format-check.sh
build:
needs: [format-check]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
config: [Release]
include:
- os: ubuntu-latest
cache_path: ~/.ccache
extra_cmake_args:
cmake_preset: linux-ninja-clang14
- os: windows-latest
cache_path: |
C:\vcpkg\installed
C:\vcpkg\packages
extra_cmake_args: -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake_preset: windows-ninja
- os: macos-latest
cache_path: ~/Library/Caches/ccache
extra_cmake_args:
cmake_preset: macos-ninja
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Set up build environment (macos-latest)
run: |
brew install ccache ninja create-dmg
brew fetch --force --bottle-tag=big_sur boost openssl@3 molten-vk
brew install $(brew --cache --bottle-tag=big_sur boost)
brew install $(brew --cache --bottle-tag=big_sur molten-vk)
brew reinstall $(brew --cache --bottle-tag=big_sur openssl@3)
echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
ccache --set-config=compiler_check=content
if: matrix.os == 'macos-latest'
- name: Set up build environment (ubuntu-latest)
run: |
sudo add-apt-repository -y ppa:mhier/libboost-latest
sudo apt update
sudo apt -y install ccache libboost-filesystem1.81-dev libboost-program-options1.81-dev libboost-system1.81-dev libgtk-3-dev libsdl2-dev ninja-build lld-11
if: matrix.os == 'ubuntu-latest'
- uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-latest'
- uses: hendrikmuhs/[email protected]
with:
variant: sccache
if: matrix.os == 'windows-latest'
- uses: actions/cache@v3
with:
path: ${{ matrix.cache_path }}
key: cache-${{ matrix.os }}-${{ matrix.config }}-${{ github.sha }}
restore-keys: |
cache-${{ matrix.os }}-${{ matrix.config }}-
- name: Set up build environment (windows-latest)
run: |
vcpkg install zlib:x64-windows boost-system:x64-windows boost-filesystem:x64-windows boost-program-options:x64-windows boost-icl:x64-windows boost-variant:x64-windows openssl:x64-windows
if: matrix.os == 'windows-latest'
- name: Set up SDL 2.28.3 (ubuntu-latest)
run: |
SDL2VER=2.28.3
if [[ ! -e ~/.ccache ]]; then
mkdir ~/.ccache
fi
cd ~/.ccache
if [[ ! -e SDL2-${SDL2VER} ]]; then
curl -sLO https://libsdl.org/release/SDL2-${SDL2VER}.tar.gz
tar -xzf SDL2-${SDL2VER}.tar.gz
cd SDL2-${SDL2VER}
./configure --prefix=/usr/local
make && cd ../
rm SDL2-${SDL2VER}.tar.gz
fi
sudo make -C SDL2-${SDL2VER} install
if: matrix.os == 'ubuntu-latest'
- name: CMake
run: |
cmake ${{ matrix.extra_cmake_args }} --preset ${{ matrix.cmake_preset }}
cmake --build build/${{ matrix.cmake_preset }} --config ${{ matrix.config }}
- name: CTest
working-directory: build/${{ matrix.cmake_preset }}
run: ctest --build-config ${{ matrix.config }} --output-on-failure
- name: Compute git short sha
shell: bash
run: echo "git_short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Set Build Variable
shell: bash
run: echo "build_variable=$(git rev-list HEAD --count)" >> $GITHUB_ENV
if: matrix.os == 'ubuntu-latest'
- name: Bundle OpenSSL shared objects
id: bundle_openssl
run: |
cd build/${{ matrix.cmake_preset }}/bin/${{ matrix.config }}
cp /usr/lib/x86_64-linux-gnu/libssl.so.3 ./libssl.so.3
cp /usr/lib/x86_64-linux-gnu/libcrypto.so.3 ./libcrypto.so.3
if: matrix.os == 'ubuntu-latest'
- name: Create DMG (macos-latest)
run: |
cd build/${{ matrix.cmake_preset }}/bin/${{ matrix.config }}
create-dmg \
--volname "Vita3K Installer" \
--volicon Vita3K.app/Contents/Resources/Vita3K.icns \
--window-size 500 300 \
--icon-size 100 \
--icon Vita3K.app 120 115 \
--app-drop-link 360 115 \
vita3k-${{ env.git_short_sha }}-${{ matrix.os }}.dmg \
Vita3K.app
rm -rf Vita3K.app
if: matrix.os == 'macos-latest'
- uses: actions/upload-artifact@v3
with:
name: vita3k-${{ env.git_short_sha }}-${{ matrix.os }}
# path is set up to be <binary_dir>/bin/<config_type> since that's how multi-config
# generators work on CMake
path: build/${{ matrix.cmake_preset }}/bin/${{ matrix.config }}
outputs:
BuildTag: ${{ env.build_variable }}
create-release:
needs: [build]
runs-on: "ubuntu-20.04"
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Get Build Variable
run: echo "Build_Variable=${{ needs.build.outputs.BuildTag }}" >> $GITHUB_ENV
- name: Upload
shell: bash
run: |
mkdir artifacts/
files=$(find . -name "*latest")
for f in $files; do
if [[ $f == *macos-latest ]]
then
cp $(basename $f)/$(basename $f).dmg artifacts/macos-latest.dmg
else
echo "Compressing $f"
(cd $(basename $f) && zip -r ../artifacts/$(basename $f | cut -d "-" -f 3)-latest.zip *)
fi
done
ls -al artifacts/
wget -c https://github.com/tcnksm/ghr/releases/download/v0.14.0/ghr_v0.14.0_linux_amd64.tar.gz
tar xfv ghr_v0.14.0_linux_amd64.tar.gz
ghr_v0.14.0_linux_amd64/ghr -u Vita3K -r Vita3K -recreate -n 'Automatic CI builds' -b "$(printf "Corresponding commit: ${{ github.sha }}\nVita3K Build: ${{ env.Build_Variable }}")" continuous artifacts/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}