Update c-cpp.yml #105
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Vita3K Optimized CI | |
on: [push, pull_request] | |
jobs: | |
format-check: | |
runs-on: ubuntu-22.04-arm | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Format check | |
run: .github/format-check.sh | |
build: | |
needs: [format-check] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04-arm] | |
config: [Release] | |
version: [zip, appimage] | |
memory_mapping: [ON, OFF] | |
include: | |
- os: ubuntu-22.04-arm | |
version: zip | |
memory_mapping: ON | |
cache_path: ~/.ccache | |
extra_cmake_args: -DMEMORY_MAPPING=ON -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 | |
cmake_preset: linux-ninja-clang | |
- os: ubuntu-22.04-arm | |
version: zip | |
memory_mapping: OFF | |
cache_path: ~/.ccache | |
extra_cmake_args: -DMEMORY_MAPPING=OFF -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 | |
cmake_preset: linux-ninja-clang | |
- os: ubuntu-22.04-arm | |
version: appimage | |
memory_mapping: ON | |
cache_path: ~/.ccache | |
extra_cmake_args: -DMEMORY_MAPPING=ON -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 -DLINUXDEPLOY_COMMAND=/usr/local/bin/linuxdeploy-aarch64.AppImage | |
cmake_preset: linux-ninja-clang-appimage | |
- os: ubuntu-22.04-arm | |
version: appimage | |
memory_mapping: OFF | |
cache_path: ~/.ccache | |
extra_cmake_args: -DMEMORY_MAPPING=OFF -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 -DLINUXDEPLOY_COMMAND=/usr/local/bin/linuxdeploy-aarch64.AppImage | |
cmake_preset: linux-ninja-clang-appimage | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Set up build environment | |
run: | | |
wget https://apt.llvm.org/llvm.sh | |
chmod +x ./llvm.sh | |
sudo ./llvm.sh 18 | |
export CXX=clang++-18 | |
export CC=clang-18 | |
sudo add-apt-repository -y ppa:mhier/libboost-latest | |
sudo add-apt-repository universe | |
sudo apt update | |
sudo apt -y install ccache libboost-filesystem1.83-dev libboost-program-options1.83-dev libboost-system1.83-dev libgtk-3-dev libsdl2-dev ninja-build libfuse2 zip | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ matrix.cache_path }} | |
key: cache-${{ matrix.os }}-${{ matrix.config }}-${{ github.sha }} | |
restore-keys: | | |
cache-${{ matrix.os }}-${{ matrix.config }}- | |
- name: Set up SDL 2.30.9 | |
run: | | |
SDL2VER=2.30.9 | |
mkdir -p ~/.ccache | |
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 | |
- name: Set up linuxdeploy | |
run: | | |
if [[ ! -e linuxdeploy-aarch64.AppImage ]]; then | |
curl -sLO https://github.com/linuxdeploy/linuxdeploy/releases/latest/download/linuxdeploy-aarch64.AppImage | |
fi | |
sudo cp -f linuxdeploy-aarch64.AppImage /usr/local/bin/ | |
sudo chmod +x /usr/local/bin/linuxdeploy-aarch64.AppImage | |
if: matrix.version == 'appimage' | |
- name: Ccache setup | |
run: ccache -z | |
- 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 | |
- name: Set Memory Mapping Name | |
run: | | |
if [[ ${{ matrix.memory_mapping }} == 'ON' ]]; then | |
echo "MEMORY_MAPPING_NAME=memory-mapping-enabled" >> $GITHUB_ENV | |
else | |
echo "MEMORY_MAPPING_NAME=memory-mapping-disabled" >> $GITHUB_ENV | |
fi | |
- name: Bundle Shared Objects | |
id: bundle_shared_objects | |
run: | | |
cd build/${{ matrix.cmake_preset }}/bin/${{ matrix.config }} | |
cp /usr/lib/aarch64-linux-gnu/libssl.so.3 ./libssl.so.3 | |
cp /usr/lib/aarch64-linux-gnu/libcrypto.so.3 ./libcrypto.so.3 | |
- name: Ccache statistics | |
run: ccache -s | |
- name: Compress AppImage into ZIP (for AppImage builds) | |
if: matrix.version == 'appimage' | |
run: | | |
cd build/${{ matrix.cmake_preset }}/bin/${{ matrix.config }} | |
zip vita3k-${{ env.git_short_sha }}-${{ env.MEMORY_MAPPING_NAME }}-${{ matrix.os }}.zip Vita3K-aarch64.AppImage Vita3K-aarch64.AppImage.zsync | |
- name: Create ZIP (for zip builds) | |
if: matrix.version == 'zip' | |
run: | | |
cd build/${{ matrix.cmake_preset }}/bin/${{ matrix.config }} | |
zip -r vita3k-${{ env.git_short_sha }}-${{ env.MEMORY_MAPPING_NAME }}-${{ matrix.os }}.zip . | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: vita3k-${{ env.git_short_sha }}-${{ matrix.version }}-${{ env.MEMORY_MAPPING_NAME }}-${{ matrix.os }} | |
path: | | |
build/${{ matrix.cmake_preset }}/bin/${{ matrix.config }}/*.zip | |
outputs: | |
BuildTag: ${{ env.build_variable }} | |
ShortSHA: ${{ env.git_short_sha }} | |
MEMORY_MAPPING_NAME: ${{ env.MEMORY_MAPPING_NAME }} | |
create-release: | |
needs: [build] | |
runs-on: ubuntu-22.04-arm | |
concurrency: | |
group: create-release | |
cancel-in-progress: false | |
if: | | |
github.ref == 'refs/heads/master' && | |
github.repository == 'mrcmunir/Vita3K' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install jq | |
run: sudo apt-get install -y jq | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: downloaded_artifacts | |
pattern: vita3k-* | |
- name: Debug downloaded artifacts structure | |
run: | | |
echo "Estructura de downloaded_artifacts:" | |
tree downloaded_artifacts | |
- name: Combine Artifacts | |
run: | | |
mkdir -p artifacts | |
for dir in downloaded_artifacts/*; do | |
if [ -d "$dir" ]; then | |
build_type=$(basename "$dir" | awk -F'-' '{print $3}') # appimage o zip | |
memory_mapping=$(basename "$dir" | awk -F'-' '{print $6}') # enabled o disabled | |
for file in "$dir"/*.zip; do | |
if [ -f "$file" ]; then | |
if [[ "$build_type" == "appimage" ]]; then | |
new_name="vita3k-$GIT_SHORT_SHA-memory-mapping-$memory_mapping-appimage.zip" | |
else | |
new_name="vita3k-$GIT_SHORT_SHA-memory-mapping-$memory_mapping-ubuntu-22.04-arm.zip" | |
fi | |
cp "$file" "artifacts/$new_name" | |
fi | |
done | |
fi | |
done | |
echo "Contenido de artifacts/:" | |
ls -al artifacts/ | |
env: | |
GIT_SHORT_SHA: ${{ needs.build.outputs.ShortSHA }} | |
- name: Upload Release | |
shell: bash | |
run: | | |
wget -c https://github.com/tcnksm/ghr/releases/download/v0.17.0/ghr_v0.17.0_linux_arm64.tar.gz | |
tar xfv ghr_v0.17.0_linux_arm64.tar.gz | |
ghr_v0.17.0_linux_arm64/ghr -u mrcmunir -r Vita3K -n 'Automatic CI builds' -b "$(printf "Corresponding commit: ${{ github.sha }}\nVita3K Build: $BUILD_VARIABLE")" continuous artifacts/ | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BUILD_VARIABLE: ${{ needs.build.outputs.BuildTag }} | |
- name: Delete old releases | |
shell: bash | |
run: | | |
releases=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/releases" | jq -r '.[] | .id') | |
releases=($releases) | |
if [[ ${#releases[@]} -gt 10 ]]; then | |
for ((i=0; i<${#releases[@]}-10; i++)); do | |
release_id=${releases[$i]} | |
echo "Eliminando release con ID: $release_id" | |
curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/releases/$release_id" | |
done | |
else | |
echo "No hay releases antiguos para eliminar." | |
fi |