first commit

This commit is contained in:
Donato Capitella
2025-11-30 08:06:04 +00:00
commit 82c6e04253
34 changed files with 50959 additions and 0 deletions
+97
View File
@@ -0,0 +1,97 @@
name: Build & Publish AMD R9700 Toolboxes
on:
workflow_dispatch:
inputs:
backends:
description: >
Comma-separated backends to build (e.g. "rocm-7beta,rocm-7rc").
Use "all" to build everything.
required: false
default: all
env:
DOCKERHUB_REPO: docker.io/kyuz0/amd-r9700-toolboxes
LOCAL_PREFIX: llama
jobs:
# 1) Prepare a clean JSON array for the matrix
prepare:
runs-on: ubuntu-latest
outputs:
matrix_json: ${{ steps.mk.outputs.matrix_json }}
steps:
- id: mk
shell: bash
run: |
# Input from the Run workflow form
IN='${{ inputs.backends }}'
if [[ "$IN" == "all" || -z "$IN" ]]; then
JSON='["rocm-6.4.4","rocm-6.4.4-rocwmma","rocm-7.1","rocm-7.1-rocwmma","rocm-7-nightly","rocm-7-nightly-rocwmma","rocm-7.9","rocm-7.9-rocwmma","vulkan-amdvlk","vulkan-radv"]'
else
# Remove spaces and build JSON array from comma list
IN_CLEAN=$(echo "$IN" | tr -d '[:space:]')
JSON='["'${IN_CLEAN//,/\",\"}'"]'
fi
echo "matrix_json=${JSON}" >> "$GITHUB_OUTPUT"
echo "Using matrix: ${JSON}"
# 2) Build each backend in parallel using the prepared matrix
build-and-push:
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
backend: ${{ fromJson(needs.prepare.outputs.matrix_json) }}
steps:
- name: Free up runner disk space
run: |
echo "Before cleanup:" && df -h /
sudo rm -rf \
/usr/share/dotnet \
/usr/local/lib/android \
/opt/ghc \
/opt/hostedtoolcache/CodeQL
docker system prune --all --force
docker builder prune --all --force
echo "After cleanup:" && df -h /
- name: Check out repository
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set build timestamp
run: echo "BUILD_TS=$(date +%Y%m%dT%H%M%S)" >> $GITHUB_ENV
- name: Build & push ${{ matrix.backend }}
working-directory: toolboxes
shell: bash
run: |
set -euo pipefail
B="${{ matrix.backend }}"
DF="Dockerfile.$B"
NAME="${B}"
LI="${LOCAL_PREFIX}-${NAME}"
TAG="${NAME}_${BUILD_TS}"
IMM="${DOCKERHUB_REPO}:${TAG}"
CHN="${DOCKERHUB_REPO}:${NAME}"
echo "→ Building ${DF}"
docker build --no-cache -t "${LI}" -f "${DF}" .
echo "→ Tag & push immutable → ${IMM}"
docker tag "${LI}" "${IMM}"
docker push "${IMM}"
echo "→ Tag & push channel → ${CHN}"
docker tag "${IMM}" "${CHN}"
docker push "${CHN}"
+105
View File
@@ -0,0 +1,105 @@
name: Poll llama.cpp & Trigger Build
on:
schedule:
- cron: '0 */4 * * *'
workflow_dispatch:
permissions:
contents: read
actions: write
jobs:
poll-and-trigger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: fetch
shell: bash
run: |
set -euo pipefail
REPO_URL="https://github.com/ggml-org/llama.cpp.git"
DEFAULT_REF=$(git ls-remote --symref "$REPO_URL" HEAD | awk '/^ref:/ {print $2}')
echo "📌 Default branch: ${DEFAULT_REF#refs/heads/}"
LATEST_SHA=$(git ls-remote "$REPO_URL" "$DEFAULT_REF" | cut -f1)
if [[ -z "$LATEST_SHA" ]]; then echo "❌ No SHA found"; exit 1; fi
echo "✅ Latest SHA: $LATEST_SHA"
echo "latest_sha=$LATEST_SHA" >> "$GITHUB_OUTPUT"
- id: previous
shell: bash
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
echo "🔎 Checking for prior artifact 'last-llama-sha'…"
ART_ID=$(curl -fsSL -H "Authorization: Bearer $GH_TOKEN" \
"https://api.github.com/repos/${GH_REPO}/actions/artifacts?per_page=100" \
| jq -r '.artifacts | map(select(.name=="last-llama-sha" and .expired==false)) | sort_by(.created_at) | reverse | .[0].id // empty')
if [[ -n "$ART_ID" ]]; then
echo "📦 Found artifact id: $ART_ID (downloading)"
curl -fsSL -H "Authorization: Bearer $GH_TOKEN" -L \
"https://api.github.com/repos/${GH_REPO}/actions/artifacts/${ART_ID}/zip" -o artifact.zip
unzip -l artifact.zip || true
unzip -p artifact.zip last_commit_sha > last_commit_sha || true
else
echo "ℹ️ No prior artifact found"
fi
PREV_SHA=""
if [[ -f last_commit_sha ]]; then PREV_SHA=$(cat last_commit_sha); fi
echo "🕓 Previous SHA: $PREV_SHA"
echo "previous_sha=$PREV_SHA" >> "$GITHUB_OUTPUT"
- id: compare
shell: bash
run: |
set -euo pipefail
echo "🧮 Comparing SHAs…"
echo "prev: ${{ steps.previous.outputs.previous_sha }}"
echo "curr: ${{ steps.fetch.outputs.latest_sha }}"
if [[ "${{ steps.fetch.outputs.latest_sha }}" != "${{ steps.previous.outputs.previous_sha }}" ]]; then
echo "🔁 New commit detected"
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "✅ No change"
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Trigger build_and_publish.yml on main
if: steps.compare.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
set -euo pipefail
WF="build_and_publish.yml"
REF="main"
echo "🚀 Dispatching $WF on $REF…"
CODE=$(curl -s -o /tmp/resp -w "%{http_code}" \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-d "{\"ref\":\"$REF\",\"inputs\":{\"backends\":\"all\"}}" \
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/$WF/dispatches")
echo "HTTP $CODE"
if [[ "$CODE" != "204" ]]; then echo "Response:"; cat /tmp/resp; exit 1; fi
- name: Save new SHA
if: steps.compare.outputs.changed == 'true'
shell: bash
run: |
set -euo pipefail
printf "%s" "${{ steps.fetch.outputs.latest_sha }}" > last_commit_sha
echo "💾 Saved $(wc -c < last_commit_sha) bytes to $(pwd)/last_commit_sha"
ls -la last_commit_sha
- name: Upload last-SHA artifact
if: steps.compare.outputs.changed == 'true'
uses: actions/upload-artifact@v4
with:
name: last-llama-sha
path: last_commit_sha
retention-days: 7
+89
View File
@@ -0,0 +1,89 @@
name: Prune Old Toolbox Images
on:
workflow_dispatch:
inputs:
backends:
description: Comma-separated backends to prune (e.g. "rocm-7beta,rocm-7rc") or "all"
default: all
keep:
description: Number of latest tags to keep
default: "3"
workflow_run:
workflows: ["Build & Publish AMD Strix Halo Toolboxes"]
types: [completed] # runs after success/failure/cancel
branches: [main]
jobs:
prune:
runs-on: ubuntu-latest
env:
NS: kyuz0
REPO: amd-strix-halo-toolboxes
steps:
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Login to Docker Hub API (JWT)
id: login
env:
DH_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DH_PASS: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
TOKEN=$(curl -s -H "Content-Type: application/json" \
-d "{\"username\":\"${DH_USER}\",\"password\":\"${DH_PASS}\"}" \
https://hub.docker.com/v2/users/login/ | jq -r .token)
if [[ -z "$TOKEN" || "$TOKEN" == "null" ]]; then
echo "Failed to get Docker Hub JWT"; exit 1
fi
echo "token=${TOKEN}" >> "$GITHUB_OUTPUT"
- name: Determine backend list
id: mk
shell: bash
run: |
IN='${{ github.event.inputs.backends }}'
if [[ "$IN" == "all" || -z "$IN" ]]; then
JSON='["rocm-6.4.2","rocm-6.4.2-rocwmma","rocm-6.4.3","rocm-6.4.3-rocwmma","rocm-6.4.4","rocm-6.4.4-rocwmma","rocm-7.1","rocm-7.1-rocwmma","rocm-7beta","rocm-7alpha","rocm-7alpha-rocwmma","rocm-7alpha-rocwmma-improved","rocm-7rc","rocm-7rc-rocwmma","rocm-7rc-rocwmma-fa_all_quants","vulkan-amdvlk","vulkan-radv"]'
else
IN_CLEAN=$(echo "$IN" | tr -d '[:space:]')
JSON='["'${IN_CLEAN//,/\",\"}'"]'
fi
echo "list=${JSON}" >> "$GITHUB_OUTPUT"
- name: Prune old tags
env:
TOKEN: ${{ steps.login.outputs.token }}
KEEP: ${{ github.event.inputs.keep }}
run: |
BACKENDS='${{ steps.mk.outputs.list }}'
mapfile -t ARR < <(jq -r '.[]' <<< "$BACKENDS")
base_url="https://hub.docker.com/v2/repositories/${NS}/${REPO}/tags"
auth_hdr="Authorization: JWT ${TOKEN}"
for B in "${ARR[@]}"; do
echo ""
echo "=== Backend: ${B} (keeping latest ${KEEP}) ==="
next="${base_url}?page_size=100&ordering=last_updated&name=${B}_"
tags=()
while [[ -n "$next" && "$next" != "null" ]]; do
resp=$(curl -s -H "$auth_hdr" "$next")
page_tags=($(jq -r '.results[].name' <<< "$resp" | grep -E "^${B}_" || true))
tags+=("${page_tags[@]}")
next=$(jq -r '.next' <<< "$resp")
done
total=${#tags[@]}
echo "Found ${total} immutable tag(s) for ${B}."
if (( total <= KEEP )); then
echo "Nothing to delete."
continue
fi
to_delete=("${tags[@]:KEEP}")
for t in "${to_delete[@]}"; do
echo "Deleting tag ${t}..."
curl -s -X DELETE -H "$auth_hdr" \
"https://hub.docker.com/v2/repositories/${NS}/${REPO}/tags/${t}/" \
-o /dev/null -w "%{http_code}\n" | grep -Eq "^(202|204)$" \
&& echo "✔ Deleted" || echo "✖ Failed"
done
done