Skip to content

Fix CMakeLists.txt bug #2332

Fix CMakeLists.txt bug

Fix CMakeLists.txt bug #2332

Workflow file for this run

# https://docs.github.com/en/actions/learn-github-actions/contexts
---
name: Gittyup
on:
push:
branches:
- master
tags:
- 'gittyup_v*'
pull_request:
page_build:
workflow_dispatch:
env:
IS_RELEASE: ${{ github.event_name == 'push' && github.ref_type == 'tag' && startswith(github.ref_name, 'gittyup_v') }}
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.18.0
with:
clang-format-version: '13'
exclude-regex: 'dep'
- name: Check CMake code style
run: |
pip install cmake-format==0.6.13 && \
find \( -type d -path './dep/*/*' -prune \) -o \( -name CMakeLists.txt -exec cmake-format --check {} + \)
flatpak:
name: "Flatpak"
runs-on: ubuntu-latest
container:
# image: bilelmoussaoui/flatpak-github-actions:kde-5.15-21.08
image: archlinux:latest
options: --privileged
steps:
- name: Update
run: |
pacman --noconfirm -Suy
pacman --noconfirm -S flatpak flatpak-builder xorg-server-xvfb
flatpak install --assumeyes org.freedesktop.Sdk.Extension.golang//23.08
- name: Show environment variables
run: >
echo IS_RELEASE: ${{ env.IS_RELEASE }}
# https://stackoverflow.com/questions/60916931/github-action-does-the-if-have-an-else
- name: Determine flatpak release branch
id: flatpak_release_branch
run: |
if [ "${{ env.IS_RELEASE }}" = "true" ]; then
echo "value=stable" >> "$GITHUB_OUTPUT"
else
echo "value=development" >> "$GITHUB_OUTPUT"
fi
- name: Checkout repository
uses: actions/checkout@v6
- name: Replace git tag by the commit id on which it runs
if: github.ref_type != 'tag'
run: >
sed -i 's@tag: .*@commit: "${{ (github.event.pull_request && github.event.pull_request.head.sha) || github.sha }}"@' com.github.Murmele.Gittyup.yml
- name: Use correct git tag
if: github.ref_type == 'tag'
run: >
sed -i 's@tag: .*$@tag: "${{ github.ref_name }}"@' com.github.Murmele.Gittyup.yml
- name: Replace source url
run: >
sed -i "s@url: .*Gittyup.git@url: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY@" com.github.Murmele.Gittyup.yml
- name: Add dev build marker to cmake options
if: github.ref_type != 'tag'
run: >
sed -i 's@config-opts: \["\(.*\)"\]@config-opts: ["\1", "-DDEV_BUILD=${{ github.ref_name }}"]@' com.github.Murmele.Gittyup.yml
- name: Replace desktop file name suffix
if: github.ref_type != 'tag'
run: >
sed -i 's@desktop-file-name-suffix: ""@desktop-file-name-suffix: " (Development)"@' com.github.Murmele.Gittyup.yml
- name: Enable automatic update
if: github.ref_type != 'tag'
run: >
sed -i 's@-DENABLE_UPDATE_OVER_GUI=OFF@-DENABLE_UPDATE_OVER_GUI=ON@' com.github.Murmele.Gittyup.yml
- name: Show Flatpak manifest
run: cat com.github.Murmele.Gittyup.yml
- name: Build package
uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v6
with:
bundle: Gittyup.flatpak
manifest-path: com.github.Murmele.Gittyup.yml
cache: false
upload-artifact: true
verbose: true
branch: ${{ steps.flatpak_release_branch.outputs.value }}
- name: Publish build artifacts
uses: actions/upload-artifact@v6
with:
path: Gittyup.flatpak
name: GittyupFlatpak
build:
runs-on: ${{ matrix.env.os }}
strategy:
fail-fast: false
matrix:
qt:
- version: 6.7.3
env:
- name: linux
os: ubuntu-latest
ninja_platform: linux
qt_platform: linux
qt_arch: linux_gcc_64
openssl_arch: linux-x86_64
ld_library_arch: linux-x86-64
cmake_flags: "-DGENERATE_APPDATA=ON -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_UPDATE_OVER_GUI=OFF -DUSE_SSH=ON"
pack: 0
cmake_env: {}
- name: macos
os: macos-15-intel
ninja_platform: mac
qt_platform: mac
openssl_arch: darwin64-x86_64-cc
cmake_flags: "-DUSE_SYSTEM_LIBSSH2=OFF -DUSE_SSH:STRING=localbuild -DUSE_SYSTEM_QT=OFF"
cmake_env: {}
pack: 1
- name: win64
os: windows-latest
ninja_platform: win
qt_platform: windows
qt_arch: win64_msvc2019_64
openssl_arch: VC-WIN64A
msvc_arch: x64
cmake_flags: "-DUSE_SYSTEM_QT=OFF -DUSE_SYSTEM_LIBSSH2=OFF -DUSE_BUNDLED_ZLIB=1 -DUSE_SSH:STRING=localbuild -DUSE_SYSTEM_OPENSSL=OFF -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl"
cmake_env:
CMAKE_RC_FLAGS: "/C 1252"
pack: 1
steps:
# otherwise the testcases will fail, because signature is invalid
- name: Set git name and email
run: |
git config --global user.name "Your Name"
git config --global user.email "youremail@yourdomain.com"
git config --list
# Use GITHUB_ENV (allenevans/set-env no longer accepts CMAKE_FLAGS; triggers workflow annotations).
- name: Configure development build
if: github.ref_type != 'tag'
shell: bash
run: |
echo "CMAKE_FLAGS=-DDEV_BUILD=\"${{ github.ref_name }}\"" >> "$GITHUB_ENV"
- name: Checkout repository
uses: actions/checkout@v6
with:
submodules: recursive
- name: Install Perl
if: matrix.env.ninja_platform == 'win'
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.30'
- name: Install Libssh2
if: matrix.env.ninja_platform == 'linux'
run: |
sudo apt-get update
sudo apt-get -y install libssh2-1
sudo apt-get -y install libssh2-1-dev
- name: Install Qt
uses: jurplel/install-qt-action@v4.3.0
timeout-minutes: 10
with:
version: ${{ matrix.qt.version }}
target: desktop
host: ${{ matrix.env.qt_platform }}
arch: ${{ matrix.env.qt_arch }}
install-deps: true
modules: qtwebengine
- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@v6
with:
version: 1.11.1
platform: ${{ matrix.env.ninja_platform }}
destination: ninja
- name: Setup MSVC environment
if: matrix.env.ninja_platform == 'win'
uses: seanmiddleditch/gha-setup-vsdevenv@v5
with:
arch: ${{ matrix.env.msvc_arch }}
- name: Install NASM
if: matrix.env.ninja_platform == 'win'
uses: ilammy/setup-nasm@v1.2.0
# CPack uses NSIS on Windows (see pack/CMakeLists.txt); runners do not ship makensis.
- name: Install NSIS for CPack
if: matrix.env.ninja_platform == 'win'
shell: pwsh
run: |
choco install nsis -y
$nsis = @(
'C:\Program Files (x86)\NSIS',
'C:\Program Files\NSIS'
) | Where-Object { Test-Path $_ } | Select-Object -First 1
if ($nsis) { Add-Content $env:GITHUB_PATH $nsis }
- name: Build OpenSSL (Windows)
if: matrix.env.ninja_platform == 'win'
run: |
cd dep/openssl/openssl
perl Configure ${{ matrix.env.openssl_arch }}
nmake
- name: Configure Release
env: ${{ matrix.env.cmake_env }}
run: |
mkdir -p build/release
cd build/release
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DUPDATE_TRANSLATIONS=ON -DGITTYUP_CI_TESTS=ON ${{ env.CMAKE_FLAGS }} ${{ matrix.env.cmake_flags }} ../..
- name: Build Information
run: |
echo "ninja version: $(ninja --version)"
git --version
qmake --version
cmake --version
- name: Build
run: |
cd build/release
ninja package
# Command copied from flathub build process
- name: Validate appdata file
if: matrix.env.ninja_platform == 'linux'
run: |
echo "Show generated appdata file"
cat ./build/release/rsrc/linux/com.github.Murmele.Gittyup.appdata.xml
echo "Start validating appdata file"
sudo apt install flatpak
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
sudo flatpak install -y flathub org.flatpak.Builder
flatpak run --command=flatpak-builder-lint org.flatpak.Builder appstream ./build/release/rsrc/linux/com.github.Murmele.Gittyup.appdata.xml
- name: Publish build artifacts
if: matrix.env.pack
uses: actions/upload-artifact@v6
with:
path: build/release/pack/Gittyup-*
name: Gittyup ${{ matrix.env.name }}
# Publish only once!
- name: Publish version file
if: matrix.env.ninja_platform == 'linux'
uses: actions/upload-artifact@v6
with:
path: build/release/Version.txt
name: Gittyup-VERSION
- name: Check Version file
run: |
cd build/release
cat ./Version.txt
- name: Test
if: matrix.env.ninja_platform != 'win' && matrix.env.ninja_platform != 'mac'
run: |
sudo apt-get update
sudo apt-get install -y xvfb
cd build/release
xvfb-run -a ninja check --verbose
- name: Test (Windows)
if: matrix.env.ninja_platform == 'win'
run: |
cd build/release
ninja check_no_win32_offscreen
- name: Build Appimage
if: matrix.env.ninja_platform == 'linux'
run: |
cd build/release
sudo apt -y install appstream
sudo apt -y install libfuse2
sudo apt -y install libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxcb-cursor0 libxkbcommon0 libx11-xcb1
sudo apt -y install libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xinerama0 libxcb-xinput0 libxcb-xkb1 libxcb-xrm0 libxcb-xv0 libxcb-xvmc0 libxcb1
mkdir -p AppDir
DESTDIR=AppDir ninja install
# install-qt-action exports QT_ROOT_DIR to the actual install dir.
# aqt downloads the "linux_gcc_64" package but extracts it to "gcc_64",
# so the arch id and the on-disk dir name differ; prefer QT_ROOT_DIR.
export QTDIR=${QT_ROOT_DIR:-$RUNNER_WORKSPACE/Qt/${{ matrix.qt.version }}/${{ matrix.env.qt_arch }}}
export QT_ROOT_DIR=$QTDIR
rm -rf ./AppDir/usr/include/
strip ./AppDir/usr/bin/cmark ./AppDir/usr/bin/gittyup ./AppDir/usr/bin/gittyup-indexer ./AppDir/usr/bin/gittyup-relauncher
wget -c https://github.com/$(wget -q https://github.com/probonopd/go-appimage/releases/expanded_assets/continuous -O - | grep "appimagetool-.*-x86_64.AppImage" | head -n 1 | cut -d '"' -f 2)
chmod +x appimagetool-*.AppImage
echo Show QTDIR
ls $QTDIR
echo Show QTDIR plugins
ls $QTDIR/plugins
echo Show QTDIR plugins platforms
ls $QTDIR/plugins/platforms
QTDIR=$QTDIR ./appimagetool-*.AppImage -s deploy ./AppDir/usr/share/applications/*.desktop --appimage-extract-and-run # Bundle EVERYTHING
# Modify the AppDir: move ld-linux into the same directory as the payload application
# and change AppRun accordingly; so that, e.g., Qt qApp->applicationDirPath() works
mv ./AppDir/lib64/ld-${{ matrix.env.ld_library_arch }}.so.2 ./AppDir/usr/bin/
sed -i -e 's@^LD_LINUX.*@LD_LINUX=$(find "$HERE/usr/bin" -name "ld-*.so.*" | head -n 1)@g' ./AppDir/AppRun
rm ./AppDir/usr/share/metainfo/gittyup.appdata.xml
VERSION=$(cat ./Version.txt)
VERSION="$VERSION" ./appimagetool-*.AppImage ./AppDir # turn AppDir into AppImage
#ls -lh Gittyup-*
- name: Publish Appimage
if: matrix.env.ninja_platform == 'linux'
uses: actions/upload-artifact@v6
with:
path: build/release/Gittyup*.AppImage
name: GittyupAppImage
publish:
needs: [flatpak, build]
runs-on: ubuntu-latest # does not matter which
permissions:
contents: write
# a prerelase is created when pushing to master
# a release is created when a tag will be set
# last condition is the same as IS_RELEASE,
# but environment variables cannot be used outside of steps
# so it was copied to here too
if: ${{ github.ref == 'refs/heads/master' || (github.event_name == 'push' && github.ref_type == 'tag' && startswith(github.ref_name, 'gittyup_v')) }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v6
with:
path: artifacts
# version is exported from cmake to file
- name: Retrieve version
id: version
run: |
echo "VERSION=$(cat artifacts/Gittyup-VERSION/Version.txt)" >> "$GITHUB_OUTPUT"
# gh CLI avoids deprecated Node-based release actions (e.g. marvinpinto/action-automatic-releases).
- name: Update GitHub release (development)
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
shopt -s nullglob
flatpaks=(artifacts/GittyupFlatpak/*.flatpak)
appimages=(artifacts/GittyupAppImage/Gittyup*.AppImage)
windows_files=("artifacts/Gittyup win64"/Gittyup*.exe)
macos_files=("artifacts/Gittyup macos"/Gittyup*.dmg)
files=("${flatpaks[@]}" "${appimages[@]}" "${windows_files[@]}")
if [ ${#files[@]} -eq 0 ]; then
echo "No assets to upload."
exit 1
fi
if ! gh release view development --repo "${{ github.repository }}" >/dev/null 2>&1; then
gh release create development \
--repo "${{ github.repository }}" \
--prerelease \
--title "Latest Build (Development)" \
--target "${{ github.sha }}" \
"${files[@]}"
else
gh release upload development "${files[@]}" --repo "${{ github.repository }}" --clobber
fi
- name: Update GitHub release (version tag)
if: ${{ env.IS_RELEASE == 'true' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
shopt -s nullglob
TAG="${{ github.ref_name }}"
flatpaks=(artifacts/GittyupFlatpak/*.flatpak)
appimages=(artifacts/GittyupAppImage/Gittyup*.AppImage)
windows_files=("artifacts/Gittyup win64"/Gittyup*.exe)
macos_files=("artifacts/Gittyup macos"/Gittyup*.dmg)
files=("${flatpaks[@]}" "${appimages[@]}" "${windows_files[@]}")
if [ ${#files[@]} -eq 0 ]; then
echo "No assets to upload."
exit 1
fi
if ! gh release view "$TAG" --repo "${{ github.repository }}" >/dev/null 2>&1; then
gh release create "$TAG" \
--repo "${{ github.repository }}" \
--title "Gittyup Release ${{ steps.version.outputs.VERSION }}" \
--target "${{ github.sha }}" \
"${files[@]}"
else
gh release upload "$TAG" "${files[@]}" --repo "${{ github.repository }}" --clobber
fi
# needed otherwise the docs folder is not available
- name: Checkout repository
if: ${{ env.IS_RELEASE == 'true' }}
uses: actions/checkout@v6
# update github pages only if it is a release
- name: Deploy Github pages
if: ${{ env.IS_RELEASE == 'true' }}
uses: JamesIves/github-pages-deploy-action@v4.7.3
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs # The folder the action should deploy.