LibreChat/.github/workflows/main-image-workflow.yml
Dustin Healy d269d35a2c
🐳 feat: Publish Release-Matched Channel Gateway Images (#17784)
* feat: publish release-matched channel gateway images

* test: isolate compose configuration from service env files

* test: render channel compose in a complete isolated fixture

* fix: publish stable images from their release commit

* fix: omit gateway builds from releases predating channels
2026-11-10 21:04:08 -08:00

62 lines
2.4 KiB
YAML

name: Publish Latest Stable Release Images (Manual Dispatch)
on:
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
# Resolved once here rather than per build leg: the tag is an input to the
# publish, and the merge job needs it too.
resolve-tag:
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
latest_tag: ${{ steps.tag.outputs.latest_tag }}
sha: ${{ steps.tag.outputs.sha }}
images: ${{ steps.tag.outputs.images }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: main
fetch-depth: 0
- name: Fetch tags and set the latest tag
id: tag
run: |
set -euo pipefail
git fetch --tags --force
# `|| true` keeps pipefail from killing the step when grep matches
# nothing, so the explicit error below is reachable.
LATEST_TAG=$(git tag --list 'v[0-9]*' --sort=-v:refname | grep -E '^v[0-9]+[.][0-9]+[.][0-9]+$' | head -n 1 || true)
if [ -z "$LATEST_TAG" ]; then
echo "::error::No stable v<semver> tag found"
exit 1
fi
printf 'latest_tag=%s\n' "$LATEST_TAG" >> "$GITHUB_OUTPUT"
# A versioned artifact must build the selected release, even when main
# has advanced. Both architectures receive that immutable commit.
printf 'sha=%s\n' "$(git rev-parse "${LATEST_TAG}^{commit}")" >> "$GITHUB_OUTPUT"
images='[{"target":"api-build","file":"Dockerfile.multi","image_name":"librechat-api"},{"target":"node","file":"Dockerfile","image_name":"librechat"}'
# Older releases have no gateway; do not invent an artifact for them.
if git cat-file -e "${LATEST_TAG}:packages/channel-gateway/Dockerfile" 2>/dev/null; then
images+=',{"target":"runtime","file":"packages/channel-gateway/Dockerfile","image_name":"librechat-channel-gateway"}'
fi
printf 'images=%s]\n' "$images" >> "$GITHUB_OUTPUT"
publish:
needs: resolve-tag
uses: ./.github/workflows/docker-publish.yml
with:
images: ${{ needs.resolve-tag.outputs.images }}
tag_suffixes: |
${{ needs.resolve-tag.outputs.latest_tag }}
latest
checkout_ref: ${{ needs.resolve-tag.outputs.sha }}
build_branch: ${{ needs.resolve-tag.outputs.latest_tag }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}