mirror of
https://github.com/TaterTotterson/microWakeWord-Trainer-Nvidia-Docker.git
synced 2026-08-12 07:55:33 -06:00
145 lines
4.3 KiB
YAML
145 lines
4.3 KiB
YAML
name: Publish Docker Images
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
concurrency:
|
|
group: docker-publish-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE_NAME: tatertotterson/microwakeword
|
|
|
|
jobs:
|
|
docker:
|
|
name: Docker image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Validate tag matches trainer version
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
version="$(tr -d '[:space:]' < VERSION)"
|
|
expected_tag="v${version#v}"
|
|
if [[ "${GITHUB_REF_NAME}" != "${expected_tag}" ]]; then
|
|
echo "Tag ${GITHUB_REF_NAME} does not match trainer version ${expected_tag}." >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
flavor: |
|
|
latest=false
|
|
tags: |
|
|
type=raw,value=latest
|
|
type=ref,event=tag
|
|
|
|
- name: Build and push image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: dockerfile
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha,scope=mww-trainer-nvidia-docker
|
|
cache-to: type=gha,mode=max,scope=mww-trainer-nvidia-docker
|
|
|
|
- name: Docker metadata (Blackwell)
|
|
id: meta-blackwell
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
flavor: |
|
|
latest=false
|
|
tags: |
|
|
type=raw,value=blackwell
|
|
type=ref,event=tag,suffix=-blackwell
|
|
|
|
- name: Build and push Blackwell image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: dockerfile.blackwell
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: ${{ steps.meta-blackwell.outputs.tags }}
|
|
labels: ${{ steps.meta-blackwell.outputs.labels }}
|
|
cache-from: type=gha,scope=mww-trainer-nvidia-docker-blackwell
|
|
cache-to: type=gha,mode=max,scope=mww-trainer-nvidia-docker-blackwell
|
|
|
|
- name: Create release notes
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
TAG_NAME: ${{ github.ref_name }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
title="microWakeWord Nvidia Trainer ${TAG_NAME}"
|
|
generated_notes="$(mktemp)"
|
|
release_notes="$(mktemp)"
|
|
test -s WHATS_NEW.md
|
|
|
|
gh api "repos/${REPO}/releases/generate-notes" \
|
|
-f tag_name="${TAG_NAME}" \
|
|
-f target_commitish="${GITHUB_SHA}" \
|
|
--jq '.body' > "${generated_notes}"
|
|
|
|
{
|
|
echo "## What's New"
|
|
echo
|
|
cat WHATS_NEW.md
|
|
echo
|
|
echo
|
|
echo "## Docker Images"
|
|
echo
|
|
echo "- \`ghcr.io/tatertotterson/microwakeword:${TAG_NAME}\`"
|
|
echo "- \`ghcr.io/tatertotterson/microwakeword:latest\`"
|
|
echo "- \`ghcr.io/tatertotterson/microwakeword:${TAG_NAME}-blackwell\`"
|
|
echo "- \`ghcr.io/tatertotterson/microwakeword:blackwell\`"
|
|
echo
|
|
cat "${generated_notes}"
|
|
} > "${release_notes}"
|
|
|
|
if gh release view "${TAG_NAME}" >/dev/null 2>&1; then
|
|
gh release edit "${TAG_NAME}" \
|
|
--title "${title}" \
|
|
--notes-file "${release_notes}" \
|
|
--latest \
|
|
--verify-tag
|
|
else
|
|
gh release create "${TAG_NAME}" \
|
|
--title "${title}" \
|
|
--notes-file "${release_notes}" \
|
|
--latest \
|
|
--verify-tag
|
|
fi
|