add macos ci build
This commit is contained in:
5 files changed
+193
-9
No files matched your search
+80
-2
@@ -125,12 +125,38 @@ build-windows-arm64:
|
|||||||
when: never
|
when: never
|
||||||
- when: on_success
|
- when: on_success
|
||||||
|
|
||||||
|
# ── macOS native build ─────────────────────────────────────────────────────────
|
||||||
|
build-macos:
|
||||||
|
interruptible: true
|
||||||
|
allow_failure: true
|
||||||
|
timeout: 10m
|
||||||
|
tags:
|
||||||
|
- macos-qt
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
|
||||||
|
- export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
|
||||||
|
- cmake -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||||
|
-DCMAKE_PREFIX_PATH="${QT_MACOS_DIR:-/opt/qt/6.10.3/macos}"
|
||||||
|
- cmake --build build-macos --target asteria-qt
|
||||||
|
artifacts:
|
||||||
|
name: "asteria-qt-macos-${CI_COMMIT_SHORT_SHA}"
|
||||||
|
paths:
|
||||||
|
- build-macos/asteria-qt.app
|
||||||
|
expire_in: 1 day
|
||||||
|
when: on_success
|
||||||
|
rules:
|
||||||
|
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
||||||
|
when: never
|
||||||
|
- when: on_success
|
||||||
|
|
||||||
# ── Linux tests ────────────────────────────────────────────────────────────────
|
# ── Linux tests ────────────────────────────────────────────────────────────────
|
||||||
test-linux:
|
test-linux:
|
||||||
interruptible: true
|
interruptible: true
|
||||||
tags:
|
tags:
|
||||||
- linux-qt
|
- linux-qt
|
||||||
stage: test
|
stage: test
|
||||||
|
needs: []
|
||||||
script:
|
script:
|
||||||
- cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
|
- cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||||
-DCMAKE_PREFIX_PATH="${QT_LINUX_DIR}"
|
-DCMAKE_PREFIX_PATH="${QT_LINUX_DIR}"
|
||||||
@@ -141,6 +167,27 @@ test-linux:
|
|||||||
when: never
|
when: never
|
||||||
- when: on_success
|
- when: on_success
|
||||||
|
|
||||||
|
# ── macOS tests ────────────────────────────────────────────────────────────────
|
||||||
|
test-macos:
|
||||||
|
interruptible: true
|
||||||
|
allow_failure: true
|
||||||
|
timeout: 10m
|
||||||
|
tags:
|
||||||
|
- macos-qt
|
||||||
|
stage: test
|
||||||
|
needs: []
|
||||||
|
script:
|
||||||
|
- export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
|
||||||
|
- export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
|
||||||
|
- cmake -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||||
|
-DCMAKE_PREFIX_PATH="${QT_MACOS_DIR:-/opt/qt/6.10.3/macos}"
|
||||||
|
- cmake --build build-macos
|
||||||
|
- QT_QPA_PLATFORM=offscreen ctest --test-dir build-macos --output-on-failure
|
||||||
|
rules:
|
||||||
|
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
||||||
|
when: never
|
||||||
|
- when: on_success
|
||||||
|
|
||||||
# ── Package Linux as AppImage ─────────────────────────────────────────────
|
# ── Package Linux as AppImage ─────────────────────────────────────────────
|
||||||
package-linux:
|
package-linux:
|
||||||
interruptible: true
|
interruptible: true
|
||||||
@@ -208,6 +255,34 @@ package-windows-arm64:
|
|||||||
when: never
|
when: never
|
||||||
- when: on_success
|
- when: on_success
|
||||||
|
|
||||||
|
# ── Package macOS as DMG ──────────────────────────────────────────────────────
|
||||||
|
package-macos:
|
||||||
|
interruptible: true
|
||||||
|
allow_failure: true
|
||||||
|
timeout: 10m
|
||||||
|
tags:
|
||||||
|
- macos-qt
|
||||||
|
stage: package
|
||||||
|
needs:
|
||||||
|
- build-macos
|
||||||
|
- test-macos
|
||||||
|
variables:
|
||||||
|
CODESIGN: "false"
|
||||||
|
script:
|
||||||
|
- export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
|
||||||
|
- chmod +x packaging/package-macos.sh
|
||||||
|
- packaging/package-macos.sh build-macos "${QT_MACOS_DIR:-/opt/qt/6.10.3/macos}" dist
|
||||||
|
artifacts:
|
||||||
|
name: "asteria-qt-macos-dmg-${CI_COMMIT_SHORT_SHA}"
|
||||||
|
paths:
|
||||||
|
- dist/Asteria.dmg
|
||||||
|
expire_in: 1 day
|
||||||
|
when: on_success
|
||||||
|
rules:
|
||||||
|
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
||||||
|
when: never
|
||||||
|
- when: on_success
|
||||||
|
|
||||||
# ── Update wiki with latest dev build links ────────────────────────────────────
|
# ── Update wiki with latest dev build links ────────────────────────────────────
|
||||||
update-wiki:
|
update-wiki:
|
||||||
stage: wiki
|
stage: wiki
|
||||||
@@ -217,6 +292,8 @@ update-wiki:
|
|||||||
- package-linux
|
- package-linux
|
||||||
- package-windows
|
- package-windows
|
||||||
- package-windows-arm64
|
- package-windows-arm64
|
||||||
|
- job: package-macos
|
||||||
|
optional: true
|
||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
if [ -z "${GITLAB_TOKEN}" ]; then
|
if [ -z "${GITLAB_TOKEN}" ]; then
|
||||||
@@ -230,14 +307,15 @@ update-wiki:
|
|||||||
- LINUX_URL="${ARTIFACTS_URL}?job=package-linux"
|
- LINUX_URL="${ARTIFACTS_URL}?job=package-linux"
|
||||||
- WINDOWS_URL="${ARTIFACTS_URL}?job=package-windows"
|
- WINDOWS_URL="${ARTIFACTS_URL}?job=package-windows"
|
||||||
- WINDOWS_ARM64_URL="${ARTIFACTS_URL}?job=package-windows-arm64"
|
- WINDOWS_ARM64_URL="${ARTIFACTS_URL}?job=package-windows-arm64"
|
||||||
|
- MACOS_URL="${ARTIFACTS_URL}?job=package-macos"
|
||||||
- |
|
- |
|
||||||
HTTP_CODE=$(curl -s -o /tmp/wiki.json -w '%{http_code}' \
|
HTTP_CODE=$(curl -s -o /tmp/wiki.json -w '%{http_code}' \
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
||||||
"${WIKI_URL}")
|
"${WIKI_URL}")
|
||||||
|
|
||||||
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) | [AppImage](%s) |\n| Windows (x86_64) | [Portable zip](%s) |\n| Windows (ARM64) | [Portable zip](%s) |' \
|
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) | [AppImage](%s) |\n| Windows (x86_64) | [Portable zip](%s) |\n| Windows (ARM64) | [Portable zip](%s) |\n| macOS | [DMG](%s) |' \
|
||||||
"${CI_PIPELINE_ID}" "${CI_PIPELINE_URL}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_SHORT_SHA}" \
|
"${CI_PIPELINE_ID}" "${CI_PIPELINE_URL}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_SHORT_SHA}" \
|
||||||
"${LINUX_URL}" "${WINDOWS_URL}" "${WINDOWS_ARM64_URL}")
|
"${LINUX_URL}" "${WINDOWS_URL}" "${WINDOWS_ARM64_URL}" "${MACOS_URL}")
|
||||||
|
|
||||||
if [ "${HTTP_CODE}" = "200" ]; then
|
if [ "${HTTP_CODE}" = "200" ]; then
|
||||||
WIKI_CONTENT=$(jq -r '.content' /tmp/wiki.json)
|
WIKI_CONTENT=$(jq -r '.content' /tmp/wiki.json)
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ ctest --test-dir build --output-on-failure
|
|||||||
|
|
||||||
### macOS Build Environment
|
### macOS Build Environment
|
||||||
```bash
|
```bash
|
||||||
|
scripts/install-deps-macos.sh
|
||||||
export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig:$PKG_CONFIG_PATH"
|
export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||||
cmake -B build -G Ninja \
|
cmake -B build -G Ninja \
|
||||||
-DCMAKE_BUILD_TYPE=Debug \
|
-DCMAKE_BUILD_TYPE=Debug \
|
||||||
@@ -103,6 +104,19 @@ cmake -B build -G Ninja \
|
|||||||
cmake --build build --parallel
|
cmake --build build --parallel
|
||||||
ctest --test-dir build --output-on-failure
|
ctest --test-dir build --output-on-failure
|
||||||
```
|
```
|
||||||
|
> If Homebrew package updates (e.g. `minizip`) invalidate cached Cellar paths, add `--fresh` (`cmake --fresh -B build ...` or `cmake --fresh --preset debug`) to reconfigure with a clean cache.
|
||||||
|
|
||||||
|
Packaging:
|
||||||
|
```bash
|
||||||
|
packaging/package-macos.sh build /opt/qt/6.10.3/macos dist
|
||||||
|
```
|
||||||
|
Local GitLab Runner (shell executor):
|
||||||
|
```bash
|
||||||
|
# First-time registration
|
||||||
|
RUNNER_TOKEN="glrt-..." scripts/start-runner-macos.sh
|
||||||
|
# Subsequent runs
|
||||||
|
scripts/start-runner-macos.sh
|
||||||
|
```
|
||||||
|
|
||||||
### VS Code & CMake Presets
|
### VS Code & CMake Presets
|
||||||
Pre-configured tasks, launch configurations, and CMake presets are available:
|
Pre-configured tasks, launch configurations, and CMake presets are available:
|
||||||
|
|||||||
@@ -10,15 +10,26 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|||||||
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
|
|
||||||
APP_PATH="$BUILD_DIR/asteria-qt.app"
|
APP_PATH="$BUILD_DIR/asteria-qt.app"
|
||||||
DMG_NAME="Asteria-macOS.dmg"
|
DMG_NAME="Asteria.dmg"
|
||||||
|
CODESIGN="${CODESIGN:-false}"
|
||||||
|
CODESIGN_IDENTITY="${CODESIGN_IDENTITY:--}"
|
||||||
|
|
||||||
|
if [ ! -d "$APP_PATH" ]; then
|
||||||
|
echo "ERROR: App bundle not found at $APP_PATH" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Deploy Qt frameworks into the .app bundle
|
# Deploy Qt frameworks into the .app bundle
|
||||||
"$QT_DIR/bin/macdeployqt" "$APP_PATH" -qmldir="$PROJECT_DIR/src/qml"
|
"$QT_DIR/bin/macdeployqt" "$APP_PATH" -qmldir="$PROJECT_DIR/src/qml"
|
||||||
|
|
||||||
# Create .dmg
|
if [ "$CODESIGN" = "true" ]; then
|
||||||
hdiutil create -volname "Asteria" -srcfolder "$APP_PATH" \
|
echo "Signing $APP_PATH with identity '$CODESIGN_IDENTITY'..."
|
||||||
-ov -format UDZO "$BUILD_DIR/$DMG_NAME"
|
codesign --force --deep --sign "$CODESIGN_IDENTITY" "$APP_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create .dmg directly in output directory
|
||||||
mkdir -p "$OUTPUT_DIR"
|
mkdir -p "$OUTPUT_DIR"
|
||||||
mv "$BUILD_DIR/$DMG_NAME" "$OUTPUT_DIR/"
|
hdiutil create -volname "Asteria" -srcfolder "$APP_PATH" \
|
||||||
|
-ov -format UDZO "$OUTPUT_DIR/$DMG_NAME"
|
||||||
|
|
||||||
echo "Created: $OUTPUT_DIR/$DMG_NAME"
|
echo "Created: $OUTPUT_DIR/$DMG_NAME"
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
brew update
|
brew update
|
||||||
brew install cmake ninja pkg-config uchardet minizip libarchive
|
brew install cmake ninja pkg-config uchardet minizip libarchive gitlab-runner
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Installing Qt 6.10.3 via aqtinstall → /opt/qt ..."
|
echo "Installing Qt 6.10.3 via aqtinstall → /opt/qt ..."
|
||||||
@@ -33,6 +33,6 @@ echo "Qt 6.10.3 is at $QT_DIR"
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Build with:"
|
echo "Build with:"
|
||||||
echo " PKG_CONFIG_PATH=\"\$(brew --prefix libarchive)/lib/pkgconfig:\$PKG_CONFIG_PATH\" \\"
|
echo " PKG_CONFIG_PATH=\"\$(brew --prefix libarchive)/lib/pkgconfig:\$PKG_CONFIG_PATH\" \\"
|
||||||
echo " cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$QT_DIR"
|
echo " cmake --fresh -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$QT_DIR"
|
||||||
echo " cmake --build build --parallel"
|
echo " cmake --build build --parallel"
|
||||||
echo " ctest --test-dir build --output-on-failure"
|
echo " ctest --test-dir build --output-on-failure"
|
||||||
Executable
+81
@@ -0,0 +1,81 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Start a local GitLab Runner for macOS builds (shell executor).
|
||||||
|
#
|
||||||
|
# First-time registration usage:
|
||||||
|
# RUNNER_TOKEN="glrt-..." ./scripts/start-runner-macos.sh
|
||||||
|
# or with a legacy registration token:
|
||||||
|
# REGISTRATION_TOKEN="..." ./scripts/start-runner-macos.sh
|
||||||
|
#
|
||||||
|
# Subsequent runs (once config.toml exists):
|
||||||
|
# ./scripts/start-runner-macos.sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ "$(uname -s)" != "Darwin" ]; then
|
||||||
|
echo "ERROR: This script is intended for macOS only." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
|
||||||
|
|
||||||
|
if ! command -v gitlab-runner >/dev/null 2>&1; then
|
||||||
|
if ! command -v brew >/dev/null 2>&1; then
|
||||||
|
echo "ERROR: Homebrew is required to install gitlab-runner. Please install Homebrew from https://brew.sh" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "gitlab-runner not found. Installing via Homebrew..."
|
||||||
|
brew install gitlab-runner
|
||||||
|
fi
|
||||||
|
|
||||||
|
RUNNER_CONFIG_DIR="${RUNNER_CONFIG_DIR:-$HOME/.gitlab-runner}"
|
||||||
|
CONFIG_FILE="${RUNNER_CONFIG_DIR}/config.toml"
|
||||||
|
RUNNER_WORKDIR="${RUNNER_WORKDIR:-${RUNNER_CONFIG_DIR}/builds}"
|
||||||
|
CI_SERVER_URL="${CI_SERVER_URL:-https://gitlab.com}"
|
||||||
|
RUNNER_NAME="${RUNNER_NAME:-asteria-qt-macos-runner}"
|
||||||
|
RUNNER_TAGS="${RUNNER_TAGS:-macos-qt}"
|
||||||
|
|
||||||
|
export QT_MACOS_DIR="${QT_MACOS_DIR:-/opt/qt/6.10.3/macos}"
|
||||||
|
if command -v brew >/dev/null 2>&1; then
|
||||||
|
LIBARCHIVE_PREFIX="$(brew --prefix libarchive 2>/dev/null || true)"
|
||||||
|
if [ -n "${LIBARCHIVE_PREFIX}" ] && [ -d "${LIBARCHIVE_PREFIX}/lib/pkgconfig" ]; then
|
||||||
|
export PKG_CONFIG_PATH="${LIBARCHIVE_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "${RUNNER_CONFIG_DIR}" "${RUNNER_WORKDIR}"
|
||||||
|
|
||||||
|
if [ ! -f "${CONFIG_FILE}" ]; then
|
||||||
|
if [ -n "${RUNNER_TOKEN:-}" ]; then
|
||||||
|
echo "Registering runner with authentication token..."
|
||||||
|
echo "NOTE: Ensure the runner in GitLab has the tag '${RUNNER_TAGS}' assigned."
|
||||||
|
gitlab-runner register \
|
||||||
|
--non-interactive \
|
||||||
|
--config "${CONFIG_FILE}" \
|
||||||
|
--url "${CI_SERVER_URL}" \
|
||||||
|
--token "${RUNNER_TOKEN}" \
|
||||||
|
--executor shell \
|
||||||
|
--shell bash \
|
||||||
|
--name "${RUNNER_NAME}"
|
||||||
|
elif [ -n "${REGISTRATION_TOKEN:-}" ]; then
|
||||||
|
echo "Registering runner with legacy registration token and tags '${RUNNER_TAGS}'..."
|
||||||
|
gitlab-runner register \
|
||||||
|
--non-interactive \
|
||||||
|
--config "${CONFIG_FILE}" \
|
||||||
|
--url "${CI_SERVER_URL}" \
|
||||||
|
--registration-token "${REGISTRATION_TOKEN}" \
|
||||||
|
--executor shell \
|
||||||
|
--shell bash \
|
||||||
|
--name "${RUNNER_NAME}" \
|
||||||
|
--tag-list "${RUNNER_TAGS}" \
|
||||||
|
--run-untagged="${RUNNER_RUN_UNTAGGED:-false}" \
|
||||||
|
--locked="${RUNNER_LOCKED:-false}"
|
||||||
|
else
|
||||||
|
echo "ERROR: No runner configuration found at ${CONFIG_FILE}." >&2
|
||||||
|
echo "Provide RUNNER_TOKEN (glrt-...) or REGISTRATION_TOKEN to register first:" >&2
|
||||||
|
echo " RUNNER_TOKEN=glrt-... $0" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting local macOS GitLab Runner (config: ${CONFIG_FILE}, workdir: ${RUNNER_WORKDIR})..."
|
||||||
|
exec gitlab-runner run --config "${CONFIG_FILE}" --working-directory "${RUNNER_WORKDIR}"
|
||||||
Reference in new issue
Block a user