Merge pull request #2040 from weblate/weblate-loot-loot #6
This file contains 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: CI | |
on: | |
push: | |
# Don't run this workflow when a tag is pushed. | |
branches: | |
- '*' | |
pull_request: | |
env: | |
BOOST_VERSION: 1.85.0 | |
OGDF_VERSION: elderberry-202309 | |
QT_VERSION: 6.7.2 | |
jobs: | |
# Check if the template.pot file is up to date. Run this as a separate job | |
# so that an outdated POT file causes a visible error but does not block the | |
# main CI builds. | |
check-pot: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install gettext | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-upgrade gettext | |
- name: Print xgettext version | |
run: | | |
xgettext --version | |
- name: Run pre-commit hook script | |
run: ./scripts/git/hooks/pre-commit | |
- name: Check if any changes were staged | |
run: | | |
if [[ $(git status --porcelain) ]] | |
then | |
echo "::warning ::The generated resources/l10n/template.pot does not match the committed file, which may be outdated and/or was generated by a different version of gettext." | |
git --no-pager diff HEAD | |
fi | |
linux: | |
runs-on: ubuntu-22.04 | |
env: | |
ICU_MAJOR_VERSION: 73 | |
LIBLOOT_VERSION: 0.24.0 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: pip cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
- name: Get Boost metadata | |
id: boost-metadata | |
run: | | |
BOOST_ROOT=~/boost_${BOOST_VERSION//./_} | |
echo "root=$BOOST_ROOT" >> $GITHUB_OUTPUT | |
echo "librarydir=${BOOST_ROOT}/stage/64/lib" >> $GITHUB_OUTPUT | |
- name: Set libloot install path | |
run: echo "LIBLOOT_INSTALL_PATH=${{ github.workspace }}/libloot-${{ env.LIBLOOT_VERSION }}-install" >> $GITHUB_ENV | |
- name: Boost cache | |
id: boost-cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
${{ steps.boost-metadata.outputs.root }}/boost | |
${{ steps.boost-metadata.outputs.root }}/stage | |
key: ${{ runner.os }}-Boost-${{ env.BOOST_VERSION }} | |
- name: libloot cache | |
id: libloot-cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.LIBLOOT_INSTALL_PATH }} | |
# Key includes ICU major version because libloot links against it as a shared library. | |
key: ${{ runner.os }}-libloot-${{ env.LIBLOOT_VERSION }}-icu-${{ env.ICU_MAJOR_VERSION }} | |
- name: Install C++ dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-upgrade \ | |
libtbb-dev \ | |
g++-12 \ | |
build-essential \ | |
libgl1-mesa-dev | |
- name: Download & build Boost | |
run: | | |
wget https://raw.githubusercontent.com/Ortham/ci-scripts/2.1.2/install_boost.py | |
python install_boost.py --directory ~ --boost-version $BOOST_VERSION -a 64 -t gcc-12 locale | |
if: steps.boost-cache.outputs.cache-hit != 'true' | |
- name: Get ICU | |
id: get-icu | |
run: | | |
wget https://github.com/unicode-org/icu/releases/download/release-${ICU_MAJOR_VERSION}-2/icu4c-${ICU_MAJOR_VERSION}_2-Ubuntu22.04-x64.tgz | |
tar -xf icu4c-${ICU_MAJOR_VERSION}_2-Ubuntu22.04-x64.tgz | |
ICU_INSTALL_PATH="${{ github.workspace }}/icu/usr/local" | |
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ICU_INSTALL_PATH/lib" >> "$GITHUB_ENV" | |
echo "root=$ICU_INSTALL_PATH" >> $GITHUB_OUTPUT | |
- name: Download Qt | |
id: qt-metadata | |
run: | | |
python -m pip install aqtinstall | |
aqt install-qt linux desktop $QT_VERSION linux_gcc_64 | |
echo "root=${{ github.workspace }}/$QT_VERSION/gcc_64" >> $GITHUB_OUTPUT | |
- name: Download and build libloot | |
run: | | |
wget https://github.com/loot/libloot/archive/$LIBLOOT_VERSION.tar.gz | |
tar -xf $LIBLOOT_VERSION.tar.gz | |
mkdir libloot-$LIBLOOT_VERSION/build | |
cd libloot-$LIBLOOT_VERSION/build | |
export CXX="g++-12" CC="gcc-12" | |
cmake .. -DBOOST_ROOT=${{ steps.boost-metadata.outputs.root }} -DBOOST_LIBRARYDIR=${{ steps.boost-metadata.outputs.librarydir }} -DICU_ROOT="${{ steps.get-icu.outputs.root }}" -DLIBLOOT_BUILD_TESTS=OFF -DLIBLOOT_INSTALL_DOCS=OFF -DCMAKE_INSTALL_PREFIX="$LIBLOOT_INSTALL_PATH" | |
cmake --build . --target loot --config Release | |
cmake --install . --config Release | |
if: steps.libloot-cache.outputs.cache-hit != 'true' | |
- name: Run CMake | |
run: | | |
mkdir build | |
cd build | |
export CXX="g++-12" CC="gcc-12" | |
cmake .. -DBOOST_ROOT=${{ steps.boost-metadata.outputs.root }} -DBOOST_LIBRARYDIR=${{ steps.boost-metadata.outputs.librarydir }} -DQt6_ROOT="${{ steps.qt-metadata.outputs.root }}" -DICU_ROOT="${{ steps.get-icu.outputs.root }}" -DCMAKE_PREFIX_PATH="${{ env.LIBLOOT_INSTALL_PATH }}" | |
make loot_gui_tests | |
- name: Run C++ tests | |
run: | | |
cd build | |
./loot_gui_tests | |
flatpak: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: pip cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
- name: flatpak-builder cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/build/.flatpak-builder | |
key: ${{ runner.os }}-flatpak-builder-${{ hashFiles('resources/linux/io.github.loot.loot.yml') }} | |
- name: Get descriptive LOOT version | |
id: get-loot-version | |
shell: bash | |
run: | | |
GIT_DESCRIBE=$(git describe --tags --long --abbrev=7) | |
GIT_REF=${{ github.ref }} | |
GIT_REF_SUFFIX=${GIT_REF#refs/*/} | |
LOOT_DESC_REF=${GIT_DESCRIBE}_${GIT_REF_SUFFIX} | |
LOOT_SAFE_DESC_REF=${LOOT_DESC_REF//[\/<>\"|]/_} | |
echo "version=$LOOT_SAFE_DESC_REF" >> $GITHUB_OUTPUT | |
- name: Install Flatpak build dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-upgrade \ | |
flatpak \ | |
flatpak-builder | |
- name: Generate Flatpak dependency manifests | |
run: ./scripts/generate_manifests.sh | |
- name: Build Flatpak package | |
id: build-flatpak | |
run: | | |
PACKAGE_FILENAME=loot_${{ steps.get-loot-version.outputs.version }}.flatpak | |
./scripts/build_flatpak.sh "$PACKAGE_FILENAME" | |
echo "filename=$PACKAGE_FILENAME" >> $GITHUB_OUTPUT | |
- name: Import GPG key | |
run: echo -n "${{ secrets.GPG_SIGNING_KEY }}" | gpg --import | |
if: github.event_name == 'push' | |
- name: Sign Flatpak package | |
run: gpg --output "build/${{ steps.build-flatpak.outputs.filename }}.sig" --detach-sig "build/${{ steps.build-flatpak.outputs.filename }}" | |
if: github.event_name == 'push' | |
- name: Upload Flatpak package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build-flatpak.outputs.filename }} | |
path: | | |
build/${{ steps.build-flatpak.outputs.filename }} | |
build/${{ steps.build-flatpak.outputs.filename }}.sig | |
if: github.event_name == 'push' | |
windows: | |
runs-on: windows-2019 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: pip cache | |
uses: actions/cache@v4 | |
with: | |
path: ~\AppData\Local\pip\Cache | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
- name: Get Boost metadata | |
id: boost-metadata | |
run: | | |
$BOOST_ROOT="${{ github.workspace }}/boost_" + $env:BOOST_VERSION -replace "\.", "_" | |
echo "root=$BOOST_ROOT" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
echo "librarydir=${BOOST_ROOT}/stage/64/lib" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
- name: Set OGDF install path | |
shell: bash | |
run: echo "OGDF_INSTALL_PATH=${{ github.workspace }}/ogdf-${{ env.OGDF_VERSION }}-install" >> $GITHUB_ENV | |
- name: Boost cache | |
id: boost-cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
${{ steps.boost-metadata.outputs.root }}/boost | |
${{ steps.boost-metadata.outputs.root }}/stage | |
key: ${{ runner.os }}-x64-Boost-${{ env.BOOST_VERSION }} | |
- name: OGDF cache | |
id: ogdf-cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.OGDF_INSTALL_PATH }} | |
key: ${{ runner.os }}-x64-ogdf-${{ env.OGDF_VERSION }} | |
- name: Download and extract svg_to_ico | |
run: | | |
curl -sfSLO 'https://github.com/Ortham/svg_to_ico/releases/download/1.1.0/svg_to_ico.7z' | |
7z e -y svg_to_ico.7z | |
- name: Generate ICO file | |
run: .\svg_to_ico.exe -i resources\icons\loot.svg -o build\icon\icon.ico | |
- name: Download & build Boost | |
run: | | |
curl -sSfLO https://raw.githubusercontent.com/Ortham/ci-scripts/2.1.2/install_boost.py | |
python install_boost.py --directory ${{ github.workspace }} --boost-version ${{ env.BOOST_VERSION }} -a 64 locale | |
if: steps.boost-cache.outputs.cache-hit != 'true' | |
- name: Download and build OGDF | |
run: | | |
curl -sSfLO https://github.com/ogdf/ogdf/archive/refs/tags/${env:OGDF_VERSION}.zip | |
Expand-Archive -Path "${env:OGDF_VERSION}.zip" -DestinationPath . | |
mkdir ogdf-${env:OGDF_VERSION}/build | |
cd ogdf-${env:OGDF_VERSION}/build | |
cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="${env:OGDF_INSTALL_PATH}" | |
cmake --build . --config Release | |
cmake --install . --config Release | |
if: steps.ogdf-cache.outputs.cache-hit != 'true' | |
- name: Download Qt | |
id: qt-metadata | |
run: | | |
python -m pip install aqtinstall | |
aqt install-qt windows desktop ${env:QT_VERSION} win64_msvc2019_64 | |
echo "root=${{ github.workspace }}/${env:QT_VERSION}/msvc2019_64" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
- name: Run CMake | |
run: | | |
cd build | |
cmake .. -G "Visual Studio 16 2019" -A x64 -DBOOST_ROOT="${{ steps.boost-metadata.outputs.root }}" -DBOOST_LIBRARYDIR="${{ steps.boost-metadata.outputs.librarydir }}" -DQt6_ROOT="${{ steps.qt-metadata.outputs.root }}" -DOGDF_ROOT="${{ env.OGDF_INSTALL_PATH }}" | |
cmake --build . --config Release | |
- name: Run C++ tests | |
run: | | |
cd build/Release | |
.\loot_gui_tests.exe | |
- name: Install packages for building docs | |
run: | | |
python -m pip install -r docs/requirements.txt | |
- name: Build docs | |
run: sphinx-build -b html docs build\docs\html | |
- name: Install Gettext | |
run: | | |
$filename='gettext-tools-windows-0.22.5.zip' | |
curl -sSfLO "https://github.com/vslavik/gettext-tools-windows/releases/download/v0.22.5/$filename" | |
7z x -y -ogettext ".\$filename" | |
echo "$PWD/gettext/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
- name: Build translation message object files | |
run: python scripts/po_to_mo.py | |
- name: Get descriptive LOOT version | |
id: get-loot-version | |
shell: bash | |
run: | | |
GIT_DESCRIBE=$(git describe --tags --long --abbrev=7) | |
GIT_REF=${{ github.ref }} | |
GIT_REF_SUFFIX=${GIT_REF#refs/*/} | |
LOOT_DESC_REF=${GIT_DESCRIBE}_${GIT_REF_SUFFIX} | |
LOOT_SAFE_DESC_REF=${LOOT_DESC_REF//[\/<>\"|]/_} | |
SAFE_GIT_REF_SUFFIX=${GIT_REF_SUFFIX//[\/<>\"|]/_} | |
echo "version=$LOOT_SAFE_DESC_REF" >> $GITHUB_OUTPUT | |
echo "ref=$SAFE_GIT_REF_SUFFIX" >> $GITHUB_OUTPUT | |
- name: Get LOOT artifact basename | |
id: get-artifact-basename | |
shell: bash | |
run: | | |
VERSION="${{ steps.get-loot-version.outputs.version }}" | |
echo "basename=loot_${VERSION}-win64" >> $GITHUB_OUTPUT | |
- name: Import GPG key | |
run: echo -n "${{ secrets.GPG_SIGNING_KEY }}" | gpg --import | |
if: github.event_name == 'push' | |
- name: Build archive | |
run: | | |
$env:PATH="${{ steps.qt-metadata.outputs.root }}/bin;$env:PATH" | |
python scripts\archive.py . "${{ steps.get-loot-version.outputs.ref }}" | |
mv "build\loot_${{ steps.get-loot-version.outputs.version }}.7z" "build\${{ steps.get-artifact-basename.outputs.basename }}.7z" | |
- name: Sign archive | |
run: gpg --output "build/${{ steps.get-artifact-basename.outputs.basename }}.7z.sig" --detach-sig "build/${{ steps.get-artifact-basename.outputs.basename }}.7z" | |
if: github.event_name == 'push' | |
- name: Build installer | |
run: | | |
scripts\prepare_installer.ps1 | |
$env:PATH += ';C:\Program Files (x86)\Inno Setup 6' | |
iscc scripts\installer.iss | |
mv "build\LOOT Installer.exe" "build\${{ steps.get-artifact-basename.outputs.basename }}.exe" | |
- name: Sign installer | |
run: gpg --output "build/${{ steps.get-artifact-basename.outputs.basename }}.exe.sig" --detach-sig "build/${{ steps.get-artifact-basename.outputs.basename }}.exe" | |
if: github.event_name == 'push' | |
- name: Upload archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.get-artifact-basename.outputs.basename }}.7z | |
path: | | |
build/${{ steps.get-artifact-basename.outputs.basename }}.7z | |
build/${{ steps.get-artifact-basename.outputs.basename }}.7z.sig | |
if: github.event_name == 'push' | |
- name: Upload installer | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.get-artifact-basename.outputs.basename }}.exe | |
path: | | |
build/${{ steps.get-artifact-basename.outputs.basename }}.exe | |
build/${{ steps.get-artifact-basename.outputs.basename }}.exe.sig | |
if: github.event_name == 'push' |