name: Publish verified Linux amd64 Docker image
on:
workflow_dispatch:
inputs:
release_tag:
description: 'Existing public release tag, e.g. v1.0.2'
required: true
type: string
permissions:
contents: read
packages: write
jobs:
docker:
name: Build and push OCI container after release
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v7
with:
ref: ${{ inputs.release_tag }}
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Require matching published release
env:
RELEASE_TAG: ${{ inputs.release_tag }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python scripts/check-release-version.py --tag "$RELEASE_TAG"
draft="$(gh api "repos/$GITHUB_REPOSITORY/releases/tags/$RELEASE_TAG" --jq .draft)"
[ "$draft" = false ] || { echo 'Container publication requires a completed public GitHub release.' >&2; exit 1; }
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry (GHCR)
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set lower case repository name
run: |
echo "IMAGE_REPOSITORY=ghcr.io/${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_REPOSITORY }}
tags: |
type=raw,value=${{ inputs.release_tag }}
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max