mirror of
https://github.com/Vita3K/Vita3K.git
synced 2026-01-09 06:34:07 +08:00
333 lines
13 KiB
YAML
333 lines
13 KiB
YAML
name: C/C++ CI
|
|
|
|
on:
|
|
push:
|
|
paths-ignore:
|
|
- '**/*.md'
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**/*.md'
|
|
|
|
env:
|
|
BUILD_CONFIG: Release
|
|
|
|
jobs:
|
|
format-check:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Format check
|
|
run: .github/format-check.sh
|
|
|
|
build:
|
|
name: Build (${{ matrix.os }})
|
|
needs: [format-check]
|
|
runs-on: ${{ matrix.runs_on || matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-22.04
|
|
arch: x86_64
|
|
cache_path: ~/.ccache
|
|
extra_cmake_args: -DLINUXDEPLOY_COMMAND=/usr/local/bin/linuxdeploy-x86_64.AppImage
|
|
cmake_preset: linux-ninja-clang-appimage
|
|
- os: ubuntu-22.04-arm
|
|
arch: aarch64
|
|
cache_path: ~/.ccache
|
|
extra_cmake_args: -DLINUXDEPLOY_COMMAND=/usr/local/bin/linuxdeploy-aarch64.AppImage
|
|
cmake_preset: linux-ninja-clang-appimage
|
|
- os: windows-latest
|
|
cache_path: |
|
|
C:\vcpkg\installed
|
|
C:\vcpkg\packages
|
|
C:\Users\runneradmin\AppData\Local\ccache
|
|
extra_cmake_args: -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static-md
|
|
cmake_preset: windows-ninja
|
|
- os: macos-latest
|
|
cache_path: ~/Library/Caches/ccache
|
|
extra_cmake_args: -DCMAKE_OSX_ARCHITECTURES="x86_64" -DFORCE_BUILD_OPENSSL_MAC=ON -DVITA3K_FORCE_CUSTOM_BOOST=ON
|
|
cmake_preset: macos-ninja
|
|
- os: android
|
|
runs_on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
|
|
- name: Set up build environment (macos-latest)
|
|
run: |
|
|
sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer
|
|
brew install ccache create-dmg
|
|
echo "$(brew --prefix ccache)/libexec" >> $GITHUB_PATH
|
|
ccache --set-config=compiler_check=content
|
|
if: matrix.os == 'macos-latest'
|
|
|
|
- name: Set up build environment (ubuntu-22.04)
|
|
run: |
|
|
sudo add-apt-repository -y ppa:mhier/libboost-latest # boost repo
|
|
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
|
|
|
|
if [[ "${{ matrix.os }}" == "ubuntu-22.04-arm" ]]; then
|
|
# easy update clang linux os from external repo for specific clang version
|
|
wget https://apt.llvm.org/llvm.sh
|
|
chmod +x ./llvm.sh
|
|
sudo ./llvm.sh 15
|
|
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100
|
|
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100
|
|
sudo update-alternatives --set clang /usr/bin/clang-15
|
|
sudo update-alternatives --set clang++ /usr/bin/clang++-15
|
|
fi
|
|
|
|
# Set up linuxdeploy for AppImage
|
|
curl -sLO https://github.com/linuxdeploy/linuxdeploy/releases/latest/download/linuxdeploy-${{ matrix.arch }}.AppImage
|
|
sudo cp -f linuxdeploy-${{ matrix.arch }}.AppImage /usr/local/bin/
|
|
sudo chmod +x /usr/local/bin/linuxdeploy-${{ matrix.arch }}.AppImage
|
|
if: startsWith(matrix.os, 'ubuntu-22.04')
|
|
|
|
- name: Set up build environment (windows-latest)
|
|
run: |
|
|
vcpkg install zlib:x64-windows-static-md boost-system:x64-windows-static-md boost-filesystem:x64-windows-static-md boost-program-options:x64-windows-static-md boost-icl:x64-windows-static-md boost-variant:x64-windows-static-md curl:x64-windows-static-md openssl:x64-windows-static-md
|
|
choco install ccache
|
|
if: matrix.os == 'windows-latest'
|
|
|
|
- uses: ilammy/msvc-dev-cmd@v1
|
|
if: matrix.os == 'windows-latest'
|
|
|
|
- name: Set up build environment (android)
|
|
run: |
|
|
sudo apt-get install -y ninja-build
|
|
vcpkg install boost-system:arm64-android boost-filesystem:arm64-android boost-program-options:arm64-android boost-icl:arm64-android boost-variant:arm64-android openssl:arm64-android zlib:arm64-android
|
|
if: matrix.os == 'android'
|
|
|
|
- uses: hendrikmuhs/ccache-action@v1.2
|
|
if: matrix.os == 'android'
|
|
|
|
- name: Restore Gradle Cache
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: |
|
|
~/.gradle/
|
|
/usr/local/share/vcpkg/installed
|
|
/usr/local/share/vcpkg/packages
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/build.gradle') }}-${{ hashFiles('android/**/*.xml') }}-${{ hashFiles('android/**.java') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-${{ hashFiles('**/build.gradle') }}-${{ hashFiles('android/**/*.xml') }}-
|
|
${{ runner.os }}-gradle-${{ hashFiles('**/build.gradle') }}-
|
|
${{ runner.os }}-gradle-
|
|
if: matrix.os == 'android'
|
|
|
|
- name: Decode Android keystore
|
|
env:
|
|
KEYSTORE_ENCODED: ${{ secrets.KEYSTORE }}
|
|
run: echo "$KEYSTORE_ENCODED" | base64 --decode > /home/runner/keystore.jks
|
|
if: matrix.os == 'android'
|
|
|
|
- uses: actions/cache@v5
|
|
with:
|
|
path: ${{ matrix.cache_path }}
|
|
key: cache-${{ matrix.os }}-${{ env.BUILD_CONFIG }}-${{ github.sha }}
|
|
restore-keys: |
|
|
cache-${{ matrix.os }}-${{ env.BUILD_CONFIG }}-
|
|
if: matrix.os != 'android'
|
|
|
|
- name: Reset ccache statistics
|
|
run: ccache -z
|
|
if: matrix.os != 'android'
|
|
|
|
- name: Build Vita3K
|
|
run: |
|
|
cmake ${{ matrix.extra_cmake_args }} --preset ${{ matrix.cmake_preset }}
|
|
cmake --build build/${{ matrix.cmake_preset }} --config ${{ env.BUILD_CONFIG }}
|
|
if: matrix.os != 'android'
|
|
|
|
- name: Print ccache statistics
|
|
run: ccache -s
|
|
if: matrix.os != 'android'
|
|
|
|
- name: Build Vita3K (android)
|
|
env:
|
|
SIGNING_STORE_PATH: "/home/runner/keystore.jks"
|
|
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
|
|
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
|
|
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
|
|
JVM_OPTS: -Xmx6G
|
|
VCPKG_ROOT: /usr/local/share/vcpkg
|
|
run: |
|
|
cp -r data android/assets
|
|
cp -r lang android/assets
|
|
cp -r vita3k/shaders-builtin android/assets
|
|
export JAVA_HOME=$(echo $JAVA_HOME_17_X64)
|
|
if [ -n "${{ secrets.KEYSTORE }}" ];
|
|
then
|
|
BUILD_TYPE=Release
|
|
else
|
|
BUILD_TYPE=Reldebug
|
|
fi
|
|
./gradlew --stacktrace --configuration-cache --build-cache --parallel --configure-on-demand assemble${BUILD_TYPE}
|
|
echo "APK_PATH=android/build/outputs/apk/${BUILD_TYPE,,}/android-${BUILD_TYPE,,}.apk" >> $GITHUB_ENV
|
|
if: matrix.os == 'android'
|
|
|
|
- name: Run tests
|
|
working-directory: build/${{ matrix.cmake_preset }}
|
|
run: ctest --build-config ${{ env.BUILD_CONFIG }} --output-on-failure
|
|
if: matrix.os != 'android'
|
|
|
|
- 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: startsWith(matrix.os, 'ubuntu-22.04')
|
|
|
|
- name: Create DMG (macos-latest)
|
|
run: |
|
|
cd build/${{ matrix.cmake_preset }}/bin/${{ env.BUILD_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'
|
|
|
|
- name: Prepare Linux AppImage artifact
|
|
run: |
|
|
cd build/${{ matrix.cmake_preset }}/bin/${{ env.BUILD_CONFIG }}
|
|
mkdir -p ../appimage
|
|
mv -f *AppImage* ../appimage/
|
|
if: startsWith(matrix.os, 'ubuntu-22.04')
|
|
|
|
- name: Upload artifact (linux AppImage)
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: vita3k-${{ env.git_short_sha }}-${{ matrix.os }}-appimage
|
|
path: build/${{ matrix.cmake_preset }}/bin/appimage
|
|
if: startsWith(matrix.os, 'ubuntu-22.04')
|
|
|
|
- name: Upload artifact (android apk)
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: vita3k-${{ env.git_short_sha }}-android
|
|
path: ${{ env.APK_PATH }}
|
|
if: matrix.os == 'android'
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: vita3k-${{ env.git_short_sha }}-${{ matrix.os }}
|
|
path: build/${{ matrix.cmake_preset }}/bin/${{ env.BUILD_CONFIG }}
|
|
if: matrix.os != 'android'
|
|
|
|
outputs:
|
|
BuildTag: ${{ env.build_variable }}
|
|
ShortSHA: ${{ env.git_short_sha }}
|
|
|
|
create-release:
|
|
needs: [build]
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: create-release
|
|
cancel-in-progress: false
|
|
if: |
|
|
github.ref == 'refs/heads/master' &&
|
|
github.repository == 'Vita3K/Vita3K'
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
|
|
- name: Download Artifacts
|
|
uses: actions/download-artifact@v7
|
|
|
|
- name: Get Build Variable
|
|
run: echo "Build_Variable=${{ needs.build.outputs.BuildTag }}" >> $GITHUB_ENV
|
|
|
|
- name: Get Git Short SHA
|
|
run: echo "Short_SHA=${{ needs.build.outputs.ShortSHA }}" >> $GITHUB_ENV
|
|
|
|
- name: Get latest commit message
|
|
run: echo "Latest_Commit_Message=$(git log -1 --pretty=format:'%s')" >> $GITHUB_ENV
|
|
|
|
- name: Get last committer
|
|
run: |
|
|
COMMITTER_NAME=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
https://api.github.com/repos/Vita3K/Vita3K/commits/${{ github.sha }} \
|
|
| jq -r '.commit.author.name')
|
|
echo "Commiter_Name=$COMMITTER_NAME" >> $GITHUB_ENV
|
|
|
|
- name: Download ghr
|
|
run: |
|
|
wget -c https://github.com/tcnksm/ghr/releases/download/v0.17.0/ghr_v0.17.0_linux_amd64.tar.gz
|
|
tar xfv ghr_v0.17.0_linux_amd64.tar.gz
|
|
|
|
- name: Prepare artifacts
|
|
run: |
|
|
mkdir -p artifacts-master artifacts-store
|
|
files=$(find . -maxdepth 1 -type d -name "vita3k-*")
|
|
for f in $files; do
|
|
dir=$(basename $f)
|
|
if [[ $dir == *-android ]]; then
|
|
echo "Processing $dir (Android)"
|
|
cp $dir/*.apk artifacts-master/android-latest.apk
|
|
cp $dir/*.apk artifacts-store/vita3k-${{ env.Build_Variable }}-${{ env.Short_SHA }}_android.apk
|
|
elif [[ $dir == *-macos-latest ]]; then
|
|
echo "Processing $dir (macOS)"
|
|
cp $dir/*.dmg artifacts-master/macos-latest.dmg
|
|
cp $dir/*.dmg artifacts-store/vita3k-${{ env.Build_Variable }}-${{ env.Short_SHA }}_macos.dmg
|
|
elif [[ $dir == *-ubuntu-22.04-appimage ]]; then
|
|
echo "Processing $dir (x86_64 AppImage)"
|
|
cp $dir/*.AppImage* artifacts-master/
|
|
cp $dir/*.AppImage* artifacts-store/
|
|
elif [[ $dir == *-ubuntu-22.04-arm-appimage ]]; then
|
|
echo "Processing $dir (ARM64 AppImage)"
|
|
cp $dir/*.AppImage* artifacts-master/
|
|
cp $dir/*.AppImage* artifacts-store/
|
|
elif [[ $dir == *-ubuntu-22.04 ]]; then
|
|
echo "Processing $dir (Ubuntu x86_64)"
|
|
(cd $dir && zip -r ../artifacts-master/ubuntu-latest.zip *)
|
|
7z a -mx=9 artifacts-store/vita3k-${{ env.Build_Variable }}-${{ env.Short_SHA }}_ubuntu-x86_64.7z $dir
|
|
elif [[ $dir == *-ubuntu-22.04-arm ]]; then
|
|
echo "Processing $dir (Ubuntu ARM64)"
|
|
(cd $dir && zip -r ../artifacts-master/ubuntu-aarch64-latest.zip *)
|
|
7z a -mx=9 artifacts-store/vita3k-${{ env.Build_Variable }}-${{ env.Short_SHA }}_ubuntu-aarch64.7z $dir
|
|
elif [[ $dir == *-windows-latest ]]; then
|
|
echo "Processing $dir (Windows)"
|
|
(cd $dir && zip -r ../artifacts-master/windows-latest.zip *)
|
|
7z a -mx=9 artifacts-store/vita3k-${{ env.Build_Variable }}-${{ env.Short_SHA }}_windows.7z $dir
|
|
fi
|
|
done
|
|
echo "=== artifacts-master ==="
|
|
ls -al artifacts-master/
|
|
echo "=== artifacts-store ==="
|
|
ls -al artifacts-store/
|
|
|
|
- name: Upload to store repository
|
|
run: |
|
|
ghr_v0.17.0_linux_amd64/ghr -u Vita3K -r Vita3K-builds \
|
|
-n "Build: ${{ env.Build_Variable }}" \
|
|
-b "$(printf "Corresponding commit: [${{ env.Latest_Commit_Message }}](https://github.com/Vita3K/Vita3K/commit/${{ github.sha }}) (${{ env.Commiter_Name }})")" \
|
|
${{ env.Build_Variable }} artifacts-store/
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.STORE_TOKEN }}
|
|
|
|
- name: Upload to master repository
|
|
run: |
|
|
ghr_v0.17.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-master/
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|