Gitlab CI/CD
This commit is contained in:
2 files changed
+128
No files matched your search
+117
@@ -0,0 +1,117 @@
|
||||
stages:
|
||||
- build
|
||||
- wiki
|
||||
|
||||
# ── Linux native build ─────────────────────────────────────────────────────────
|
||||
build-linux:
|
||||
stage: build
|
||||
image: ubuntu:24.04
|
||||
variables:
|
||||
QT_VERSION: "6.10.1"
|
||||
QT_INSTALL_DIR: "/opt/qt"
|
||||
before_script:
|
||||
- apt-get update -qq
|
||||
- DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends
|
||||
python3 python3-pip cmake ninja-build pkg-config git
|
||||
build-essential libgl1-mesa-dev
|
||||
libuchardet-dev
|
||||
libquazip1-qt6-dev libminizip-dev
|
||||
libdjvulibre-dev libwpd-dev
|
||||
- pip3 install --quiet --break-system-packages aqtinstall
|
||||
# Qt6 for Linux — provides headers, libs, and host tools
|
||||
- aqt install-qt linux desktop ${QT_VERSION} linux_gcc_64
|
||||
--outputdir ${QT_INSTALL_DIR}
|
||||
script:
|
||||
- QT_DIR="${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64"
|
||||
- cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_PREFIX_PATH="${QT_DIR}"
|
||||
- cmake --build build-linux --target asteria-qt
|
||||
artifacts:
|
||||
name: "asteria-qt-linux-${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
- build-linux/asteria-qt
|
||||
expire_in: 1 day
|
||||
when: on_success
|
||||
|
||||
# ── Windows cross-compile build (MinGW-w64 + aqtinstall) ──────────────────────
|
||||
build-windows:
|
||||
stage: build
|
||||
image: ubuntu:24.04
|
||||
variables:
|
||||
QT_VERSION: "6.10.1"
|
||||
QT_INSTALL_DIR: "/opt/qt"
|
||||
SYSROOT: "/opt/mingw-sysroot"
|
||||
before_script:
|
||||
- apt-get update -qq
|
||||
- DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends
|
||||
python3 python3-pip cmake ninja-build pkg-config git
|
||||
gcc g++ mingw-w64
|
||||
- pip3 install --quiet --break-system-packages aqtinstall
|
||||
# Qt6 for Windows (MinGW 64-bit) — provides headers, import libs, and DLLs
|
||||
- aqt install-qt linux desktop ${QT_VERSION} win64_mingw
|
||||
--outputdir ${QT_INSTALL_DIR}
|
||||
# Qt6 host tools (moc, rcc, qmlimportscanner …) must run on Linux
|
||||
- aqt install-qt linux desktop ${QT_VERSION} linux_gcc_64
|
||||
--outputdir ${QT_INSTALL_DIR}
|
||||
# Build uchardet for MinGW from source
|
||||
- git clone --depth 1 https://github.com/freedesktop/uchardet.git /tmp/uchardet
|
||||
- cmake -B /tmp/uchardet-build /tmp/uchardet -G Ninja
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CI_PROJECT_DIR}/scripts/mingw-w64-toolchain.cmake
|
||||
-DCMAKE_INSTALL_PREFIX=${SYSROOT}
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
- cmake --build /tmp/uchardet-build
|
||||
- cmake --install /tmp/uchardet-build
|
||||
script:
|
||||
- QT_WIN_DIR="${QT_INSTALL_DIR}/${QT_VERSION}/mingw_64"
|
||||
- QT_HOST_DIR="${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64"
|
||||
- cmake -B build-windows -G Ninja
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CI_PROJECT_DIR}/scripts/mingw-w64-toolchain.cmake
|
||||
-DCMAKE_PREFIX_PATH="${QT_WIN_DIR};${SYSROOT}"
|
||||
-DCMAKE_FIND_ROOT_PATH="${QT_WIN_DIR};${SYSROOT}"
|
||||
-DQT_HOST_PATH="${QT_HOST_DIR}"
|
||||
- cmake --build build-windows --target asteria-qt
|
||||
artifacts:
|
||||
name: "asteria-qt-windows-${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
- build-windows/asteria-qt.exe
|
||||
expire_in: 1 day
|
||||
when: on_success
|
||||
|
||||
# ── Update wiki with latest dev build links ────────────────────────────────────
|
||||
update-wiki:
|
||||
stage: wiki
|
||||
image: alpine:latest
|
||||
needs:
|
||||
- build-linux
|
||||
- build-windows
|
||||
before_script:
|
||||
- apk add --no-cache curl jq
|
||||
script:
|
||||
- PROJECT_URL="https://gitlab.com/asteria-bookreader/asteria-qt"
|
||||
- API_URL="https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}"
|
||||
- ARTIFACTS_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw"
|
||||
- LINUX_URL="${ARTIFACTS_URL}/build-linux/asteria-qt?job=build-linux"
|
||||
- WINDOWS_URL="${ARTIFACTS_URL}/build-windows/asteria-qt.exe?job=build-windows"
|
||||
- WIKI_CONTENT=$(curl -sf --header "PRIVATE-TOKEN:${GITLAB_TOKEN}" "${API_URL}/wikis/Asteria" | jq -r '.content')
|
||||
- |
|
||||
NEW_SECTION=$(printf '## Latest dev builds\n\n> Updated automatically by pipeline [#%s](%s) from `%s` @ %s\n\n| Platform | Download |\n|----------|----------|\n| Linux (x86_64) | [asteria-qt](%s) |\n| Windows (x86_64) | [asteria-qt.exe](%s) |' \
|
||||
"${CI_PIPELINE_ID}" "${CI_PIPELINE_URL}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_SHORT_SHA}" \
|
||||
"${LINUX_URL}" "${WINDOWS_URL}")
|
||||
if printf '%s' "${WIKI_CONTENT}" | grep -q '^## Latest dev builds'; then
|
||||
UPDATED=$(printf '%s' "${WIKI_CONTENT}" | awk -v new="${NEW_SECTION}" '
|
||||
/^## Latest dev builds/ { found=1; printf "%s\n", new; next }
|
||||
found && /^## / { found=0 }
|
||||
!found { print }
|
||||
')
|
||||
else
|
||||
UPDATED=$(printf '%s\n\n%s' "${WIKI_CONTENT}" "${NEW_SECTION}")
|
||||
fi
|
||||
curl -sf -X PUT \
|
||||
--header "PRIVATE-TOKEN:${GITLAB_TOKEN}" \
|
||||
--header "Content-Type:application/json" \
|
||||
--data "$(jq -n --arg c "${UPDATED}" '{content:$c}')" \
|
||||
"${API_URL}/wikis/Asteria"
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
@@ -0,0 +1,11 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
|
||||
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
Reference in new issue
Block a user