swtich to gitea
Asteria Qt CI / rebuild-images (linux-x86_64) (push) Skipped
Asteria Qt CI / rebuild-images (windows-arm64) (push) Skipped
Asteria Qt CI / rebuild-images (windows-x86_64) (push) Skipped
Asteria Qt CI / build-linux (push) Canceled after 0s
Asteria Qt CI / build-linux-arm64 (push) Canceled after 0s
Asteria Qt CI / build-windows (push) Canceled after 0s
Asteria Qt CI / build-windows-arm64 (push) Canceled after 0s
Asteria Qt CI / build-macos (push) Canceled after 0s
Asteria Qt CI / test-linux (push) Canceled after 0s
Asteria Qt CI / test-macos (push) Canceled after 0s
Asteria Qt CI / package-linux (push) Canceled after 0s
Asteria Qt CI / package-linux-arm64 (push) Canceled after 0s
Asteria Qt CI / rebuild-images (linux-arm64) (push) Skipped
Asteria Qt CI / package-windows (push) Canceled after 0s
Asteria Qt CI / package-windows-arm64 (push) Canceled after 0s
Asteria Qt CI / package-macos (push) Canceled after 0s
Asteria Qt CI / release (push) Canceled after 0s
Asteria Qt CI / rebuild-images (linux-x86_64) (push) Skipped
Asteria Qt CI / rebuild-images (windows-arm64) (push) Skipped
Asteria Qt CI / rebuild-images (windows-x86_64) (push) Skipped
Asteria Qt CI / build-linux (push) Canceled after 0s
Asteria Qt CI / build-linux-arm64 (push) Canceled after 0s
Asteria Qt CI / build-windows (push) Canceled after 0s
Asteria Qt CI / build-windows-arm64 (push) Canceled after 0s
Asteria Qt CI / build-macos (push) Canceled after 0s
Asteria Qt CI / test-linux (push) Canceled after 0s
Asteria Qt CI / test-macos (push) Canceled after 0s
Asteria Qt CI / package-linux (push) Canceled after 0s
Asteria Qt CI / package-linux-arm64 (push) Canceled after 0s
Asteria Qt CI / rebuild-images (linux-arm64) (push) Skipped
Asteria Qt CI / package-windows (push) Canceled after 0s
Asteria Qt CI / package-windows-arm64 (push) Canceled after 0s
Asteria Qt CI / package-macos (push) Canceled after 0s
Asteria Qt CI / release (push) Canceled after 0s
This commit is contained in:
14 files changed
+975
-835
No files matched your search
@@ -0,0 +1,390 @@
|
|||||||
|
name: Asteria Qt CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "**"
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
rebuild_images:
|
||||||
|
description: "Rebuild and push CI runner images using unprivileged Kaniko (requires kaniko-builder runner)"
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# ── Optional manual Kaniko runner image rebuild (unprivileged, no Docker socket) ──
|
||||||
|
rebuild-images:
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' && inputs.rebuild_images }}
|
||||||
|
runs-on: kaniko-builder
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
max-parallel: 1
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- linux-x86_64
|
||||||
|
- linux-arm64
|
||||||
|
- windows-x86_64
|
||||||
|
- windows-arm64
|
||||||
|
steps:
|
||||||
|
- name: Build and push ${{ matrix.target }} runner image via Kaniko
|
||||||
|
shell: sh
|
||||||
|
env:
|
||||||
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||||
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||||
|
REGISTRY: gitea.agel.dev
|
||||||
|
IMAGE_PREFIX: gitea.agel.dev/asteria
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
export PATH="/kaniko:/busybox:/usr/local/bin"
|
||||||
|
cleanup() {
|
||||||
|
/busybox/mkdir -p /bin
|
||||||
|
/busybox/ln -sf /busybox/sh /bin/sh
|
||||||
|
rm -rf /kaniko/.docker/config.json src src.tar.gz || true
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
if [ -z "${BUILD_TOKEN}" ]; then
|
||||||
|
echo "ERROR: BUILD_TOKEN secret is not set" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOGIN_USER="${REGISTRY_USER:-${GITHUB_ACTOR}}"
|
||||||
|
AUTH_B64="$(printf '%s:%s' "${LOGIN_USER}" "${BUILD_TOKEN}" | /busybox/base64 | /busybox/tr -d '\n\r')"
|
||||||
|
/busybox/mkdir -p /kaniko/.docker
|
||||||
|
printf '{"auths":{"%s":{"auth":"%s"}}}\n' "${REGISTRY}" "${AUTH_B64}" > /kaniko/.docker/config.json
|
||||||
|
|
||||||
|
rm -rf src src.tar.gz
|
||||||
|
/busybox/mkdir -p src
|
||||||
|
ARCHIVE_URL="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
|
||||||
|
/busybox/wget -q --header="Authorization: token ${BUILD_TOKEN}" "${ARCHIVE_URL}" -O src.tar.gz
|
||||||
|
/busybox/tar -xzf src.tar.gz -C src --strip-components=1
|
||||||
|
rm -f src.tar.gz
|
||||||
|
|
||||||
|
IMAGE="${IMAGE_PREFIX}/build-${{ matrix.target }}:latest"
|
||||||
|
/kaniko/executor \
|
||||||
|
--dockerfile=src/docker/Dockerfile.build \
|
||||||
|
--context=src \
|
||||||
|
--target="${{ matrix.target }}" \
|
||||||
|
--build-arg=QT_VERSION=6.12.0 \
|
||||||
|
--destination="${IMAGE}" \
|
||||||
|
--cleanup \
|
||||||
|
--ignore-path=/kaniko \
|
||||||
|
--ignore-path=/busybox \
|
||||||
|
--ignore-path=/data \
|
||||||
|
--ignore-path=/builds
|
||||||
|
|
||||||
|
# ── Linux native build (x86_64) ──────────────────────────────────────────────
|
||||||
|
build-linux:
|
||||||
|
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.rebuild_images) }}
|
||||||
|
runs-on: linux-x86_64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Configure and build Linux x86_64
|
||||||
|
run: |
|
||||||
|
chmod +x scripts/compute-version.sh
|
||||||
|
ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
||||||
|
echo "Building Asteria version ${ASTERIA_VERSION}"
|
||||||
|
cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_PREFIX_PATH="${QT_LINUX_DIR}" \
|
||||||
|
-DASTERIA_VERSION="${ASTERIA_VERSION}"
|
||||||
|
cmake --build build-linux --target asteria-qt --parallel 4
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-linux-${{ github.sha }}
|
||||||
|
path: build-linux/asteria-qt
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
# ── Linux cross-compile build (ARM64) ────────────────────────────────────────
|
||||||
|
build-linux-arm64:
|
||||||
|
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.rebuild_images) }}
|
||||||
|
runs-on: linux-arm64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Configure and build Linux ARM64
|
||||||
|
run: |
|
||||||
|
chmod +x scripts/compute-version.sh
|
||||||
|
ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
||||||
|
echo "Building Asteria version ${ASTERIA_VERSION}"
|
||||||
|
cmake -B build-linux-arm64 -G Ninja \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE="${GITHUB_WORKSPACE}/scripts/linux-arm64-toolchain.cmake" \
|
||||||
|
-DCMAKE_PREFIX_PATH="${QT_LINUX_ARM64_DIR}" \
|
||||||
|
-DQT_HOST_PATH="${QT_LINUX_DIR}" \
|
||||||
|
-DASTERIA_VERSION="${ASTERIA_VERSION}"
|
||||||
|
cmake --build build-linux-arm64 --target asteria-qt --parallel 4
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-linux-arm64-${{ github.sha }}
|
||||||
|
path: build-linux-arm64/asteria-qt
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
# ── Windows cross-compile build (LLVM-MinGW x86_64) ─────────────────────────
|
||||||
|
build-windows:
|
||||||
|
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.rebuild_images) }}
|
||||||
|
runs-on: windows-x86_64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Configure and build Windows x86_64
|
||||||
|
run: |
|
||||||
|
chmod +x scripts/compute-version.sh
|
||||||
|
ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
||||||
|
echo "Building Asteria version ${ASTERIA_VERSION}"
|
||||||
|
PKG_CONFIG_PATH="${MINGW_SYSROOT}/lib/pkgconfig" cmake -B build-windows -G Ninja \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE="${GITHUB_WORKSPACE}/scripts/mingw-w64-toolchain.cmake" \
|
||||||
|
-DCMAKE_PREFIX_PATH="${QT_WINDOWS_DIR};${MINGW_SYSROOT}" \
|
||||||
|
-DCMAKE_FIND_ROOT_PATH="${QT_WINDOWS_DIR};${MINGW_SYSROOT}" \
|
||||||
|
-DQT_HOST_PATH="${QT_LINUX_DIR}" \
|
||||||
|
-DASTERIA_VERSION="${ASTERIA_VERSION}"
|
||||||
|
cmake --build build-windows --target asteria-qt --parallel 4
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-windows-${{ github.sha }}
|
||||||
|
path: build-windows/asteria-qt.exe
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
# ── Windows cross-compile build (LLVM-MinGW ARM64) ──────────────────────────
|
||||||
|
build-windows-arm64:
|
||||||
|
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.rebuild_images) }}
|
||||||
|
runs-on: windows-arm64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Configure and build Windows ARM64
|
||||||
|
run: |
|
||||||
|
chmod +x scripts/compute-version.sh
|
||||||
|
ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
||||||
|
echo "Building Asteria version ${ASTERIA_VERSION}"
|
||||||
|
PKG_CONFIG_PATH="${MINGW_ARM64_SYSROOT}/lib/pkgconfig" cmake -B build-windows-arm64 -G Ninja \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE="${GITHUB_WORKSPACE}/scripts/mingw-w64-arm64-toolchain.cmake" \
|
||||||
|
-DCMAKE_PREFIX_PATH="${QT_WINDOWS_ARM64_DIR};${MINGW_ARM64_SYSROOT}" \
|
||||||
|
-DCMAKE_FIND_ROOT_PATH="${QT_WINDOWS_ARM64_DIR};${MINGW_ARM64_SYSROOT}" \
|
||||||
|
-DQT_HOST_PATH="${QT_LINUX_DIR}" \
|
||||||
|
-DASTERIA_VERSION="${ASTERIA_VERSION}"
|
||||||
|
cmake --build build-windows-arm64 --target asteria-qt --parallel 4
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-windows-arm64-${{ github.sha }}
|
||||||
|
path: build-windows-arm64/asteria-qt.exe
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
# ── macOS native build (optional local runner) ───────────────────────────────
|
||||||
|
build-macos:
|
||||||
|
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.rebuild_images) }}
|
||||||
|
runs-on: macos-qt
|
||||||
|
continue-on-error: true
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Configure and build macOS
|
||||||
|
run: |
|
||||||
|
export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
|
||||||
|
export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
|
||||||
|
chmod +x scripts/compute-version.sh
|
||||||
|
ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
||||||
|
echo "Building Asteria version ${ASTERIA_VERSION}"
|
||||||
|
cmake -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_PREFIX_PATH="${QT_MACOS_DIR:-/opt/qt/6.12.0/macos}" \
|
||||||
|
-DASTERIA_VERSION="${ASTERIA_VERSION}"
|
||||||
|
cmake --build build-macos --target asteria-qt
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-macos-${{ github.sha }}
|
||||||
|
path: build-macos/asteria-qt.app
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
# ── Linux tests ──────────────────────────────────────────────────────────────
|
||||||
|
test-linux:
|
||||||
|
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.rebuild_images) }}
|
||||||
|
runs-on: linux-x86_64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Build and run CTest on Linux
|
||||||
|
run: |
|
||||||
|
cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_PREFIX_PATH="${QT_LINUX_DIR}"
|
||||||
|
cmake --build build-linux --parallel 4
|
||||||
|
QT_QPA_PLATFORM=offscreen ctest --test-dir build-linux --output-on-failure --parallel 4
|
||||||
|
|
||||||
|
# ── macOS tests (optional local runner) ──────────────────────────────────────
|
||||||
|
test-macos:
|
||||||
|
if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.rebuild_images) }}
|
||||||
|
runs-on: macos-qt
|
||||||
|
continue-on-error: true
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Build and run CTest on macOS
|
||||||
|
run: |
|
||||||
|
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.12.0/macos}"
|
||||||
|
cmake --build build-macos
|
||||||
|
QT_QPA_PLATFORM=offscreen ctest --test-dir build-macos --output-on-failure
|
||||||
|
|
||||||
|
# ── Package Linux x86_64 as AppImage ─────────────────────────────────────────
|
||||||
|
package-linux:
|
||||||
|
needs: [build-linux, test-linux]
|
||||||
|
runs-on: linux-x86_64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-linux-${{ github.sha }}
|
||||||
|
path: build-linux
|
||||||
|
- name: Package AppImage (x86_64)
|
||||||
|
run: |
|
||||||
|
chmod +x build-linux/asteria-qt packaging/package-linux.sh
|
||||||
|
JOBS=4 packaging/package-linux.sh build-linux "${QT_LINUX_DIR}" . x86_64
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-linux-appimage-${{ github.sha }}
|
||||||
|
path: |
|
||||||
|
Asteria-x86_64.AppImage
|
||||||
|
Asteria-x86_64.AppImage.tar.gz
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
# ── Package Linux ARM64 as AppImage ──────────────────────────────────────────
|
||||||
|
package-linux-arm64:
|
||||||
|
needs: [build-linux-arm64, test-linux]
|
||||||
|
runs-on: linux-arm64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-linux-arm64-${{ github.sha }}
|
||||||
|
path: build-linux-arm64
|
||||||
|
- name: Package AppImage (ARM64)
|
||||||
|
run: |
|
||||||
|
chmod +x build-linux-arm64/asteria-qt packaging/package-linux.sh
|
||||||
|
JOBS=4 packaging/package-linux.sh build-linux-arm64 "${QT_LINUX_ARM64_DIR}" . arm64
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-linux-arm64-appimage-${{ github.sha }}
|
||||||
|
path: |
|
||||||
|
Asteria-arm64.AppImage
|
||||||
|
Asteria-arm64.AppImage.tar.gz
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
# ── Package Windows x86_64 as portable zip ───────────────────────────────────
|
||||||
|
package-windows:
|
||||||
|
needs: [build-windows]
|
||||||
|
runs-on: windows-x86_64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-windows-${{ github.sha }}
|
||||||
|
path: build-windows
|
||||||
|
- name: Package Windows x86_64 zip
|
||||||
|
run: |
|
||||||
|
chmod +x packaging/package-windows.sh
|
||||||
|
packaging/package-windows.sh build-windows "${QT_WINDOWS_DIR}" "${MINGW_SYSROOT}" . x86_64
|
||||||
|
zip -r -9 asteria-qt-windows-x86_64.zip asteria-qt-windows
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-windows-zip-${{ github.sha }}
|
||||||
|
path: asteria-qt-windows-x86_64.zip
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
# ── Package Windows ARM64 as portable zip ────────────────────────────────────
|
||||||
|
package-windows-arm64:
|
||||||
|
needs: [build-windows-arm64]
|
||||||
|
runs-on: windows-arm64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-windows-arm64-${{ github.sha }}
|
||||||
|
path: build-windows-arm64
|
||||||
|
- name: Package Windows ARM64 zip
|
||||||
|
run: |
|
||||||
|
chmod +x packaging/package-windows.sh
|
||||||
|
packaging/package-windows.sh build-windows-arm64 "${QT_WINDOWS_ARM64_DIR}" "${MINGW_ARM64_SYSROOT}" . arm64
|
||||||
|
zip -r -9 asteria-qt-windows-arm64.zip asteria-qt-windows-arm64
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-windows-arm64-zip-${{ github.sha }}
|
||||||
|
path: asteria-qt-windows-arm64.zip
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
# ── Package macOS as DMG (optional local runner) ─────────────────────────────
|
||||||
|
package-macos:
|
||||||
|
needs: [build-macos, test-macos]
|
||||||
|
runs-on: macos-qt
|
||||||
|
continue-on-error: true
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-macos-${{ github.sha }}
|
||||||
|
path: build-macos/asteria-qt.app
|
||||||
|
- name: Package macOS DMG
|
||||||
|
env:
|
||||||
|
CODESIGN: "true"
|
||||||
|
run: |
|
||||||
|
export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
|
||||||
|
chmod +x build-macos/asteria-qt.app/Contents/MacOS/asteria-qt packaging/package-macos.sh
|
||||||
|
mkdir -p dist-macos
|
||||||
|
packaging/package-macos.sh build-macos "${QT_MACOS_DIR:-/opt/qt/6.12.0/macos}" dist-macos
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-macos-dmg-${{ github.sha }}
|
||||||
|
path: dist-macos/Asteria.dmg
|
||||||
|
retention-days: 1
|
||||||
|
- name: Attach DMG if master release already exists
|
||||||
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
|
||||||
|
continue-on-error: true
|
||||||
|
env:
|
||||||
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||||
|
run: |
|
||||||
|
chmod +x scripts/bump-version.sh
|
||||||
|
./scripts/bump-version.sh --attach-if-released --assets-dir dist-macos
|
||||||
|
|
||||||
|
# ── Publish Gitea Release, attach binaries, and bump VERSION (master only) ───
|
||||||
|
release:
|
||||||
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
|
||||||
|
needs:
|
||||||
|
- package-linux
|
||||||
|
- package-linux-arm64
|
||||||
|
- package-windows
|
||||||
|
- package-windows-arm64
|
||||||
|
runs-on: linux-x86_64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-linux-appimage-${{ github.sha }}
|
||||||
|
path: dist
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-linux-arm64-appimage-${{ github.sha }}
|
||||||
|
path: dist
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-windows-zip-${{ github.sha }}
|
||||||
|
path: dist
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: asteria-qt-windows-arm64-zip-${{ github.sha }}
|
||||||
|
path: dist
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
name: asteria-qt-macos-dmg-${{ github.sha }}
|
||||||
|
path: dist
|
||||||
|
- name: Remove unpacked AppImage duplicates before release upload
|
||||||
|
run: rm -f dist/*.AppImage
|
||||||
|
- name: Create Gitea Release, upload assets, and bump VERSION
|
||||||
|
env:
|
||||||
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||||
|
run: |
|
||||||
|
chmod +x scripts/bump-version.sh
|
||||||
|
./scripts/bump-version.sh --assets-dir dist
|
||||||
-536
@@ -1,536 +0,0 @@
|
|||||||
spec:
|
|
||||||
inputs:
|
|
||||||
FORCE_REBUILD_IMAGE:
|
|
||||||
description: "Force (true) or skip (false) building the runner image, even if files changed"
|
|
||||||
type: string
|
|
||||||
options:
|
|
||||||
- "auto"
|
|
||||||
- "true"
|
|
||||||
- "false"
|
|
||||||
default: "auto"
|
|
||||||
---
|
|
||||||
workflow:
|
|
||||||
auto_cancel:
|
|
||||||
on_new_commit: interruptible
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_TAG
|
|
||||||
when: never
|
|
||||||
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "true" || $FORCE_REBUILD_IMAGE == "true"'
|
|
||||||
variables:
|
|
||||||
CI_PIPELINE_TYPE: image-rebuild
|
|
||||||
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "false" || $FORCE_REBUILD_IMAGE == "false"'
|
|
||||||
variables:
|
|
||||||
CI_PIPELINE_TYPE: normal
|
|
||||||
- changes:
|
|
||||||
- docker/Dockerfile.build
|
|
||||||
- docker/entrypoint.sh
|
|
||||||
- scripts/download-mingw-arm64-qt.py
|
|
||||||
- scripts/install-deps-ubuntu.sh
|
|
||||||
- scripts/linux-arm64-toolchain.cmake
|
|
||||||
- scripts/mingw-w64-toolchain.cmake
|
|
||||||
- scripts/mingw-w64-arm64-toolchain.cmake
|
|
||||||
variables:
|
|
||||||
CI_PIPELINE_TYPE: image-rebuild
|
|
||||||
- variables:
|
|
||||||
CI_PIPELINE_TYPE: normal
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- build
|
|
||||||
- test
|
|
||||||
- package
|
|
||||||
- wiki
|
|
||||||
- release
|
|
||||||
|
|
||||||
variables:
|
|
||||||
GIT_CLEAN_FLAGS: -fdx
|
|
||||||
|
|
||||||
# ── Build split runner images and push to registry ─────────────────────────────
|
|
||||||
.build-docker-base:
|
|
||||||
stage: build
|
|
||||||
image: docker:27
|
|
||||||
services:
|
|
||||||
- docker:27-dind
|
|
||||||
variables:
|
|
||||||
DOCKER_TLS_CERTDIR: "/certs"
|
|
||||||
DOCKER_BUILDKIT: "1"
|
|
||||||
before_script:
|
|
||||||
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
|
|
||||||
script:
|
|
||||||
- docker build
|
|
||||||
--pull
|
|
||||||
--build-arg QT_VERSION=6.12.0
|
|
||||||
--build-arg BUILDKIT_INLINE_CACHE=1
|
|
||||||
--cache-from "${DOCKER_IMAGE}"
|
|
||||||
--target "${DOCKER_TARGET}"
|
|
||||||
-t "${DOCKER_IMAGE}"
|
|
||||||
-f docker/Dockerfile.build .
|
|
||||||
- docker push "${DOCKER_IMAGE}"
|
|
||||||
|
|
||||||
build-docker-linux-x86_64:
|
|
||||||
extends: .build-docker-base
|
|
||||||
variables:
|
|
||||||
DOCKER_TARGET: "linux-x86_64"
|
|
||||||
DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-linux-x86_64:latest"
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE != "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "true" || $FORCE_REBUILD_IMAGE == "true"'
|
|
||||||
when: on_success
|
|
||||||
- changes:
|
|
||||||
- docker/Dockerfile.build
|
|
||||||
- docker/entrypoint.sh
|
|
||||||
- scripts/install-deps-ubuntu.sh
|
|
||||||
when: on_success
|
|
||||||
|
|
||||||
build-docker-linux-arm64:
|
|
||||||
extends: .build-docker-base
|
|
||||||
variables:
|
|
||||||
DOCKER_TARGET: "linux-arm64"
|
|
||||||
DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-linux-arm64:latest"
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE != "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "true" || $FORCE_REBUILD_IMAGE == "true"'
|
|
||||||
when: on_success
|
|
||||||
- changes:
|
|
||||||
- docker/Dockerfile.build
|
|
||||||
- docker/entrypoint.sh
|
|
||||||
- scripts/install-deps-ubuntu.sh
|
|
||||||
- scripts/linux-arm64-toolchain.cmake
|
|
||||||
when: on_success
|
|
||||||
|
|
||||||
build-docker-windows-x86_64:
|
|
||||||
extends: .build-docker-base
|
|
||||||
variables:
|
|
||||||
DOCKER_TARGET: "windows-x86_64"
|
|
||||||
DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-windows-x86_64:latest"
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE != "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "true" || $FORCE_REBUILD_IMAGE == "true"'
|
|
||||||
when: on_success
|
|
||||||
- changes:
|
|
||||||
- docker/Dockerfile.build
|
|
||||||
- docker/entrypoint.sh
|
|
||||||
- scripts/download-mingw-arm64-qt.py
|
|
||||||
- scripts/mingw-w64-toolchain.cmake
|
|
||||||
when: on_success
|
|
||||||
|
|
||||||
build-docker-windows-arm64:
|
|
||||||
extends: .build-docker-base
|
|
||||||
variables:
|
|
||||||
DOCKER_TARGET: "windows-arm64"
|
|
||||||
DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-windows-arm64:latest"
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE != "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "true" || $FORCE_REBUILD_IMAGE == "true"'
|
|
||||||
when: on_success
|
|
||||||
- changes:
|
|
||||||
- docker/Dockerfile.build
|
|
||||||
- docker/entrypoint.sh
|
|
||||||
- scripts/download-mingw-arm64-qt.py
|
|
||||||
- scripts/mingw-w64-arm64-toolchain.cmake
|
|
||||||
when: on_success
|
|
||||||
|
|
||||||
# ── Linux native build (x86_64) ────────────────────────────────────────────────
|
|
||||||
build-linux:
|
|
||||||
interruptible: true
|
|
||||||
tags:
|
|
||||||
- linux-x86_64
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- chmod +x scripts/compute-version.sh
|
|
||||||
- ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
|
||||||
- echo "Building Asteria version ${ASTERIA_VERSION}"
|
|
||||||
- cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
|
|
||||||
-DCMAKE_PREFIX_PATH="${QT_LINUX_DIR}"
|
|
||||||
-DASTERIA_VERSION="${ASTERIA_VERSION}"
|
|
||||||
- cmake --build build-linux --target asteria-qt --parallel 4
|
|
||||||
artifacts:
|
|
||||||
name: "asteria-qt-linux-${CI_COMMIT_SHORT_SHA}"
|
|
||||||
paths:
|
|
||||||
- build-linux/asteria-qt
|
|
||||||
expire_in: 1 day
|
|
||||||
when: on_success
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- when: on_success
|
|
||||||
|
|
||||||
# ── Linux cross-compile build (ARM64) ──────────────────────────────────────────
|
|
||||||
build-linux-arm64:
|
|
||||||
interruptible: true
|
|
||||||
tags:
|
|
||||||
- linux-arm64
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- chmod +x scripts/compute-version.sh
|
|
||||||
- ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
|
||||||
- echo "Building Asteria version ${ASTERIA_VERSION}"
|
|
||||||
- cmake -B build-linux-arm64 -G Ninja
|
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE="${CI_PROJECT_DIR}/scripts/linux-arm64-toolchain.cmake"
|
|
||||||
-DCMAKE_PREFIX_PATH="${QT_LINUX_ARM64_DIR}"
|
|
||||||
-DQT_HOST_PATH="${QT_LINUX_DIR}"
|
|
||||||
-DASTERIA_VERSION="${ASTERIA_VERSION}"
|
|
||||||
- cmake --build build-linux-arm64 --target asteria-qt --parallel 4
|
|
||||||
artifacts:
|
|
||||||
name: "asteria-qt-linux-arm64-${CI_COMMIT_SHORT_SHA}"
|
|
||||||
paths:
|
|
||||||
- build-linux-arm64/asteria-qt
|
|
||||||
expire_in: 1 day
|
|
||||||
when: on_success
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- when: on_success
|
|
||||||
|
|
||||||
# ── Windows cross-compile build (LLVM-MinGW x86_64) ───────────────────────────
|
|
||||||
build-windows:
|
|
||||||
interruptible: true
|
|
||||||
tags:
|
|
||||||
- windows-x86_64
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- chmod +x scripts/compute-version.sh
|
|
||||||
- ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
|
||||||
- echo "Building Asteria version ${ASTERIA_VERSION}"
|
|
||||||
- PKG_CONFIG_PATH="${MINGW_SYSROOT}/lib/pkgconfig" 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_WINDOWS_DIR};${MINGW_SYSROOT}"
|
|
||||||
-DCMAKE_FIND_ROOT_PATH="${QT_WINDOWS_DIR};${MINGW_SYSROOT}"
|
|
||||||
-DQT_HOST_PATH="${QT_LINUX_DIR}"
|
|
||||||
-DASTERIA_VERSION="${ASTERIA_VERSION}"
|
|
||||||
- cmake --build build-windows --target asteria-qt --parallel 4
|
|
||||||
artifacts:
|
|
||||||
name: "asteria-qt-windows-${CI_COMMIT_SHORT_SHA}"
|
|
||||||
paths:
|
|
||||||
- build-windows/asteria-qt.exe
|
|
||||||
expire_in: 1 day
|
|
||||||
when: on_success
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- when: on_success
|
|
||||||
|
|
||||||
# ── Windows cross-compile build (LLVM-MinGW ARM64) ────────────────────────────
|
|
||||||
build-windows-arm64:
|
|
||||||
interruptible: true
|
|
||||||
tags:
|
|
||||||
- windows-arm64
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- chmod +x scripts/compute-version.sh
|
|
||||||
- ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
|
||||||
- echo "Building Asteria version ${ASTERIA_VERSION}"
|
|
||||||
- PKG_CONFIG_PATH="${MINGW_ARM64_SYSROOT}/lib/pkgconfig" cmake -B build-windows-arm64 -G Ninja
|
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE="${CI_PROJECT_DIR}/scripts/mingw-w64-arm64-toolchain.cmake"
|
|
||||||
-DCMAKE_PREFIX_PATH="${QT_WINDOWS_ARM64_DIR};${MINGW_ARM64_SYSROOT}"
|
|
||||||
-DCMAKE_FIND_ROOT_PATH="${QT_WINDOWS_ARM64_DIR};${MINGW_ARM64_SYSROOT}"
|
|
||||||
-DQT_HOST_PATH="${QT_LINUX_DIR}"
|
|
||||||
-DASTERIA_VERSION="${ASTERIA_VERSION}"
|
|
||||||
- cmake --build build-windows-arm64 --target asteria-qt --parallel 4
|
|
||||||
artifacts:
|
|
||||||
name: "asteria-qt-windows-arm64-${CI_COMMIT_SHORT_SHA}"
|
|
||||||
paths:
|
|
||||||
- build-windows-arm64/asteria-qt.exe
|
|
||||||
expire_in: 1 day
|
|
||||||
when: on_success
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- 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:-}"
|
|
||||||
- chmod +x scripts/compute-version.sh
|
|
||||||
- ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
|
||||||
- echo "Building Asteria version ${ASTERIA_VERSION}"
|
|
||||||
- cmake -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release
|
|
||||||
-DCMAKE_PREFIX_PATH="${QT_MACOS_DIR:-/opt/qt/6.12.0/macos}"
|
|
||||||
-DASTERIA_VERSION="${ASTERIA_VERSION}"
|
|
||||||
- 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 ────────────────────────────────────────────────────────────────
|
|
||||||
test-linux:
|
|
||||||
interruptible: true
|
|
||||||
tags:
|
|
||||||
- linux-x86_64
|
|
||||||
stage: test
|
|
||||||
needs: []
|
|
||||||
script:
|
|
||||||
- cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
|
|
||||||
-DCMAKE_PREFIX_PATH="${QT_LINUX_DIR}"
|
|
||||||
- cmake --build build-linux --parallel 4
|
|
||||||
- QT_QPA_PLATFORM=offscreen ctest --test-dir build-linux --output-on-failure --parallel 4
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- 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.12.0/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 x86_64 as AppImage ───────────────────────────────────────────
|
|
||||||
package-linux:
|
|
||||||
interruptible: true
|
|
||||||
tags:
|
|
||||||
- linux-x86_64
|
|
||||||
stage: package
|
|
||||||
needs:
|
|
||||||
- build-linux
|
|
||||||
- test-linux
|
|
||||||
script:
|
|
||||||
- chmod +x packaging/package-linux.sh
|
|
||||||
- JOBS=4 packaging/package-linux.sh build-linux "${QT_LINUX_DIR}" . x86_64
|
|
||||||
artifacts:
|
|
||||||
name: "asteria-qt-linux-appimage-${CI_COMMIT_SHORT_SHA}"
|
|
||||||
paths:
|
|
||||||
- Asteria-x86_64.AppImage
|
|
||||||
- Asteria-x86_64.AppImage.tar.gz
|
|
||||||
expire_in: 1 day
|
|
||||||
when: on_success
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- when: on_success
|
|
||||||
|
|
||||||
# ── Package Linux ARM64 as AppImage ────────────────────────────────────────────
|
|
||||||
package-linux-arm64:
|
|
||||||
interruptible: true
|
|
||||||
tags:
|
|
||||||
- linux-arm64
|
|
||||||
stage: package
|
|
||||||
needs:
|
|
||||||
- build-linux-arm64
|
|
||||||
- test-linux
|
|
||||||
script:
|
|
||||||
- chmod +x packaging/package-linux.sh
|
|
||||||
- JOBS=4 packaging/package-linux.sh build-linux-arm64 "${QT_LINUX_ARM64_DIR}" . arm64
|
|
||||||
artifacts:
|
|
||||||
name: "asteria-qt-linux-arm64-appimage-${CI_COMMIT_SHORT_SHA}"
|
|
||||||
paths:
|
|
||||||
- Asteria-arm64.AppImage
|
|
||||||
- Asteria-arm64.AppImage.tar.gz
|
|
||||||
expire_in: 1 day
|
|
||||||
when: on_success
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- when: on_success
|
|
||||||
|
|
||||||
# ── Package Windows x86_64 as portable zip ───────────────────────────────────
|
|
||||||
package-windows:
|
|
||||||
interruptible: true
|
|
||||||
tags:
|
|
||||||
- windows-x86_64
|
|
||||||
stage: package
|
|
||||||
needs:
|
|
||||||
- build-windows
|
|
||||||
script:
|
|
||||||
- chmod +x packaging/package-windows.sh
|
|
||||||
- packaging/package-windows.sh build-windows "${QT_WINDOWS_DIR}" "${MINGW_SYSROOT}" . x86_64
|
|
||||||
artifacts:
|
|
||||||
name: "asteria-qt-windows-${CI_COMMIT_SHORT_SHA}"
|
|
||||||
paths:
|
|
||||||
- asteria-qt-windows/
|
|
||||||
expire_in: 1 day
|
|
||||||
when: on_success
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- when: on_success
|
|
||||||
|
|
||||||
# ── Package Windows ARM64 as portable zip ─────────────────────────────────────
|
|
||||||
package-windows-arm64:
|
|
||||||
interruptible: true
|
|
||||||
tags:
|
|
||||||
- windows-arm64
|
|
||||||
stage: package
|
|
||||||
needs:
|
|
||||||
- build-windows-arm64
|
|
||||||
script:
|
|
||||||
- chmod +x packaging/package-windows.sh
|
|
||||||
- packaging/package-windows.sh build-windows-arm64 "${QT_WINDOWS_ARM64_DIR}" "${MINGW_ARM64_SYSROOT}" . arm64
|
|
||||||
artifacts:
|
|
||||||
name: "asteria-qt-windows-arm64-${CI_COMMIT_SHORT_SHA}"
|
|
||||||
paths:
|
|
||||||
- asteria-qt-windows-arm64/
|
|
||||||
expire_in: 1 day
|
|
||||||
when: on_success
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- 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: "true"
|
|
||||||
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.12.0/macos}" .
|
|
||||||
artifacts:
|
|
||||||
name: "asteria-qt-macos-dmg-${CI_COMMIT_SHORT_SHA}"
|
|
||||||
paths:
|
|
||||||
- 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 (master only) ──────────────────────
|
|
||||||
update-wiki:
|
|
||||||
stage: wiki
|
|
||||||
tags:
|
|
||||||
- linux-x86_64
|
|
||||||
needs:
|
|
||||||
- job: package-linux
|
|
||||||
artifacts: false
|
|
||||||
- job: package-linux-arm64
|
|
||||||
artifacts: false
|
|
||||||
- job: package-windows
|
|
||||||
artifacts: false
|
|
||||||
- job: package-windows-arm64
|
|
||||||
artifacts: false
|
|
||||||
- job: package-macos
|
|
||||||
artifacts: false
|
|
||||||
optional: true
|
|
||||||
script:
|
|
||||||
- |
|
|
||||||
if [ "${CI_COMMIT_BRANCH:-}" != "master" ]; then
|
|
||||||
echo "Skipping wiki update: branch is '${CI_COMMIT_BRANCH:-unknown}', not 'master'."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
if [ -z "${GITLAB_TOKEN:-}" ]; then
|
|
||||||
echo "ERROR: GITLAB_TOKEN CI/CD variable is not set"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- chmod +x scripts/compute-version.sh
|
|
||||||
- ASTERIA_VERSION="$(./scripts/compute-version.sh)"
|
|
||||||
- PROJECT_URL="https://gitlab.com/asteria-bookreader/asteria-qt"
|
|
||||||
- API_URL="${CI_API_V4_URL:-https://gitlab.com/api/v4}/projects/${CI_PROJECT_ID}"
|
|
||||||
- WIKI_URL="${API_URL}/wikis/home"
|
|
||||||
- ARTIFACTS_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/download"
|
|
||||||
- LINUX_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria-x86_64.AppImage.tar.gz?job=package-linux"
|
|
||||||
- LINUX_ARM64_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria-arm64.AppImage.tar.gz?job=package-linux-arm64"
|
|
||||||
- WINDOWS_URL="${ARTIFACTS_URL}?job=package-windows"
|
|
||||||
- WINDOWS_ARM64_URL="${ARTIFACTS_URL}?job=package-windows-arm64"
|
|
||||||
- MACOS_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria.dmg?job=package-macos"
|
|
||||||
- |
|
|
||||||
HTTP_CODE=$(curl -s -o /tmp/wiki.json -w '%{http_code}' \
|
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
|
||||||
"${WIKI_URL}")
|
|
||||||
|
|
||||||
NEW_SECTION=$(printf '## Latest dev builds (v%s)\n\n> Updated automatically by pipeline [#%s](%s) from `%s` @ %s\n\n| Platform | Download |\n|----------|----------|\n| Linux (x86_64) | [AppImage (.tar.gz)](%s) |\n| Linux (ARM64) | [AppImage (.tar.gz)](%s) |\n| Windows (x86_64) | [Portable zip](%s) |\n| Windows (ARM64) | [Portable zip](%s) |\n| macOS | [DMG](%s) |' \
|
|
||||||
"${ASTERIA_VERSION}" "${CI_PIPELINE_ID}" "${CI_PIPELINE_URL}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_SHORT_SHA}" \
|
|
||||||
"${LINUX_URL}" "${LINUX_ARM64_URL}" "${WINDOWS_URL}" "${WINDOWS_ARM64_URL}" "${MACOS_URL}")
|
|
||||||
|
|
||||||
if [ "${HTTP_CODE}" = "200" ]; then
|
|
||||||
WIKI_CONTENT=$(jq -r '.content' /tmp/wiki.json)
|
|
||||||
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}')" \
|
|
||||||
"${WIKI_URL}"
|
|
||||||
else
|
|
||||||
echo "ERROR: GitLab API returned HTTP ${HTTP_CODE}"
|
|
||||||
cat /tmp/wiki.json
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE != "merge_request_event"
|
|
||||||
when: on_success
|
|
||||||
- when: never
|
|
||||||
|
|
||||||
# ── Bump VERSION, commit [skip ci], tag release, & rotate token if expiring ──
|
|
||||||
bump-version:
|
|
||||||
stage: release
|
|
||||||
tags:
|
|
||||||
- linux-x86_64
|
|
||||||
needs:
|
|
||||||
- job: package-linux
|
|
||||||
artifacts: false
|
|
||||||
- job: package-linux-arm64
|
|
||||||
artifacts: false
|
|
||||||
- job: package-windows
|
|
||||||
artifacts: false
|
|
||||||
- job: package-windows-arm64
|
|
||||||
artifacts: false
|
|
||||||
- job: package-macos
|
|
||||||
artifacts: false
|
|
||||||
optional: true
|
|
||||||
- job: update-wiki
|
|
||||||
artifacts: false
|
|
||||||
script:
|
|
||||||
- chmod +x scripts/bump-version.sh
|
|
||||||
- ./scripts/bump-version.sh
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
|
||||||
when: never
|
|
||||||
- if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE != "merge_request_event"
|
|
||||||
when: on_success
|
|
||||||
- when: never
|
|
||||||
@@ -120,15 +120,16 @@ packaging/package-linux.sh build-linux /opt/qt/6.12.0/gcc_64 dist x86_64
|
|||||||
packaging/package-linux.sh build-linux-arm64 /opt/qt/6.12.0/gcc_arm64 dist arm64
|
packaging/package-linux.sh build-linux-arm64 /opt/qt/6.12.0/gcc_arm64 dist arm64
|
||||||
```
|
```
|
||||||
|
|
||||||
### GitLab CI Split Docker Images (`docker/Dockerfile.build`)
|
### Gitea Actions Split Docker Runners (`docker/Dockerfile.build`, `docker/Dockerfile.kaniko`)
|
||||||
The CI environment is split into 4 multi-stage targets on `ubuntu:24.04` sharing a common `base` layer (core CLI tools, host `QT_LINUX_DIR` for `QT_HOST_PATH`, and `gitlab-runner`) plus `linux-base` / `windows-base` intermediate layers:
|
The CI environment is split into 4 build targets on `ubuntu:24.04` sharing a common `base` layer (core CLI tools, Node.js 20, host `QT_LINUX_DIR` for `QT_HOST_PATH`, and `act_runner` in host/shell mode) plus a dedicated unprivileged `kaniko-builder` runner (`docker/Dockerfile.kaniko`) based on `gcr.io/kaniko-project/executor:v1.23.2-debug`:
|
||||||
| Image | Docker `--target` | Runner Tag | Purpose |
|
| Image | Target / Dockerfile | Runner Label | Purpose |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `${CI_REGISTRY_IMAGE}/build-linux-x86_64:latest` | `linux-x86_64` | `linux-x86_64` | `build-linux`, `test-linux`, `package-linux`, `update-wiki` |
|
| `gitea.agel.dev/asteria/build-linux-x86_64:latest` | `linux-x86_64` (`Dockerfile.build`) | `linux-x86_64:host` | `build-linux`, `test-linux`, `package-linux`, `release` |
|
||||||
| `${CI_REGISTRY_IMAGE}/build-linux-arm64:latest` | `linux-arm64` | `linux-arm64` | `build-linux-arm64`, `package-linux-arm64` |
|
| `gitea.agel.dev/asteria/build-linux-arm64:latest` | `linux-arm64` (`Dockerfile.build`) | `linux-arm64:host` | `build-linux-arm64`, `package-linux-arm64` |
|
||||||
| `${CI_REGISTRY_IMAGE}/build-windows-x86_64:latest` | `windows-x86_64` | `windows-x86_64` | `build-windows`, `package-windows` |
|
| `gitea.agel.dev/asteria/build-windows-x86_64:latest` | `windows-x86_64` (`Dockerfile.build`) | `windows-x86_64:host` | `build-windows`, `package-windows` |
|
||||||
| `${CI_REGISTRY_IMAGE}/build-windows-arm64:latest` | `windows-arm64` | `windows-arm64` | `build-windows-arm64`, `package-windows-arm64` |
|
| `gitea.agel.dev/asteria/build-windows-arm64:latest` | `windows-arm64` (`Dockerfile.build`) | `windows-arm64:host` | `build-windows-arm64`, `package-windows-arm64` |
|
||||||
In `.gitlab-ci.yml`, `image-rebuild` pipelines rebuild only the affected target image(s) when relevant files change, or all 4 in parallel when `FORCE_REBUILD_IMAGE=true`.
|
| `gitea.agel.dev/asteria/build-kaniko:latest` | `Dockerfile.kaniko` | `kaniko-builder:host` | `rebuild-images` (`workflow_dispatch`, unprivileged) |
|
||||||
|
Each container runs `docker/entrypoint.sh` (or `docker/kaniko-entrypoint.sh`), which auto-registers with Gitea (`GITEA_INSTANCE_URL`, `GITEA_RUNNER_REGISTRATION_TOKEN`, `GITEA_RUNNER_NAME`, `GITEA_RUNNER_LABELS`) on first boot when `/data/.runner` is absent, generates `/data/config.yaml`, and starts `act_runner daemon`. In `.gitea/workflows/ci.yml`, `workflow_dispatch` (`rebuild_images=true`) runs on `kaniko-builder` to rebuild and push all 4 `Dockerfile.build` images to `gitea.agel.dev/asteria` using `BUILD_TOKEN` with zero extra capabilities, zero `security_opt`, and no Docker socket.
|
||||||
|
|
||||||
### macOS Build Environment
|
### macOS Build Environment
|
||||||
```bash
|
```bash
|
||||||
@@ -146,10 +147,10 @@ Packaging:
|
|||||||
```bash
|
```bash
|
||||||
packaging/package-macos.sh build /opt/qt/6.12.0/macos dist
|
packaging/package-macos.sh build /opt/qt/6.12.0/macos dist
|
||||||
```
|
```
|
||||||
Local GitLab Runner (shell executor):
|
Local Gitea Runner (host mode, `gitea-runner` / `act_runner`):
|
||||||
```bash
|
```bash
|
||||||
# First-time registration
|
# First-time registration
|
||||||
RUNNER_TOKEN="glrt-..." scripts/start-runner-macos.sh
|
RUNNER_TOKEN="<token>" scripts/start-runner-macos.sh
|
||||||
# Subsequent runs
|
# Subsequent runs
|
||||||
scripts/start-runner-macos.sh
|
scripts/start-runner-macos.sh
|
||||||
```
|
```
|
||||||
@@ -160,12 +161,12 @@ scripts/start-runner-macos.sh
|
|||||||
- **On `master`**: Reads and outputs `MAJOR.MINOR.PATCH` directly from `VERSION`.
|
- **On `master`**: Reads and outputs `MAJOR.MINOR.PATCH` directly from `VERSION`.
|
||||||
- **On feature branches**: Outputs a SemVer 2.0.0 pre-release string `MAJOR.MINOR.PATCH-<sanitized-branch>.<short-sha>` (e.g., `0.1.2-fix-epub.62c08ac`).
|
- **On feature branches**: Outputs a SemVer 2.0.0 pre-release string `MAJOR.MINOR.PATCH-<sanitized-branch>.<short-sha>` (e.g., `0.1.2-fix-epub.62c08ac`).
|
||||||
- **Build & Metadata Propagation**: `CMakeLists.txt` resolves `ASTERIA_VERSION` (or accepts `-DASTERIA_VERSION=...`), populates `PROJECT_VERSION`, `ASTERIA_VERSION_STRING`, `QApplication::applicationVersion()`, `AppInfo.version`, macOS bundle `Info.plist` (`CFBundleShortVersionString` / `CFBundleVersion`), and Windows `VS_VERSION_INFO` via `src/asteria.rc.in`.
|
- **Build & Metadata Propagation**: `CMakeLists.txt` resolves `ASTERIA_VERSION` (or accepts `-DASTERIA_VERSION=...`), populates `PROJECT_VERSION`, `ASTERIA_VERSION_STRING`, `QApplication::applicationVersion()`, `AppInfo.version`, macOS bundle `Info.plist` (`CFBundleShortVersionString` / `CFBundleVersion`), and Windows `VS_VERSION_INFO` via `src/asteria.rc.in`.
|
||||||
- **CI Isolation, Auto-Bump & Token Rotation (`.gitlab-ci.yml`, `scripts/bump-version.sh`)**:
|
- **CI Isolation, Gitea Releases & Auto-Bump (`.gitea/workflows/ci.yml`, `scripts/bump-version.sh`)**:
|
||||||
- `update-wiki` and `bump-version` run strictly on `master` (non-MR pipelines). Feature branches never update the wiki, create tags, or bump `VERSION`.
|
- `release` runs strictly on `push` to `master` (never on PRs or feature branches), using the `BUILD_TOKEN` org secret (`write:repository`, `write:package`).
|
||||||
- At the end of a successful `master` pipeline (`release` stage, after packaging and `update-wiki`), `bump-version` runs `scripts/bump-version.sh`:
|
- At the end of a successful `master` pipeline, `release` runs `scripts/bump-version.sh --assets-dir dist`:
|
||||||
1. Checks `GITLAB_TOKEN` expiration via GitLab API and, if within `TOKEN_ROTATE_THRESHOLD_DAYS` (default `30`) and the `GITLAB_TOKEN` CI/CD variable is API-writable, self-rotates the token and updates the CI/CD variable automatically.
|
1. Creates release tag `vX.Y.Z` and a Gitea Release at `GITHUB_SHA` via `/api/v1/repos/Asteria/asteria-qt/releases` (if absent).
|
||||||
2. Creates release tag `vX.Y.Z` at `CI_COMMIT_SHA` via the GitLab Tags API (if absent).
|
2. Uploads packaged binaries (`Asteria-x86_64.AppImage.tar.gz`, `Asteria-arm64.AppImage.tar.gz`, `asteria-qt-windows-x86_64.zip`, `asteria-qt-windows-arm64.zip`, and `Asteria.dmg` when the optional `macos-qt` runner is active) as release assets.
|
||||||
3. Increments `PATCH` in `VERSION` (`X.Y.(Z+1)`), commits `chore: bump version to ... [skip ci]` on `master` via the GitLab Repository Commits API (skipping if remote `VERSION` is already ahead). Tag pipelines (`$CI_COMMIT_TAG`) are skipped in `workflow: rules:` to prevent loops.
|
3. Increments `PATCH` in `VERSION` (`X.Y.(Z+1)`), committing `chore: bump version to ... [skip ci]` on `master` via the Gitea Contents API (`PUT /api/v1/repos/Asteria/asteria-qt/contents/VERSION`). Tag pushes do not trigger `push` branch workflows.
|
||||||
|
|
||||||
### 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:
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
Read AGENTS.md for project details.
|
|
||||||
|
|
||||||
ALWAYS try to compile and run tests after making code changes to ensure system integrity.
|
|
||||||
+43
-17
@@ -9,13 +9,16 @@ FROM ubuntu:24.04 AS base
|
|||||||
|
|
||||||
ARG QT_VERSION=6.12.0
|
ARG QT_VERSION=6.12.0
|
||||||
ARG QT_INSTALL_DIR=/opt/qt
|
ARG QT_INSTALL_DIR=/opt/qt
|
||||||
|
ARG ACT_RUNNER_VERSION=0.2.11
|
||||||
|
ARG NODE_VERSION=20.18.1
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
ENV QT_VERSION=${QT_VERSION}
|
ENV QT_VERSION=${QT_VERSION}
|
||||||
ENV QT_INSTALL_DIR=${QT_INSTALL_DIR}
|
ENV QT_INSTALL_DIR=${QT_INSTALL_DIR}
|
||||||
ENV QT_LINUX_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64
|
ENV QT_LINUX_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64
|
||||||
|
ENV PATH="/opt/node/bin:${PATH}"
|
||||||
|
|
||||||
# ── Core CLI tools, Qt host runtime libs, and host Qt 6 (QT_HOST_PATH) ─────────
|
# ── Core CLI tools and Qt host runtime libs ────────────────────────────────────
|
||||||
RUN apt-get update -qq && \
|
RUN apt-get update -qq && \
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
@@ -35,30 +38,53 @@ RUN apt-get update -qq && \
|
|||||||
pkg-config \
|
pkg-config \
|
||||||
python3 \
|
python3 \
|
||||||
python3-venv \
|
python3-venv \
|
||||||
|
unzip \
|
||||||
wget \
|
wget \
|
||||||
xz-utils \
|
xz-utils \
|
||||||
zip \
|
zip \
|
||||||
zstd \
|
zstd \
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
&& python3 -m venv /tmp/aqt-venv \
|
|
||||||
&& /tmp/aqt-venv/bin/pip install --quiet aqtinstall \
|
|
||||||
&& /tmp/aqt-venv/bin/aqt install-qt linux desktop "${QT_VERSION}" linux_gcc_64 \
|
|
||||||
-m qtimageformats --outputdir "${QT_INSTALL_DIR}" \
|
|
||||||
&& rm -rf /tmp/aqt-venv \
|
|
||||||
&& rm -rf \
|
|
||||||
"${QT_LINUX_DIR}/doc" \
|
|
||||||
"${QT_LINUX_DIR}/examples"
|
|
||||||
|
|
||||||
# ── gitlab-runner (shell executor) ─────────────────────────────────────────────
|
# ── Host Qt 6 (split into compact layers for reliable registry pushes) ──────────
|
||||||
RUN wget -q https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 \
|
RUN python3 -m venv /tmp/aqt-venv && \
|
||||||
-O /usr/local/bin/gitlab-runner && \
|
/tmp/aqt-venv/bin/pip install --quiet aqtinstall && \
|
||||||
chmod +x /usr/local/bin/gitlab-runner && \
|
/tmp/aqt-venv/bin/aqt install-qt linux desktop "${QT_VERSION}" linux_gcc_64 \
|
||||||
mkdir -p /etc/gitlab-runner /builds && \
|
--archives qtbase icu --outputdir "${QT_INSTALL_DIR}" && \
|
||||||
chmod 777 /builds
|
rm -rf /tmp/aqt-venv
|
||||||
|
|
||||||
|
RUN python3 -m venv /tmp/aqt-venv && \
|
||||||
|
/tmp/aqt-venv/bin/pip install --quiet aqtinstall && \
|
||||||
|
/tmp/aqt-venv/bin/aqt install-qt linux desktop "${QT_VERSION}" linux_gcc_64 \
|
||||||
|
-m qtimageformats --archives qtdeclarative qtsvg qttools qtwayland \
|
||||||
|
--outputdir "${QT_INSTALL_DIR}" && \
|
||||||
|
rm -rf /tmp/aqt-venv \
|
||||||
|
"${QT_LINUX_DIR}/doc" \
|
||||||
|
"${QT_LINUX_DIR}/examples" \
|
||||||
|
"${QT_LINUX_DIR}/sbom" \
|
||||||
|
"${QT_LINUX_DIR}/phrasebooks" \
|
||||||
|
"${QT_LINUX_DIR}/bin/qmlls" \
|
||||||
|
"${QT_LINUX_DIR}/lib/libQt6QmlLS.a" \
|
||||||
|
"${QT_LINUX_DIR}/lib/libQt6QmlDom.a"
|
||||||
|
|
||||||
|
# ── Node.js (required by Gitea/GitHub JS actions such as checkout/artifacts) ───
|
||||||
|
RUN curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" \
|
||||||
|
-o /tmp/node.tar.xz && \
|
||||||
|
mkdir -p /opt/node && \
|
||||||
|
tar -xJf /tmp/node.tar.xz -C /opt/node --strip-components=1 && \
|
||||||
|
rm -f /tmp/node.tar.xz && \
|
||||||
|
node --version
|
||||||
|
|
||||||
|
# ── Gitea act_runner (host/shell mode) ─────────────────────────────────────────
|
||||||
|
RUN wget -q "https://dl.gitea.com/act_runner/${ACT_RUNNER_VERSION}/act_runner-${ACT_RUNNER_VERSION}-linux-amd64" \
|
||||||
|
-O /usr/local/bin/act_runner && \
|
||||||
|
chmod +x /usr/local/bin/act_runner && \
|
||||||
|
mkdir -p /data /builds && \
|
||||||
|
chmod 777 /data /builds
|
||||||
|
|
||||||
COPY docker/entrypoint.sh /entrypoint.sh
|
COPY docker/entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
WORKDIR /data
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
CMD []
|
CMD []
|
||||||
|
|
||||||
@@ -84,7 +110,7 @@ RUN apt-get update -qq && \
|
|||||||
|
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Target 1: Linux x86_64 (native build, CTest, AppImage, wiki)
|
# Target 1: Linux x86_64 (native build, CTest, AppImage, release)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
FROM linux-base AS linux-x86_64
|
FROM linux-base AS linux-x86_64
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Dedicated unprivileged Kaniko image-builder runner for Gitea Actions.
|
||||||
|
# Requires zero extra Linux capabilities, zero security_opt, and no Docker socket.
|
||||||
|
# Target image: gitea.agel.dev/asteria/build-kaniko:latest
|
||||||
|
|
||||||
|
FROM gcr.io/kaniko-project/executor:v1.23.2-debug
|
||||||
|
|
||||||
|
ARG ACT_RUNNER_VERSION=0.2.11
|
||||||
|
|
||||||
|
ENV PATH="/kaniko:/busybox:/usr/local/bin"
|
||||||
|
|
||||||
|
ADD https://dl.gitea.com/act_runner/${ACT_RUNNER_VERSION}/act_runner-${ACT_RUNNER_VERSION}-linux-amd64 /kaniko/act_runner
|
||||||
|
RUN /busybox/chmod +x /kaniko/act_runner && \
|
||||||
|
/busybox/mkdir -p /data /builds /kaniko/.docker && \
|
||||||
|
/busybox/chmod 777 /data /builds
|
||||||
|
|
||||||
|
COPY docker/kaniko-entrypoint.sh /kaniko/entrypoint.sh
|
||||||
|
RUN /busybox/chmod +x /kaniko/entrypoint.sh
|
||||||
|
|
||||||
|
WORKDIR /data
|
||||||
|
ENTRYPOINT ["/busybox/sh", "/kaniko/entrypoint.sh"]
|
||||||
|
CMD []
|
||||||
Regular → Executable
+88
-16
@@ -1,19 +1,91 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -euo pipefail
|
||||||
|
|
||||||
# Auto-register if no config exists and env vars are provided
|
DATA_DIR="${GITEA_RUNNER_DATA_DIR:-/data}"
|
||||||
if [ ! -f /etc/gitlab-runner/config.toml ] && \
|
WORKDIR_PARENT="${GITEA_RUNNER_WORKDIR:-/builds}"
|
||||||
[ -n "${CI_SERVER_URL}" ] && [ -n "${REGISTRATION_TOKEN}" ]; then
|
CONFIG_FILE="${DATA_DIR}/config.yaml"
|
||||||
gitlab-runner register \
|
RUNNER_FILE="${DATA_DIR}/.runner"
|
||||||
--non-interactive \
|
|
||||||
--url "${CI_SERVER_URL}" \
|
INSTANCE_URL="${GITEA_INSTANCE_URL:-${CI_SERVER_URL:-}}"
|
||||||
--registration-token "${REGISTRATION_TOKEN}" \
|
REG_TOKEN="${GITEA_RUNNER_REGISTRATION_TOKEN:-${RUNNER_TOKEN:-${REGISTRATION_TOKEN:-}}}"
|
||||||
--executor shell \
|
RUNNER_NAME="${GITEA_RUNNER_NAME:-${RUNNER_NAME:-asteria-qt-runner}}"
|
||||||
--shell bash \
|
RAW_LABELS="${GITEA_RUNNER_LABELS:-${RUNNER_TAGS:-}}"
|
||||||
--description "${RUNNER_NAME:-asteria-qt-runner}" \
|
CAPACITY="${GITEA_RUNNER_CAPACITY:-1}"
|
||||||
--tag-list "${RUNNER_TAGS:-}" \
|
INSECURE="${GITEA_RUNNER_INSECURE:-false}"
|
||||||
--run-untagged="${RUNNER_RUN_UNTAGGED:-true}" \
|
|
||||||
--locked="${RUNNER_LOCKED:-false}"
|
mkdir -p "${DATA_DIR}" "${WORKDIR_PARENT}"
|
||||||
|
cd "${DATA_DIR}"
|
||||||
|
|
||||||
|
# Normalize labels: append ':host' when no executor suffix is specified so jobs
|
||||||
|
# run directly inside this container's pre-installed toolchain.
|
||||||
|
NORMALIZED_LABELS=()
|
||||||
|
if [ -n "${RAW_LABELS}" ]; then
|
||||||
|
IFS=',' read -ra _parts <<< "${RAW_LABELS}"
|
||||||
|
for lbl in "${_parts[@]}"; do
|
||||||
|
lbl="$(printf '%s' "${lbl}" | sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//')"
|
||||||
|
[ -z "${lbl}" ] && continue
|
||||||
|
if [[ "${lbl}" != *:* ]]; then
|
||||||
|
lbl="${lbl}:host"
|
||||||
|
fi
|
||||||
|
NORMALIZED_LABELS+=("${lbl}")
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec gitlab-runner run --working-directory=/builds
|
if [ ${#NORMALIZED_LABELS[@]} -eq 0 ]; then
|
||||||
|
NORMALIZED_LABELS=("linux-x86_64:host")
|
||||||
|
fi
|
||||||
|
|
||||||
|
LABELS_CSV="$(IFS=','; echo "${NORMALIZED_LABELS[*]}")"
|
||||||
|
|
||||||
|
# Always regenerate config.yaml from current environment variables
|
||||||
|
{
|
||||||
|
cat <<EOF
|
||||||
|
log:
|
||||||
|
level: info
|
||||||
|
|
||||||
|
runner:
|
||||||
|
file: ${RUNNER_FILE}
|
||||||
|
capacity: ${CAPACITY}
|
||||||
|
timeout: 3h
|
||||||
|
insecure: ${INSECURE}
|
||||||
|
fetch_timeout: 5s
|
||||||
|
fetch_interval: 2s
|
||||||
|
labels:
|
||||||
|
EOF
|
||||||
|
for lbl in "${NORMALIZED_LABELS[@]}"; do
|
||||||
|
printf ' - "%s"\n' "${lbl}"
|
||||||
|
done
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
cache:
|
||||||
|
enabled: true
|
||||||
|
dir: ${DATA_DIR}/cache
|
||||||
|
|
||||||
|
container:
|
||||||
|
network: ""
|
||||||
|
valid_volumes: []
|
||||||
|
|
||||||
|
host:
|
||||||
|
workdir_parent: ${WORKDIR_PARENT}
|
||||||
|
EOF
|
||||||
|
} > "${CONFIG_FILE}"
|
||||||
|
|
||||||
|
# Auto-register on first boot if .runner registration state does not exist
|
||||||
|
if [ ! -f "${RUNNER_FILE}" ]; then
|
||||||
|
if [ -z "${INSTANCE_URL}" ] || [ -z "${REG_TOKEN}" ]; then
|
||||||
|
echo "ERROR: ${RUNNER_FILE} not found and GITEA_INSTANCE_URL / GITEA_RUNNER_REGISTRATION_TOKEN are not set." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Registering Gitea runner '${RUNNER_NAME}' at '${INSTANCE_URL}' with labels '${LABELS_CSV}'..."
|
||||||
|
act_runner register \
|
||||||
|
--no-interactive \
|
||||||
|
--config "${CONFIG_FILE}" \
|
||||||
|
--instance "${INSTANCE_URL}" \
|
||||||
|
--token "${REG_TOKEN}" \
|
||||||
|
--name "${RUNNER_NAME}" \
|
||||||
|
--labels "${LABELS_CSV}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting Gitea act_runner daemon (name=${RUNNER_NAME}, labels=${LABELS_CSV})..."
|
||||||
|
exec act_runner daemon --config "${CONFIG_FILE}"
|
||||||
Executable
+98
@@ -0,0 +1,98 @@
|
|||||||
|
#!/busybox/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
export PATH="/kaniko:/busybox:/usr/local/bin"
|
||||||
|
|
||||||
|
# Ensure /bin/sh exists even if a prior Kaniko cleanup removed it
|
||||||
|
/busybox/mkdir -p /bin
|
||||||
|
/busybox/ln -sf /busybox/sh /bin/sh
|
||||||
|
|
||||||
|
DATA_DIR="${GITEA_RUNNER_DATA_DIR:-/data}"
|
||||||
|
WORKDIR_PARENT="${GITEA_RUNNER_WORKDIR:-/builds}"
|
||||||
|
CONFIG_FILE="${DATA_DIR}/config.yaml"
|
||||||
|
RUNNER_FILE="${DATA_DIR}/.runner"
|
||||||
|
|
||||||
|
INSTANCE_URL="${GITEA_INSTANCE_URL:-${CI_SERVER_URL:-}}"
|
||||||
|
REG_TOKEN="${GITEA_RUNNER_REGISTRATION_TOKEN:-${RUNNER_TOKEN:-${REGISTRATION_TOKEN:-}}}"
|
||||||
|
RUNNER_NAME="${GITEA_RUNNER_NAME:-asteria-kaniko-builder}"
|
||||||
|
RAW_LABELS="${GITEA_RUNNER_LABELS:-kaniko-builder:host}"
|
||||||
|
CAPACITY="${GITEA_RUNNER_CAPACITY:-1}"
|
||||||
|
INSECURE="${GITEA_RUNNER_INSECURE:-false}"
|
||||||
|
|
||||||
|
mkdir -p "${DATA_DIR}" "${WORKDIR_PARENT}"
|
||||||
|
cd "${DATA_DIR}"
|
||||||
|
|
||||||
|
# Normalize comma-separated labels in POSIX sh, appending ':host' when omitted
|
||||||
|
NORMALIZED_LABELS=""
|
||||||
|
OLD_IFS="$IFS"
|
||||||
|
IFS=','
|
||||||
|
for lbl in ${RAW_LABELS}; do
|
||||||
|
lbl="$(printf '%s' "${lbl}" | sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//')"
|
||||||
|
[ -z "${lbl}" ] && continue
|
||||||
|
case "${lbl}" in
|
||||||
|
*:*) ;;
|
||||||
|
*) lbl="${lbl}:host" ;;
|
||||||
|
esac
|
||||||
|
if [ -z "${NORMALIZED_LABELS}" ]; then
|
||||||
|
NORMALIZED_LABELS="${lbl}"
|
||||||
|
else
|
||||||
|
NORMALIZED_LABELS="${NORMALIZED_LABELS},${lbl}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS="$OLD_IFS"
|
||||||
|
|
||||||
|
if [ -z "${NORMALIZED_LABELS}" ]; then
|
||||||
|
NORMALIZED_LABELS="kaniko-builder:host"
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
cat <<EOF
|
||||||
|
log:
|
||||||
|
level: info
|
||||||
|
|
||||||
|
runner:
|
||||||
|
file: ${RUNNER_FILE}
|
||||||
|
capacity: ${CAPACITY}
|
||||||
|
timeout: 3h
|
||||||
|
insecure: ${INSECURE}
|
||||||
|
fetch_timeout: 5s
|
||||||
|
fetch_interval: 2s
|
||||||
|
labels:
|
||||||
|
EOF
|
||||||
|
IFS=','
|
||||||
|
for lbl in ${NORMALIZED_LABELS}; do
|
||||||
|
printf ' - "%s"\n' "${lbl}"
|
||||||
|
done
|
||||||
|
IFS="$OLD_IFS"
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
cache:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
container:
|
||||||
|
network: ""
|
||||||
|
valid_volumes: []
|
||||||
|
|
||||||
|
host:
|
||||||
|
workdir_parent: ${WORKDIR_PARENT}
|
||||||
|
EOF
|
||||||
|
} > "${CONFIG_FILE}"
|
||||||
|
|
||||||
|
if [ ! -f "${RUNNER_FILE}" ]; then
|
||||||
|
if [ -z "${INSTANCE_URL}" ] || [ -z "${REG_TOKEN}" ]; then
|
||||||
|
echo "ERROR: ${RUNNER_FILE} not found and GITEA_INSTANCE_URL / GITEA_RUNNER_REGISTRATION_TOKEN are not set." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Registering Gitea Kaniko runner '${RUNNER_NAME}' at '${INSTANCE_URL}' with labels '${NORMALIZED_LABELS}'..."
|
||||||
|
/kaniko/act_runner register \
|
||||||
|
--no-interactive \
|
||||||
|
--config "${CONFIG_FILE}" \
|
||||||
|
--instance "${INSTANCE_URL}" \
|
||||||
|
--token "${REG_TOKEN}" \
|
||||||
|
--name "${RUNNER_NAME}" \
|
||||||
|
--labels "${NORMALIZED_LABELS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting Gitea act_runner daemon for Kaniko (name=${RUNNER_NAME}, labels=${NORMALIZED_LABELS})..."
|
||||||
|
exec /kaniko/act_runner daemon --config "${CONFIG_FILE}"
|
||||||
+212
-192
@@ -1,10 +1,21 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# End-of-pipeline release automation for Asteria Qt (master branch only):
|
# End-of-pipeline release automation for Asteria Qt on Gitea (master branch only):
|
||||||
# 1. Checks GITLAB_TOKEN expiration and self-rotates + updates the GitLab CI/CD
|
# 1. Creates Gitea Release + Git tag v<BUILT_VERSION> at target commit (if absent).
|
||||||
# variable if expiry is within TOKEN_ROTATE_THRESHOLD_DAYS (default: 30).
|
# 2. Uploads packaged binaries from --assets-dir to the Gitea Release.
|
||||||
# 2. Creates release Git tag v<BUILT_VERSION> at CI_COMMIT_SHA (if absent).
|
# 3. Increments patch version in VERSION on the target branch via Gitea Contents
|
||||||
# 3. Increments patch version in VERSION on the target branch via GitLab
|
# API with [skip ci].
|
||||||
# Repository Commits API with [skip ci].
|
#
|
||||||
|
# Usage:
|
||||||
|
# scripts/bump-version.sh [--assets-dir <dir>] [--attach-if-released]
|
||||||
|
#
|
||||||
|
# Required environment:
|
||||||
|
# BUILD_TOKEN Gitea token with write:repository (and write:package)
|
||||||
|
#
|
||||||
|
# Optional environment (auto-populated by Gitea Actions):
|
||||||
|
# GITHUB_SERVER_URL Default: https://gitea.agel.dev
|
||||||
|
# GITHUB_REPOSITORY Default: Asteria/asteria-qt
|
||||||
|
# GITHUB_REF_NAME Branch name (must be master unless overridden)
|
||||||
|
# GITHUB_SHA Commit SHA to tag for the release
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
@@ -12,28 +23,60 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
PROJECT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
PROJECT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||||
cd "$PROJECT_DIR"
|
cd "$PROJECT_DIR"
|
||||||
|
|
||||||
|
ASSETS_DIR="${RELEASE_ASSETS_DIR:-}"
|
||||||
|
ATTACH_IF_RELEASED=false
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--assets-dir)
|
||||||
|
ASSETS_DIR="${2:?Missing value for --assets-dir}"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--attach-if-released)
|
||||||
|
ATTACH_IF_RELEASED=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
sed -n '2,18p' "$0" | sed 's/^# \{0,1\}//'
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Unknown argument: $1" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
DEFAULT_BRANCH="${CI_DEFAULT_BRANCH:-master}"
|
DEFAULT_BRANCH="${CI_DEFAULT_BRANCH:-master}"
|
||||||
TARGET_BRANCH="${CI_COMMIT_BRANCH:-}"
|
TARGET_BRANCH="${GITHUB_REF_NAME:-${CI_COMMIT_BRANCH:-}}"
|
||||||
TOKEN_ROTATE_THRESHOLD_DAYS="${TOKEN_ROTATE_THRESHOLD_DAYS:-30}"
|
if [ -z "$TARGET_BRANCH" ] && command -v git >/dev/null 2>&1; then
|
||||||
TOKEN_ROTATE_LIFETIME_DAYS="${TOKEN_ROTATE_LIFETIME_DAYS:-360}"
|
TARGET_BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$TARGET_BRANCH" != "$DEFAULT_BRANCH" ] && [ "$TARGET_BRANCH" != "master" ]; then
|
if [ "$TARGET_BRANCH" != "$DEFAULT_BRANCH" ] && [ "$TARGET_BRANCH" != "master" ]; then
|
||||||
echo "Skipping version bump: branch is '${TARGET_BRANCH:-unknown}', not '${DEFAULT_BRANCH}'."
|
echo "Skipping release/version bump: branch is '${TARGET_BRANCH:-unknown}', not '${DEFAULT_BRANCH}'."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${GITLAB_TOKEN:-}" ]; then
|
TOKEN="${BUILD_TOKEN:-${GITEA_TOKEN:-}}"
|
||||||
echo "ERROR: GITLAB_TOKEN CI/CD variable is not set" >&2
|
if [ -z "$TOKEN" ]; then
|
||||||
|
echo "ERROR: BUILD_TOKEN secret is not set" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${CI_PROJECT_ID:-}" ] || [ -z "${CI_COMMIT_SHA:-}" ]; then
|
COMMIT_SHA="${GITHUB_SHA:-${CI_COMMIT_SHA:-}}"
|
||||||
echo "ERROR: CI_PROJECT_ID and CI_COMMIT_SHA must be set" >&2
|
if [ -z "$COMMIT_SHA" ] && command -v git >/dev/null 2>&1; then
|
||||||
|
COMMIT_SHA="$(git rev-parse HEAD 2>/dev/null || true)"
|
||||||
|
fi
|
||||||
|
if [ -z "$COMMIT_SHA" ]; then
|
||||||
|
echo "ERROR: GITHUB_SHA / COMMIT_SHA is not set" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
API_ROOT="${CI_API_V4_URL:-https://gitlab.com/api/v4}"
|
SERVER_URL="${GITHUB_SERVER_URL:-https://gitea.agel.dev}"
|
||||||
PROJECT_API="${API_ROOT}/projects/${CI_PROJECT_ID}"
|
SERVER_URL="${SERVER_URL%/}"
|
||||||
|
REPO_PATH="${GITHUB_REPOSITORY:-Asteria/asteria-qt}"
|
||||||
|
API_URL="${SERVER_URL}/api/v1/repos/${REPO_PATH}"
|
||||||
|
|
||||||
WORK_TMP="$(mktemp -d)"
|
WORK_TMP="$(mktemp -d)"
|
||||||
cleanup() {
|
cleanup() {
|
||||||
@@ -74,172 +117,125 @@ increment_patch() {
|
|||||||
echo "${major}.${minor}.$((patch + 1))"
|
echo "${major}.${minor}.$((patch + 1))"
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_fresh_token() {
|
find_or_create_release() {
|
||||||
local info_file="${WORK_TMP}/token_self.json"
|
|
||||||
local info_code
|
|
||||||
info_code=$(curl -s -o "$info_file" -w '%{http_code}' \
|
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
|
||||||
"${API_ROOT}/personal_access_tokens/self")
|
|
||||||
|
|
||||||
if [ "$info_code" != "200" ]; then
|
|
||||||
echo "WARNING: Could not query token expiry (HTTP ${info_code}); proceeding with current GITLAB_TOKEN."
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local expires_at
|
|
||||||
expires_at="$(jq -r '.expires_at // empty' "$info_file")"
|
|
||||||
if [ -z "$expires_at" ]; then
|
|
||||||
echo "GITLAB_TOKEN has no expiration date; skipping rotation."
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local days_left
|
|
||||||
days_left="$(python3 - "$expires_at" <<'PY'
|
|
||||||
from datetime import date
|
|
||||||
import sys
|
|
||||||
exp = date.fromisoformat(sys.argv[1][:10])
|
|
||||||
print((exp - date.today()).days)
|
|
||||||
PY
|
|
||||||
)"
|
|
||||||
echo "GITLAB_TOKEN expires on ${expires_at} (${days_left} days remaining)."
|
|
||||||
|
|
||||||
if [ "$days_left" -gt "$TOKEN_ROTATE_THRESHOLD_DAYS" ]; then
|
|
||||||
echo "Token valid for more than ${TOKEN_ROTATE_THRESHOLD_DAYS} days; no rotation needed."
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Token expires within ${TOKEN_ROTATE_THRESHOLD_DAYS} days; checking CI/CD variable write access before rotating..."
|
|
||||||
|
|
||||||
local var_update_url=""
|
|
||||||
local group_id=""
|
|
||||||
local proj_var_code
|
|
||||||
proj_var_code=$(curl -s -o /dev/null -w '%{http_code}' \
|
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
|
||||||
"${PROJECT_API}/variables/GITLAB_TOKEN")
|
|
||||||
|
|
||||||
if [ "$proj_var_code" = "200" ]; then
|
|
||||||
var_update_url="${PROJECT_API}/variables/GITLAB_TOKEN"
|
|
||||||
else
|
|
||||||
local proj_info="${WORK_TMP}/project.json"
|
|
||||||
local proj_code
|
|
||||||
proj_code=$(curl -s -o "$proj_info" -w '%{http_code}' \
|
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
|
||||||
"${PROJECT_API}")
|
|
||||||
if [ "$proj_code" = "200" ]; then
|
|
||||||
local ns_kind
|
|
||||||
ns_kind="$(jq -r '.namespace.kind // empty' "$proj_info")"
|
|
||||||
if [ "$ns_kind" = "group" ]; then
|
|
||||||
group_id="$(jq -r '.namespace.id // empty' "$proj_info")"
|
|
||||||
if [ -n "$group_id" ]; then
|
|
||||||
local grp_var_code
|
|
||||||
grp_var_code=$(curl -s -o /dev/null -w '%{http_code}' \
|
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
|
||||||
"${API_ROOT}/groups/${group_id}/variables/GITLAB_TOKEN")
|
|
||||||
if [ "$grp_var_code" = "200" ]; then
|
|
||||||
var_update_url="${API_ROOT}/groups/${group_id}/variables/GITLAB_TOKEN"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$var_update_url" ]; then
|
|
||||||
echo "WARNING: GITLAB_TOKEN CI/CD variable is not accessible via API (project check HTTP ${proj_var_code}). Skipping rotation to avoid losing the rotated token."
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local new_expires_at
|
|
||||||
new_expires_at="$(python3 - "$TOKEN_ROTATE_LIFETIME_DAYS" <<'PY'
|
|
||||||
from datetime import date, timedelta
|
|
||||||
import sys
|
|
||||||
days = int(sys.argv[1])
|
|
||||||
print((date.today() + timedelta(days=days)).isoformat())
|
|
||||||
PY
|
|
||||||
)"
|
|
||||||
|
|
||||||
local rotate_urls=("${PROJECT_API}/access_tokens/self/rotate?expires_at=${new_expires_at}")
|
|
||||||
if [ -n "$group_id" ]; then
|
|
||||||
rotate_urls+=("${API_ROOT}/groups/${group_id}/access_tokens/self/rotate?expires_at=${new_expires_at}")
|
|
||||||
fi
|
|
||||||
rotate_urls+=("${API_ROOT}/personal_access_tokens/self/rotate?expires_at=${new_expires_at}")
|
|
||||||
|
|
||||||
local rotated_token=""
|
|
||||||
local rot_file="${WORK_TMP}/rotate_resp.json"
|
|
||||||
local rot_code=""
|
|
||||||
local url
|
|
||||||
for url in "${rotate_urls[@]}"; do
|
|
||||||
rot_code=$(curl -s -o "$rot_file" -w '%{http_code}' -X POST \
|
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
|
||||||
"$url")
|
|
||||||
if [ "$rot_code" = "200" ] || [ "$rot_code" = "201" ]; then
|
|
||||||
rotated_token="$(jq -r '.token // empty' "$rot_file")"
|
|
||||||
if [ -n "$rotated_token" ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -z "$rotated_token" ]; then
|
|
||||||
echo "ERROR: Failed to self-rotate GITLAB_TOKEN (last HTTP ${rot_code}):" >&2
|
|
||||||
jq 'del(.token)' "$rot_file" >&2 || true
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
export GITLAB_TOKEN="$rotated_token"
|
|
||||||
|
|
||||||
local put_file="${WORK_TMP}/var_put.json"
|
|
||||||
local put_code
|
|
||||||
put_code=$(jq -n --arg v "${GITLAB_TOKEN}" '{value: $v}' | \
|
|
||||||
curl -s -o "$put_file" -w '%{http_code}' -X PUT \
|
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
|
||||||
--header "Content-Type: application/json" \
|
|
||||||
--data-binary @- \
|
|
||||||
"$var_update_url")
|
|
||||||
|
|
||||||
if [ "$put_code" != "200" ]; then
|
|
||||||
echo "ERROR: Rotated GITLAB_TOKEN, but failed to persist new value to CI/CD variable (HTTP ${put_code}):" >&2
|
|
||||||
cat "$put_file" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Successfully self-rotated GITLAB_TOKEN (new expiry: ${new_expires_at}) and updated CI/CD variable."
|
|
||||||
}
|
|
||||||
|
|
||||||
create_release_tag() {
|
|
||||||
local built_version="$1"
|
local built_version="$1"
|
||||||
|
local create_if_missing="$2"
|
||||||
local tag_name="v${built_version}"
|
local tag_name="v${built_version}"
|
||||||
local encoded_tag
|
local rel_file="${WORK_TMP}/release.json"
|
||||||
encoded_tag="$(jq -rn --arg t "${tag_name}" '$t|@uri')"
|
|
||||||
|
|
||||||
local exists_code
|
local get_code
|
||||||
exists_code=$(curl -s -o /dev/null -w '%{http_code}' \
|
get_code=$(curl -s -o "$rel_file" -w '%{http_code}' \
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
--header "Authorization: token ${TOKEN}" \
|
||||||
"${PROJECT_API}/repository/tags/${encoded_tag}")
|
--header "Accept: application/json" \
|
||||||
|
"${API_URL}/releases/tags/${tag_name}")
|
||||||
|
|
||||||
if [ "$exists_code" = "200" ]; then
|
if [ "$get_code" = "200" ]; then
|
||||||
echo "Tag ${tag_name} already exists; skipping tag creation."
|
local rel_id
|
||||||
|
rel_id="$(jq -r '.id // empty' "$rel_file")"
|
||||||
|
if [ -n "$rel_id" ]; then
|
||||||
|
echo "Found existing Gitea release ${tag_name} (id=${rel_id})." >&2
|
||||||
|
printf '%s\n' "$rel_id"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$create_if_missing" != "true" ]; then
|
||||||
|
echo "Release ${tag_name} does not exist yet (HTTP ${get_code}); skipping asset upload." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local run_id="${GITHUB_RUN_ID:-0}"
|
||||||
|
local run_url="${SERVER_URL}/${REPO_PATH}/actions/runs/${run_id}"
|
||||||
|
local body
|
||||||
|
body="Automated build from \`${TARGET_BRANCH}\` @ \`${COMMIT_SHA:0:7}\` (run [#${run_id}](${run_url}))."
|
||||||
|
|
||||||
local tag_resp="${WORK_TMP}/tag_resp.json"
|
|
||||||
local create_code
|
local create_code
|
||||||
create_code=$(jq -n \
|
create_code=$(jq -n \
|
||||||
--arg tag "${tag_name}" \
|
--arg tag "${tag_name}" \
|
||||||
--arg ref "${CI_COMMIT_SHA}" \
|
--arg target "${COMMIT_SHA}" \
|
||||||
--arg msg "Release ${tag_name} (pipeline #${CI_PIPELINE_ID:-0})" \
|
--arg name "Asteria ${tag_name}" \
|
||||||
'{tag_name: $tag, ref: $ref, message: $msg}' | \
|
--arg body "${body}" \
|
||||||
curl -s -o "$tag_resp" -w '%{http_code}' -X POST \
|
'{
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
tag_name: $tag,
|
||||||
|
target_commitish: $target,
|
||||||
|
name: $name,
|
||||||
|
body: $body,
|
||||||
|
draft: false,
|
||||||
|
prerelease: false
|
||||||
|
}' | \
|
||||||
|
curl -s -o "$rel_file" -w '%{http_code}' -X POST \
|
||||||
|
--header "Authorization: token ${TOKEN}" \
|
||||||
--header "Content-Type: application/json" \
|
--header "Content-Type: application/json" \
|
||||||
|
--header "Accept: application/json" \
|
||||||
--data-binary @- \
|
--data-binary @- \
|
||||||
"${PROJECT_API}/repository/tags")
|
"${API_URL}/releases")
|
||||||
|
|
||||||
if [ "$create_code" = "201" ] || [ "$create_code" = "200" ]; then
|
if [ "$create_code" = "201" ] || [ "$create_code" = "200" ]; then
|
||||||
echo "Created release tag ${tag_name} at ${CI_COMMIT_SHA}"
|
local rel_id
|
||||||
else
|
rel_id="$(jq -r '.id // empty' "$rel_file")"
|
||||||
echo "ERROR: Failed to create tag ${tag_name} (HTTP ${create_code})" >&2
|
echo "Created Gitea release ${tag_name} at ${COMMIT_SHA:0:7} (id=${rel_id})." >&2
|
||||||
cat "$tag_resp" >&2
|
printf '%s\n' "$rel_id"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "ERROR: Failed to create release ${tag_name} (HTTP ${create_code}):" >&2
|
||||||
|
cat "$rel_file" >&2
|
||||||
return 1
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
upload_release_assets() {
|
||||||
|
local release_id="$1"
|
||||||
|
local dir="$2"
|
||||||
|
|
||||||
|
if [ -z "$dir" ] || [ ! -d "$dir" ]; then
|
||||||
|
echo "No assets directory provided or directory missing; skipping asset upload."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
local existing_assets="${WORK_TMP}/assets.json"
|
||||||
|
local list_code
|
||||||
|
list_code=$(curl -s -o "$existing_assets" -w '%{http_code}' \
|
||||||
|
--header "Authorization: token ${TOKEN}" \
|
||||||
|
--header "Accept: application/json" \
|
||||||
|
"${API_URL}/releases/${release_id}/assets")
|
||||||
|
|
||||||
|
local uploaded=0
|
||||||
|
local file
|
||||||
|
while IFS= read -r -d '' file; do
|
||||||
|
local fname
|
||||||
|
fname="$(basename "$file")"
|
||||||
|
|
||||||
|
# Delete pre-existing asset with same name so re-runs are idempotent
|
||||||
|
if [ "$list_code" = "200" ]; then
|
||||||
|
local existing_id
|
||||||
|
existing_id="$(jq -r --arg n "$fname" '.[] | select(.name == $n) | .id' "$existing_assets" | head -n1 || true)"
|
||||||
|
if [ -n "$existing_id" ]; then
|
||||||
|
curl -s -o /dev/null -X DELETE \
|
||||||
|
--header "Authorization: token ${TOKEN}" \
|
||||||
|
"${API_URL}/releases/${release_id}/assets/${existing_id}" || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
local up_resp="${WORK_TMP}/upload_resp.json"
|
||||||
|
local up_code
|
||||||
|
up_code=$(curl -s -o "$up_resp" -w '%{http_code}' -X POST \
|
||||||
|
--header "Authorization: token ${TOKEN}" \
|
||||||
|
--header "Accept: application/json" \
|
||||||
|
-F "attachment=@${file};filename=${fname}" \
|
||||||
|
"${API_URL}/releases/${release_id}/assets")
|
||||||
|
|
||||||
|
if [ "$up_code" = "201" ] || [ "$up_code" = "200" ]; then
|
||||||
|
echo "Uploaded release asset: ${fname}"
|
||||||
|
uploaded=$((uploaded + 1))
|
||||||
|
else
|
||||||
|
echo "ERROR: Failed to upload asset ${fname} (HTTP ${up_code}):" >&2
|
||||||
|
cat "$up_resp" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done < <(find "$dir" -maxdepth 2 -type f \( -name '*.tar.gz' -o -name '*.AppImage' -o -name '*.zip' -o -name '*.dmg' \) -print0 | sort -z)
|
||||||
|
|
||||||
|
if [ "$uploaded" -eq 0 ]; then
|
||||||
|
echo "WARNING: No release binary files found in ${dir}" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,50 +244,67 @@ commit_version_bump() {
|
|||||||
local encoded_branch
|
local encoded_branch
|
||||||
encoded_branch="$(jq -rn --arg b "${TARGET_BRANCH}" '$b|@uri')"
|
encoded_branch="$(jq -rn --arg b "${TARGET_BRANCH}" '$b|@uri')"
|
||||||
|
|
||||||
local base_version="$built_version"
|
local content_file="${WORK_TMP}/version_content.json"
|
||||||
local remote_ver_file="${WORK_TMP}/remote_version.txt"
|
local get_code
|
||||||
local raw_code
|
get_code=$(curl -s -o "$content_file" -w '%{http_code}' \
|
||||||
raw_code=$(curl -s -o "$remote_ver_file" -w '%{http_code}' \
|
--header "Authorization: token ${TOKEN}" \
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
--header "Accept: application/json" \
|
||||||
"${PROJECT_API}/repository/files/VERSION/raw?ref=${encoded_branch}")
|
"${API_URL}/contents/VERSION?ref=${encoded_branch}")
|
||||||
|
|
||||||
|
if [ "$get_code" != "200" ]; then
|
||||||
|
echo "ERROR: Failed to read remote VERSION from ${TARGET_BRANCH} (HTTP ${get_code}):" >&2
|
||||||
|
cat "$content_file" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local file_sha remote_b64 remote_version
|
||||||
|
file_sha="$(jq -r '.sha // empty' "$content_file")"
|
||||||
|
remote_b64="$(jq -r '.content // empty' "$content_file" | tr -d '\n\r ')"
|
||||||
|
remote_version="$(printf '%s' "$remote_b64" | (base64 -d 2>/dev/null || base64 -D) | tr -d '[:space:]')"
|
||||||
|
|
||||||
|
if [ -z "$file_sha" ] || [ -z "$remote_version" ]; then
|
||||||
|
echo "ERROR: Unexpected Gitea contents response for VERSION" >&2
|
||||||
|
cat "$content_file" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$raw_code" = "200" ]; then
|
|
||||||
local remote_version
|
|
||||||
remote_version="$(tr -d '[:space:]' < "$remote_ver_file")"
|
|
||||||
parse_semver "$remote_version"
|
parse_semver "$remote_version"
|
||||||
if semver_gt "$remote_version" "$built_version"; then
|
if semver_gt "$remote_version" "$built_version"; then
|
||||||
echo "Remote VERSION (${remote_version}) is already ahead of built version (${built_version}); skipping VERSION bump commit."
|
echo "Remote VERSION (${remote_version}) is already ahead of built version (${built_version}); skipping VERSION bump commit."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
base_version="$remote_version"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local next_version
|
local next_version
|
||||||
next_version="$(increment_patch "$base_version")"
|
next_version="$(increment_patch "$remote_version")"
|
||||||
|
local next_b64
|
||||||
|
next_b64="$(printf '%s\n' "$next_version" | base64 | tr -d '\n\r')"
|
||||||
|
|
||||||
local commit_resp="${WORK_TMP}/commit_resp.json"
|
local commit_resp="${WORK_TMP}/commit_resp.json"
|
||||||
local commit_code
|
local commit_code
|
||||||
commit_code=$(jq -n \
|
commit_code=$(jq -n \
|
||||||
--arg branch "${TARGET_BRANCH}" \
|
--arg branch "${TARGET_BRANCH}" \
|
||||||
--arg msg "chore: bump version to ${next_version} [skip ci]" \
|
--arg msg "chore: bump version to ${next_version} [skip ci]" \
|
||||||
--arg content "${next_version}"$'\n' \
|
--arg content "${next_b64}" \
|
||||||
|
--arg sha "${file_sha}" \
|
||||||
'{
|
'{
|
||||||
branch: $branch,
|
branch: $branch,
|
||||||
commit_message: $msg,
|
message: $msg,
|
||||||
actions: [{action: "update", file_path: "VERSION", content: $content}]
|
content: $content,
|
||||||
|
sha: $sha
|
||||||
}' | \
|
}' | \
|
||||||
curl -s -o "$commit_resp" -w '%{http_code}' -X POST \
|
curl -s -o "$commit_resp" -w '%{http_code}' -X PUT \
|
||||||
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
|
--header "Authorization: token ${TOKEN}" \
|
||||||
--header "Content-Type: application/json" \
|
--header "Content-Type: application/json" \
|
||||||
|
--header "Accept: application/json" \
|
||||||
--data-binary @- \
|
--data-binary @- \
|
||||||
"${PROJECT_API}/repository/commits")
|
"${API_URL}/contents/VERSION")
|
||||||
|
|
||||||
if [ "$commit_code" = "201" ] || [ "$commit_code" = "200" ]; then
|
if [ "$commit_code" = "200" ] || [ "$commit_code" = "201" ]; then
|
||||||
local commit_sha
|
local new_sha
|
||||||
commit_sha="$(jq -r '.short_id // .id // "unknown"' "$commit_resp")"
|
new_sha="$(jq -r '.commit.sha // "unknown"' "$commit_resp")"
|
||||||
echo "Bumped VERSION from ${base_version} to ${next_version} on ${TARGET_BRANCH} (${commit_sha})."
|
echo "Bumped VERSION from ${remote_version} to ${next_version} on ${TARGET_BRANCH} (${new_sha:0:7})."
|
||||||
else
|
else
|
||||||
echo "ERROR: Failed to commit VERSION bump to ${TARGET_BRANCH} (HTTP ${commit_code})" >&2
|
echo "ERROR: Failed to commit VERSION bump to ${TARGET_BRANCH} (HTTP ${commit_code}):" >&2
|
||||||
cat "$commit_resp" >&2
|
cat "$commit_resp" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -300,6 +313,13 @@ commit_version_bump() {
|
|||||||
BUILT_VERSION="$(tr -d '[:space:]' < VERSION)"
|
BUILT_VERSION="$(tr -d '[:space:]' < VERSION)"
|
||||||
parse_semver "$BUILT_VERSION"
|
parse_semver "$BUILT_VERSION"
|
||||||
|
|
||||||
ensure_fresh_token
|
if [ "$ATTACH_IF_RELEASED" = true ]; then
|
||||||
create_release_tag "$BUILT_VERSION"
|
if RELEASE_ID="$(find_or_create_release "$BUILT_VERSION" "false")"; then
|
||||||
|
upload_release_assets "$RELEASE_ID" "$ASSETS_DIR"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
RELEASE_ID="$(find_or_create_release "$BUILT_VERSION" "true")"
|
||||||
|
upload_release_assets "$RELEASE_ID" "$ASSETS_DIR"
|
||||||
commit_version_bump "$BUILT_VERSION"
|
commit_version_bump "$BUILT_VERSION"
|
||||||
@@ -58,8 +58,19 @@ MINOR="${BASH_REMATCH[2]}"
|
|||||||
PATCH="${BASH_REMATCH[3]}"
|
PATCH="${BASH_REMATCH[3]}"
|
||||||
|
|
||||||
# Determine current branch and short SHA
|
# Determine current branch and short SHA
|
||||||
BRANCH="${OVERRIDE_BRANCH:-${CI_COMMIT_BRANCH:-${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-${CI_COMMIT_REF_NAME:-}}}}"
|
GITEA_BRANCH=""
|
||||||
SHORT_SHA="${OVERRIDE_SHA:-${CI_COMMIT_SHORT_SHA:-}}"
|
if [ -n "${GITHUB_HEAD_REF:-}" ]; then
|
||||||
|
GITEA_BRANCH="${GITHUB_HEAD_REF}"
|
||||||
|
elif [ "${GITHUB_REF_TYPE:-}" != "tag" ] && [ -n "${GITHUB_REF_NAME:-}" ]; then
|
||||||
|
GITEA_BRANCH="${GITHUB_REF_NAME}"
|
||||||
|
fi
|
||||||
|
GITEA_SHORT_SHA=""
|
||||||
|
if [ -n "${GITHUB_SHA:-}" ]; then
|
||||||
|
GITEA_SHORT_SHA="${GITHUB_SHA:0:7}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
BRANCH="${OVERRIDE_BRANCH:-${GITEA_BRANCH:-${CI_COMMIT_BRANCH:-${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-${CI_COMMIT_REF_NAME:-}}}}}"
|
||||||
|
SHORT_SHA="${OVERRIDE_SHA:-${GITEA_SHORT_SHA:-${CI_COMMIT_SHORT_SHA:-}}}"
|
||||||
|
|
||||||
HAS_GIT=false
|
HAS_GIT=false
|
||||||
if command -v git >/dev/null 2>&1 && git -C "$PROJECT_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
if command -v git >/dev/null 2>&1 && git -C "$PROJECT_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
brew update
|
brew update
|
||||||
brew install cmake ninja pkg-config uchardet minizip libarchive gitlab-runner
|
brew install cmake ninja pkg-config uchardet minizip libarchive gitea-runner
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Installing Qt 6.12.0 via aqtinstall → /opt/qt ..."
|
echo "Installing Qt 6.12.0 via aqtinstall → /opt/qt ..."
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Start a local GitLab Runner for macOS builds (shell executor).
|
# Start a local Gitea Actions Runner for macOS builds (host mode).
|
||||||
#
|
#
|
||||||
# First-time registration usage:
|
# First-time registration usage:
|
||||||
# RUNNER_TOKEN="glrt-..." ./scripts/start-runner-macos.sh
|
# RUNNER_TOKEN="..." ./scripts/start-runner-macos.sh
|
||||||
# or with a legacy registration token:
|
|
||||||
# REGISTRATION_TOKEN="..." ./scripts/start-runner-macos.sh
|
|
||||||
#
|
#
|
||||||
# Subsequent runs (once config.toml exists):
|
# Subsequent runs (once .runner exists):
|
||||||
# ./scripts/start-runner-macos.sh
|
# ./scripts/start-runner-macos.sh
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -18,21 +16,32 @@ fi
|
|||||||
|
|
||||||
export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
|
export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
|
||||||
|
|
||||||
if ! command -v gitlab-runner >/dev/null 2>&1; then
|
RUNNER_BIN=""
|
||||||
|
if command -v gitea-runner >/dev/null 2>&1; then
|
||||||
|
RUNNER_BIN="gitea-runner"
|
||||||
|
elif command -v act_runner >/dev/null 2>&1; then
|
||||||
|
RUNNER_BIN="act_runner"
|
||||||
|
else
|
||||||
if ! command -v brew >/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
|
echo "ERROR: Homebrew is required to install gitea-runner. Please install Homebrew from https://brew.sh" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "gitlab-runner not found. Installing via Homebrew..."
|
echo "gitea-runner not found. Installing via Homebrew..."
|
||||||
brew install gitlab-runner
|
brew install gitea-runner
|
||||||
|
if command -v gitea-runner >/dev/null 2>&1; then
|
||||||
|
RUNNER_BIN="gitea-runner"
|
||||||
|
else
|
||||||
|
RUNNER_BIN="act_runner"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RUNNER_CONFIG_DIR="${RUNNER_CONFIG_DIR:-$HOME/.gitlab-runner}"
|
RUNNER_CONFIG_DIR="${RUNNER_CONFIG_DIR:-$HOME/.gitea-runner}"
|
||||||
CONFIG_FILE="${RUNNER_CONFIG_DIR}/config.toml"
|
CONFIG_FILE="${RUNNER_CONFIG_DIR}/config.yaml"
|
||||||
|
RUNNER_FILE="${RUNNER_CONFIG_DIR}/.runner"
|
||||||
RUNNER_WORKDIR="${RUNNER_WORKDIR:-${RUNNER_CONFIG_DIR}/builds}"
|
RUNNER_WORKDIR="${RUNNER_WORKDIR:-${RUNNER_CONFIG_DIR}/builds}"
|
||||||
CI_SERVER_URL="${CI_SERVER_URL:-https://gitlab.com}"
|
GITEA_INSTANCE_URL="${GITEA_INSTANCE_URL:-${CI_SERVER_URL:-https://gitea.agel.dev}}"
|
||||||
RUNNER_NAME="${RUNNER_NAME:-asteria-qt-macos-runner}"
|
RUNNER_NAME="${RUNNER_NAME:-asteria-qt-macos-runner}"
|
||||||
RUNNER_TAGS="${RUNNER_TAGS:-macos-qt}"
|
RUNNER_LABELS="${RUNNER_LABELS:-${RUNNER_TAGS:-macos-qt:host}}"
|
||||||
|
|
||||||
export QT_MACOS_DIR="${QT_MACOS_DIR:-/opt/qt/6.12.0/macos}"
|
export QT_MACOS_DIR="${QT_MACOS_DIR:-/opt/qt/6.12.0/macos}"
|
||||||
if command -v brew >/dev/null 2>&1; then
|
if command -v brew >/dev/null 2>&1; then
|
||||||
@@ -43,39 +52,48 @@ if command -v brew >/dev/null 2>&1; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "${RUNNER_CONFIG_DIR}" "${RUNNER_WORKDIR}"
|
mkdir -p "${RUNNER_CONFIG_DIR}" "${RUNNER_WORKDIR}"
|
||||||
|
cd "${RUNNER_CONFIG_DIR}"
|
||||||
|
|
||||||
if [ ! -f "${CONFIG_FILE}" ]; then
|
cat > "${CONFIG_FILE}" <<EOF
|
||||||
if [ -n "${RUNNER_TOKEN:-}" ]; then
|
log:
|
||||||
echo "Registering runner with authentication token..."
|
level: info
|
||||||
echo "NOTE: Ensure the runner in GitLab has the tag '${RUNNER_TAGS}' assigned."
|
|
||||||
gitlab-runner register \
|
runner:
|
||||||
--non-interactive \
|
file: ${RUNNER_FILE}
|
||||||
|
capacity: 1
|
||||||
|
timeout: 3h
|
||||||
|
insecure: false
|
||||||
|
fetch_timeout: 5s
|
||||||
|
fetch_interval: 2s
|
||||||
|
labels:
|
||||||
|
- "${RUNNER_LABELS}"
|
||||||
|
|
||||||
|
cache:
|
||||||
|
enabled: true
|
||||||
|
dir: ${RUNNER_CONFIG_DIR}/cache
|
||||||
|
|
||||||
|
host:
|
||||||
|
workdir_parent: ${RUNNER_WORKDIR}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ ! -f "${RUNNER_FILE}" ]; then
|
||||||
|
TOKEN="${RUNNER_TOKEN:-${GITEA_RUNNER_REGISTRATION_TOKEN:-${REGISTRATION_TOKEN:-}}}"
|
||||||
|
if [ -n "${TOKEN}" ]; then
|
||||||
|
echo "Registering Gitea runner '${RUNNER_NAME}' at '${GITEA_INSTANCE_URL}' with labels '${RUNNER_LABELS}'..."
|
||||||
|
"${RUNNER_BIN}" register \
|
||||||
|
--no-interactive \
|
||||||
--config "${CONFIG_FILE}" \
|
--config "${CONFIG_FILE}" \
|
||||||
--url "${CI_SERVER_URL}" \
|
--instance "${GITEA_INSTANCE_URL}" \
|
||||||
--token "${RUNNER_TOKEN}" \
|
--token "${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}" \
|
--name "${RUNNER_NAME}" \
|
||||||
--tag-list "${RUNNER_TAGS}" \
|
--labels "${RUNNER_LABELS}"
|
||||||
--run-untagged="${RUNNER_RUN_UNTAGGED:-false}" \
|
|
||||||
--locked="${RUNNER_LOCKED:-false}"
|
|
||||||
else
|
else
|
||||||
echo "ERROR: No runner configuration found at ${CONFIG_FILE}." >&2
|
echo "ERROR: No runner registration found at ${RUNNER_FILE}." >&2
|
||||||
echo "Provide RUNNER_TOKEN (glrt-...) or REGISTRATION_TOKEN to register first:" >&2
|
echo "Provide RUNNER_TOKEN from Gitea (Org/Repo Settings -> Actions -> Runners) to register first:" >&2
|
||||||
echo " RUNNER_TOKEN=glrt-... $0" >&2
|
echo " RUNNER_TOKEN=<token> $0" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Starting local macOS GitLab Runner (config: ${CONFIG_FILE}, workdir: ${RUNNER_WORKDIR})..."
|
echo "Starting local macOS Gitea Runner (bin: ${RUNNER_BIN}, config: ${CONFIG_FILE}, workdir: ${RUNNER_WORKDIR})..."
|
||||||
exec gitlab-runner run --config "${CONFIG_FILE}" --working-directory "${RUNNER_WORKDIR}"
|
exec "${RUNNER_BIN}" daemon --config "${CONFIG_FILE}"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Run Linux CI build/test/package jobs locally using podman or docker.
|
# Run Linux CI build/test/package jobs locally using podman or docker.
|
||||||
# Usage: test-ci-linux.sh [--build-image] [--image <tag>] [--arm64] [--only-arm64]
|
# Usage: test-ci-linux.sh [--build-image] [--push] [--image <tag>] [--arm64] [--only-arm64]
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"
|
export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"
|
||||||
@@ -9,15 +9,17 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|||||||
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
OUTPUT_DIR="$PROJECT_DIR/ci-output"
|
OUTPUT_DIR="$PROJECT_DIR/ci-output"
|
||||||
DOCKERFILE="$PROJECT_DIR/docker/Dockerfile.build"
|
DOCKERFILE="$PROJECT_DIR/docker/Dockerfile.build"
|
||||||
IMAGE_PREFIX="${PREBUILT_IMAGE_PREFIX:-registry.gitlab.com/asteria-bookreader/asteria-qt}"
|
IMAGE_PREFIX="${PREBUILT_IMAGE_PREFIX:-gitea.agel.dev/asteria}"
|
||||||
CUSTOM_IMAGE=""
|
CUSTOM_IMAGE=""
|
||||||
BUILD_IMAGE=false
|
BUILD_IMAGE=false
|
||||||
|
PUSH_IMAGE=false
|
||||||
RUN_X86_64=true
|
RUN_X86_64=true
|
||||||
RUN_ARM64=false
|
RUN_ARM64=false
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--build-image) BUILD_IMAGE=true; shift ;;
|
--build-image) BUILD_IMAGE=true; shift ;;
|
||||||
|
--push) PUSH_IMAGE=true; BUILD_IMAGE=true; shift ;;
|
||||||
--image) CUSTOM_IMAGE="$2"; shift 2 ;;
|
--image) CUSTOM_IMAGE="$2"; shift 2 ;;
|
||||||
--image=*) CUSTOM_IMAGE="${1#*=}"; shift ;;
|
--image=*) CUSTOM_IMAGE="${1#*=}"; shift ;;
|
||||||
--arm64) RUN_ARM64=true; shift ;;
|
--arm64) RUN_ARM64=true; shift ;;
|
||||||
@@ -37,11 +39,22 @@ else
|
|||||||
fi
|
fi
|
||||||
echo "Using container runtime: $RUNTIME"
|
echo "Using container runtime: $RUNTIME"
|
||||||
|
|
||||||
|
resolve_image_tag() {
|
||||||
|
local target="$1"
|
||||||
|
if [ -n "$CUSTOM_IMAGE" ]; then
|
||||||
|
echo "$CUSTOM_IMAGE"
|
||||||
|
elif [ "$BUILD_IMAGE" = true ] && [ "$PUSH_IMAGE" = false ]; then
|
||||||
|
echo "asteria-qt-ci-${target}:latest"
|
||||||
|
else
|
||||||
|
echo "${IMAGE_PREFIX}/build-${target}:latest"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
prepare_image() {
|
prepare_image() {
|
||||||
local target="$1"
|
local target="$1"
|
||||||
local image_tag="${CUSTOM_IMAGE:-${IMAGE_PREFIX}/build-${target}:latest}"
|
local image_tag
|
||||||
|
image_tag="$(resolve_image_tag "$target")"
|
||||||
if [ "$BUILD_IMAGE" = true ]; then
|
if [ "$BUILD_IMAGE" = true ]; then
|
||||||
image_tag="${CUSTOM_IMAGE:-asteria-qt-ci-${target}:latest}"
|
|
||||||
echo "==> Building CI image target '$target' ($image_tag) from $DOCKERFILE"
|
echo "==> Building CI image target '$target' ($image_tag) from $DOCKERFILE"
|
||||||
DOCKER_BUILDKIT=1 "$RUNTIME" build \
|
DOCKER_BUILDKIT=1 "$RUNTIME" build \
|
||||||
--platform linux/amd64 \
|
--platform linux/amd64 \
|
||||||
@@ -50,6 +63,10 @@ prepare_image() {
|
|||||||
-t "$image_tag" \
|
-t "$image_tag" \
|
||||||
-f "$DOCKERFILE" \
|
-f "$DOCKERFILE" \
|
||||||
"$PROJECT_DIR"
|
"$PROJECT_DIR"
|
||||||
|
if [ "$PUSH_IMAGE" = true ]; then
|
||||||
|
echo "==> Pushing CI image: $image_tag"
|
||||||
|
"$RUNTIME" push "$image_tag"
|
||||||
|
fi
|
||||||
elif ! "$RUNTIME" image inspect "$image_tag" &>/dev/null; then
|
elif ! "$RUNTIME" image inspect "$image_tag" &>/dev/null; then
|
||||||
echo "==> Pulling prebuilt CI image: $image_tag"
|
echo "==> Pulling prebuilt CI image: $image_tag"
|
||||||
"$RUNTIME" pull --platform linux/amd64 "$image_tag"
|
"$RUNTIME" pull --platform linux/amd64 "$image_tag"
|
||||||
@@ -81,8 +98,7 @@ run_in_container() {
|
|||||||
# ── Linux x86_64 build, test, and package ────────────────────────────────────
|
# ── Linux x86_64 build, test, and package ────────────────────────────────────
|
||||||
if [ "$RUN_X86_64" = true ]; then
|
if [ "$RUN_X86_64" = true ]; then
|
||||||
prepare_image "linux-x86_64"
|
prepare_image "linux-x86_64"
|
||||||
X64_IMAGE="${CUSTOM_IMAGE:-${IMAGE_PREFIX}/build-linux-x86_64:latest}"
|
X64_IMAGE="$(resolve_image_tag "linux-x86_64")"
|
||||||
[ "$BUILD_IMAGE" = true ] && X64_IMAGE="${CUSTOM_IMAGE:-asteria-qt-ci-linux-x86_64:latest}"
|
|
||||||
|
|
||||||
echo "==> build-linux & test-linux (x86_64)"
|
echo "==> build-linux & test-linux (x86_64)"
|
||||||
CI_SCRIPT='
|
CI_SCRIPT='
|
||||||
@@ -106,8 +122,7 @@ fi
|
|||||||
# ── Linux ARM64 build and package ────────────────────────────────────────────
|
# ── Linux ARM64 build and package ────────────────────────────────────────────
|
||||||
if [ "$RUN_ARM64" = true ]; then
|
if [ "$RUN_ARM64" = true ]; then
|
||||||
prepare_image "linux-arm64"
|
prepare_image "linux-arm64"
|
||||||
ARM64_IMAGE="${CUSTOM_IMAGE:-${IMAGE_PREFIX}/build-linux-arm64:latest}"
|
ARM64_IMAGE="$(resolve_image_tag "linux-arm64")"
|
||||||
[ "$BUILD_IMAGE" = true ] && ARM64_IMAGE="${CUSTOM_IMAGE:-asteria-qt-ci-linux-arm64:latest}"
|
|
||||||
|
|
||||||
echo "==> build-linux-arm64"
|
echo "==> build-linux-arm64"
|
||||||
CI_SCRIPT='
|
CI_SCRIPT='
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Run CI build/package jobs locally using podman or docker.
|
# Run CI build/package jobs locally using podman or docker.
|
||||||
# Usage: test-ci-windows.sh [--build-image] [--image <tag>] [--linux] [--arm64] [--only-arm64]
|
# Usage: test-ci-windows.sh [--build-image] [--push] [--image <tag>] [--linux] [--arm64] [--only-arm64]
|
||||||
# --build-image build the CI image target(s) from Dockerfile instead of pulling prebuilt ones
|
# --build-image build the CI image target(s) from Dockerfile instead of pulling prebuilt ones
|
||||||
|
# --push build and push the CI image target(s) to IMAGE_PREFIX (implies --build-image)
|
||||||
# --linux also run build-linux + package-linux (and arm64 if --arm64 is passed)
|
# --linux also run build-linux + package-linux (and arm64 if --arm64 is passed)
|
||||||
# --arm64 also run arm64 build + package jobs
|
# --arm64 also run arm64 build + package jobs
|
||||||
# --only-arm64 run only arm64 build + package jobs
|
# --only-arm64 run only arm64 build + package jobs
|
||||||
@@ -13,9 +14,10 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|||||||
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
OUTPUT_DIR="$PROJECT_DIR/ci-output"
|
OUTPUT_DIR="$PROJECT_DIR/ci-output"
|
||||||
DOCKERFILE="$PROJECT_DIR/docker/Dockerfile.build"
|
DOCKERFILE="$PROJECT_DIR/docker/Dockerfile.build"
|
||||||
IMAGE_PREFIX="${PREBUILT_IMAGE_PREFIX:-registry.gitlab.com/asteria-bookreader/asteria-qt}"
|
IMAGE_PREFIX="${PREBUILT_IMAGE_PREFIX:-gitea.agel.dev/asteria}"
|
||||||
CUSTOM_IMAGE=""
|
CUSTOM_IMAGE=""
|
||||||
BUILD_IMAGE=false
|
BUILD_IMAGE=false
|
||||||
|
PUSH_IMAGE=false
|
||||||
RUN_LINUX=false
|
RUN_LINUX=false
|
||||||
RUN_X86_64=true
|
RUN_X86_64=true
|
||||||
RUN_ARM64=false
|
RUN_ARM64=false
|
||||||
@@ -23,6 +25,7 @@ RUN_ARM64=false
|
|||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--build-image) BUILD_IMAGE=true; shift ;;
|
--build-image) BUILD_IMAGE=true; shift ;;
|
||||||
|
--push) PUSH_IMAGE=true; BUILD_IMAGE=true; shift ;;
|
||||||
--image) CUSTOM_IMAGE="$2"; shift 2 ;;
|
--image) CUSTOM_IMAGE="$2"; shift 2 ;;
|
||||||
--image=*) CUSTOM_IMAGE="${1#*=}"; shift ;;
|
--image=*) CUSTOM_IMAGE="${1#*=}"; shift ;;
|
||||||
--linux) RUN_LINUX=true; shift ;;
|
--linux) RUN_LINUX=true; shift ;;
|
||||||
@@ -47,7 +50,7 @@ resolve_image_tag() {
|
|||||||
local target="$1"
|
local target="$1"
|
||||||
if [ -n "$CUSTOM_IMAGE" ]; then
|
if [ -n "$CUSTOM_IMAGE" ]; then
|
||||||
echo "$CUSTOM_IMAGE"
|
echo "$CUSTOM_IMAGE"
|
||||||
elif [ "$BUILD_IMAGE" = true ]; then
|
elif [ "$BUILD_IMAGE" = true ] && [ "$PUSH_IMAGE" = false ]; then
|
||||||
echo "asteria-qt-ci-${target}:latest"
|
echo "asteria-qt-ci-${target}:latest"
|
||||||
else
|
else
|
||||||
echo "${IMAGE_PREFIX}/build-${target}:latest"
|
echo "${IMAGE_PREFIX}/build-${target}:latest"
|
||||||
@@ -67,6 +70,10 @@ prepare_image() {
|
|||||||
-t "$image_tag" \
|
-t "$image_tag" \
|
||||||
-f "$DOCKERFILE" \
|
-f "$DOCKERFILE" \
|
||||||
"$PROJECT_DIR"
|
"$PROJECT_DIR"
|
||||||
|
if [ "$PUSH_IMAGE" = true ]; then
|
||||||
|
echo "==> Pushing CI image: $image_tag"
|
||||||
|
"$RUNTIME" push "$image_tag"
|
||||||
|
fi
|
||||||
elif ! "$RUNTIME" image inspect "$image_tag" &>/dev/null; then
|
elif ! "$RUNTIME" image inspect "$image_tag" &>/dev/null; then
|
||||||
echo "==> Pulling prebuilt CI image: $image_tag"
|
echo "==> Pulling prebuilt CI image: $image_tag"
|
||||||
"$RUNTIME" pull --platform linux/amd64 "$image_tag"
|
"$RUNTIME" pull --platform linux/amd64 "$image_tag"
|
||||||
|
|||||||
Reference in new issue
Block a user