Files
miner/.github/workflows/cuda-build.yml
T
rob thijssen bfeb0328cd Refactor CUDA build workflow to use repo Containerfile
Replace inline Dockerfile with repo Containerfile and export built
binary via build output instead of docker image copy.
2025-09-12 09:14:55 +03:00

88 lines
3.1 KiB
YAML

name: CUDA Build
on:
workflow_dispatch:
push:
branches:
- cuda
pull_request:
branches:
- cuda
permissions:
contents: read
jobs:
build-matrix:
name: cuda=${{ matrix.cuda_tag }} sm=${{ matrix.sm }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cuda_tag: ["12.9.0", "13.0.0"]
sm: ["86", "89", "120"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare Buildx cache
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.cuda_tag }}-sm${{ matrix.sm }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.cuda_tag }}-sm${{ matrix.sm }}-
- name: Use repo Containerfile (no inline Dockerfile)
run: echo "Building with Containerfile at repo root"
- name: Build miner image and export dist filesystem
env:
CUDA_TAG: ${{ matrix.cuda_tag }}
SM: ${{ matrix.sm }}
run: |
set -eux
# Build the dist stage and export its filesystem to ./out
docker buildx build \
--progress=plain \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max \
--target dist \
--output type=local,dest=./out \
--build-arg CUDA_TAG=${CUDA_TAG} \
--build-arg SM=${SM} \
-f Containerfile .
# Move new cache into place to avoid unbounded growth
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Collect binary artifact
id: extract
env:
CUDA_TAG: ${{ matrix.cuda_tag }}
SM: ${{ matrix.sm }}
run: |
set -eux
# Short CUDA tag (e.g., 12.9 from 12.9.0)
SHORT_TAG="$(echo "${CUDA_TAG}" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')"
BIN="quantus-miner-cuda-${SHORT_TAG}-sm-${SM}"
# Binary exported by the dist stage is under ./out/usr/local/bin
install -m 0755 ./out/usr/local/bin/quantus-miner "./${BIN}"
echo "bin_path=./${BIN}" >> "$GITHUB_OUTPUT"
echo "short_tag=${SHORT_TAG}" >> "$GITHUB_OUTPUT"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ format('quantus-miner-cuda-{0}-sm-{1}', steps.extract.outputs.short_tag, matrix.sm) }}
path: ${{ steps.extract.outputs.bin_path }}
if-no-files-found: error
retention-days: 3