Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/actions/build-container/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 'Build Container'
description: 'Builds and pushes the Linux Docker image'
inputs:
dockerfile:
description: 'Path to the Dockerfile'
required: true
tag:
description: 'Tag suffix for the image'
required: true
image-subdir:
description: 'Subdirectory to push image to'
default: 'cache'

outputs:
container-image-adress:
description: Address of container image
value: ${{ steps.set-image.outputs.image }}

runs:
using: "composite"
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set image names
id: set-image
shell: bash
run: |
image="ghcr.io/${{ github.repository }}/${{ inputs.image-subdir }}:${{ inputs.tag }}"
echo "image=$image" >> $GITHUB_OUTPUT
echo "cache_image=${image}-cache" >> $GITHUB_OUTPUT

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ${{ inputs.dockerfile }}
push: true
tags: ${{ steps.set-image.outputs.image }}
cache-from: type=registry,ref=${{ steps.set-image.outputs.cache_image }}
cache-to: type=registry,ref=${{ steps.set-image.outputs.cache_image }},mode=max
49 changes: 49 additions & 0 deletions .github/actions/build-cth/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: 'Build cth'
description: 'Handles Caching, Configuration, and Compilation'
inputs:
cache_prefix:
description: 'Cache Prefix e.g. OS'
required: true
preset:
description: 'CI preset from ci/CMakeUserPresets.json'
required: true

runs:
using: "composite"
steps:
# --- 1. setup vcpkg cache ---
- name: setup vcpkg
uses: ./.github/actions/setup-vcpkg-cache

# --- 2. configure ---
- name: Configure CMake
shell: bash
run: |
[ -f ci/CMakeUserPresets.json ] && cp ci/CMakeUserPresets.json CMakeUserPresets.json
cmake --preset ${{ inputs.preset }}

# --- 3. restore BuildCache ---
- name: Restore BuildCache
id: buildcache
uses: ./.github/actions/restore-cache
with:
path: .buildcache
key: buildcache-${{ inputs.cache_prefix }}-${{ inputs.preset }}-${{ github.run_id }}
restore-keys: buildcache-${{ inputs.cache_prefix }}-${{ inputs.preset }}-
global-tag: buildcache-${{ inputs.cache_prefix }}-${{ inputs.preset }}
gh-token: ${{ github.token }}

# --- 4. build ---
- name: Build
shell: bash
run: cmake --build --preset ${{ inputs.preset }}

# --- 5. save BuildCache ---
- name: Save BuildCache
if: always()
uses: ./.github/actions/save-cache
with:
path: .buildcache
key: ${{ steps.buildcache.outputs.primary-key }}
global-tag: buildcache-${{ inputs.cache_prefix }}-${{ inputs.preset }}
gh-token: ${{ github.token }}
26 changes: 0 additions & 26 deletions .github/actions/build-linux-container/action.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/actions/prepare-windows/action.yml

This file was deleted.

73 changes: 73 additions & 0 deletions .github/actions/restore-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: 'Restore Cache'
description: 'Restores from GitHub Cache or GHCR'
inputs:
path:
description: 'File path to restore'
required: true
key:
description: 'Primary key for GitHub Cache'
required: true
restore-keys:
description: 'Fallback keys for GitHub Cache'
required: false
global-tag:
description: 'OCI Tag for GHCR'
required: true
gh-token:
description: 'GitHub Token for GHCR auth'
required: true
default: ${{ github.token }}

outputs:
cache-hit:
description: 'true if cache was found in either github or GHCR'
value: ${{ steps.local-cache.outputs.cache-hit == 'true' || steps.global-cache.outputs.hit == 'true' }}
primary-key:
description: 'The key used for saving later'
value: ${{ steps.local-cache.outputs.cache-primary-key }}

runs:
using: "composite"
steps:
# --- Local GitHub cache ---
- name: Restore local cache
id: local-cache
uses: actions/cache/restore@v4
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
restore-keys: ${{ inputs.restore-keys }}

# --- Setup ORAS (Only if local missed) ---
- name: Set up ORAS
if: steps.local-cache.outputs.cache-matched-key == ''
uses: oras-project/setup-oras@v1

# --- Login ---
- name: Login to GHCR (Native ORAS)
if: steps.local-cache.outputs.cache-matched-key == ''
shell: bash
run: |
echo "${{ inputs.gh-token }}" | oras login ghcr.io \
--username "${{ github.actor }}" \
--password-stdin

# --- Global GHCR cache ---
- name: Restore global cache
id: global-cache
if: steps.local-cache.outputs.cache-matched-key == ''
shell: bash
env:
REPO: ghcr.io/${{ github.repository }}
TAG: master-${{ inputs.global-tag }}
TARGET_PATH: ${{ inputs.path }}
run: |
echo "Local miss. Pulling from GHCR: $TAG"
if oras pull "$REPO/cache:$TAG"; then
echo "hit=true" >> $GITHUB_OUTPUT
tar -xzf cache-archive.tar.gz
rm cache-archive.tar.gz
else
echo "hit=false" >> $GITHUB_OUTPUT
echo "Global cache miss."
fi
21 changes: 0 additions & 21 deletions .github/actions/run-linux/action.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/actions/save-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: 'Save Cache'
description: 'Saves to GitHub Cache (Always) and GHCR (Only on master)'
inputs:
path:
description: 'File path to save'
required: true
key:
description: 'Key used in the restore step'
required: true
global-tag:
description: 'OCI Tag for GHCR'
required: true
gh-token:
description: 'GitHub Token for GHCR auth'
required: true
default: ${{ github.token }}

runs:
using: "composite"
steps:
# --- Local github cache ---
- name: Save Local Cache
uses: actions/cache/save@v4
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}

# --- Setup for Global (Only on master) ---
- name: Set up ORAS
if: github.ref == 'refs/heads/master'
uses: oras-project/setup-oras@v1

# --- Login ---
- name: Login to GHCR (Native ORAS)
if: github.ref == 'refs/heads/master'
shell: bash
run: |
echo "${{ inputs.gh-token }}" | oras login ghcr.io \
--username "${{ github.actor }}" \
--password-stdin

# --- Global GHCR cache (master only) ---
- name: Save Global Cache
if: github.ref == 'refs/heads/master'
shell: bash
env:
REPO: ghcr.io/${{ github.repository }}
TAG: master-${{ inputs.global-tag }}
TARGET_PATH: ${{ inputs.path }}
run: |
if [ -d "$TARGET_PATH" ]; then
echo "Compressing for Global Cache..."
tar -czf cache-archive.tar.gz "$TARGET_PATH"

echo "Pushing to GHCR..."
oras push "$REPO/cache:$TAG" cache-archive.tar.gz
rm cache-archive.tar.gz
fi
31 changes: 0 additions & 31 deletions .github/actions/setup-linux/action.yml

This file was deleted.

Loading
Loading