Asteria Qt CI / rebuild-images (linux-arm64) (push) Skipped
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-macos (push) Successful in 10s
Asteria Qt CI / test-macos (push) Successful in 39s
Asteria Qt CI / rebuild-images (linux-arm64) (pull_request) Skipped
Asteria Qt CI / rebuild-images (linux-x86_64) (pull_request) Skipped
Asteria Qt CI / rebuild-images (windows-arm64) (pull_request) Skipped
Asteria Qt CI / rebuild-images (windows-x86_64) (pull_request) Skipped
Asteria Qt CI / build-linux (push) Successful in 1m12s
Asteria Qt CI / build-linux (pull_request) Canceled after 0s
Asteria Qt CI / build-linux-arm64 (pull_request) Canceled after 0s
Asteria Qt CI / build-windows (pull_request) Canceled after 0s
Asteria Qt CI / build-windows-arm64 (pull_request) Canceled after 0s
Asteria Qt CI / build-macos (pull_request) Canceled after 0s
Asteria Qt CI / test-linux (pull_request) Canceled after 0s
Asteria Qt CI / test-macos (pull_request) Canceled after 0s
Asteria Qt CI / package-linux (pull_request) Canceled after 0s
Asteria Qt CI / package-linux-arm64 (pull_request) Canceled after 0s
Asteria Qt CI / package-windows (pull_request) Canceled after 0s
Asteria Qt CI / package-windows-arm64 (pull_request) Canceled after 0s
Asteria Qt CI / package-macos (pull_request) Canceled after 0s
Asteria Qt CI / release (pull_request) Canceled after 0s
Asteria Qt CI / build-site-image (pull_request) Canceled after 0s
Asteria Qt CI / package-windows (push) Successful in 23s
Asteria Qt CI / build-windows-arm64 (push) Successful in 1m29s
Asteria Qt CI / build-windows (push) Successful in 1m29s
Asteria Qt CI / build-linux-arm64 (push) Successful in 1m31s
Asteria Qt CI / package-windows-arm64 (push) Successful in 19s
Asteria Qt CI / package-macos (push) Successful in 56s
Asteria Qt CI / test-linux (push) Successful in 3m20s
Asteria Qt CI / package-linux-arm64 (push) Successful in 17s
Asteria Qt CI / package-linux (push) Successful in 17s
Asteria Qt CI / release (push) Skipped
Asteria Qt CI / build-site-image (push) Skipped
Instead of linking to ephemeral CI artifacts on a wiki, package each
master release's built binaries into a self-contained Nginx static site
container (`gitea.agel.dev/asteria/site:latest` and `:<version>`) via a
new `build-site-image` job in Gitea Actions.
Because the unprivileged `kaniko-builder` runner has no Node.js runtime
for artifact actions, the multi-stage `Dockerfile.site` fetches the
just-published `v<version>` release assets (permission-preserving Linux
`.AppImage.tar.gz` archives, Windows portable `.zip` packages, and
optional macOS `.dmg`) from the Gitea Release API inside a throwaway
Python builder stage and strips the temporary token file before copying
the static output into `nginx:1.27-alpine`.
HTML, CSS, and JS are kept as standalone static files under `site/`
with `{{PLACEHOLDER}}` tokens substituted by `generate-static-site.py`
alongside generated `manifest.json` and `downloads/SHA256SUMS`, allowing
the page layout and styling to be edited independently of the build
script.
460 lines
20 KiB
YAML
460 lines
20 KiB
YAML
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.ref == 'refs/heads/master' || github.ref_name == 'master') && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.rebuild_images)) }}
|
|
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: ${{ success() && (github.ref == 'refs/heads/master' || github.ref_name == 'master') && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.rebuild_images)) }}
|
|
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
|
|
|
|
# ── Build and push static website Docker image with release binaries (master only) ──
|
|
build-site-image:
|
|
if: ${{ success() && (github.ref == 'refs/heads/master' || github.ref_name == 'master') && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.rebuild_images)) }}
|
|
needs:
|
|
- release
|
|
runs-on: kaniko-builder
|
|
steps:
|
|
- name: Build and push static site 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
|
|
|
|
BUILT_VERSION="$(/busybox/tr -d '[:space:]' < src/VERSION)"
|
|
SHORT_SHA="$(printf '%.7s' "${GITHUB_SHA}")"
|
|
SERVER_URL="${GITHUB_SERVER_URL%/}"
|
|
REPO_URL="${SERVER_URL}/${GITHUB_REPOSITORY}"
|
|
RUN_URL="${REPO_URL}/actions/runs/${GITHUB_RUN_ID:-0}"
|
|
|
|
/busybox/mkdir -p src/site-input
|
|
printf '%s' "${BUILD_TOKEN}" > src/site-input/.gitea_token
|
|
|
|
/kaniko/executor \
|
|
--dockerfile=src/docker/Dockerfile.site \
|
|
--context=src \
|
|
--build-arg="ASTERIA_VERSION=${BUILT_VERSION}" \
|
|
--build-arg="CI_COMMIT_SHORT_SHA=${SHORT_SHA}" \
|
|
--build-arg="CI_COMMIT_REF_NAME=${GITHUB_REF_NAME:-master}" \
|
|
--build-arg="CI_RUN_ID=${GITHUB_RUN_ID:-0}" \
|
|
--build-arg="CI_RUN_URL=${RUN_URL}" \
|
|
--build-arg="CI_REPO_URL=${REPO_URL}" \
|
|
--build-arg="GITEA_API_URL=${SERVER_URL}/api/v1" \
|
|
--build-arg="GITEA_REPO=${GITHUB_REPOSITORY}" \
|
|
--destination="${IMAGE_PREFIX}/site:latest" \
|
|
--destination="${IMAGE_PREFIX}/site:${BUILT_VERSION}" \
|
|
--cleanup \
|
|
--ignore-path=/kaniko \
|
|
--ignore-path=/busybox \
|
|
--ignore-path=/data \
|
|
--ignore-path=/builds
|