Docker Publish Release #96
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Publish Release | |
on: | |
release: | |
types: [published] | |
# Can be triggered manually | |
workflow_dispatch: | |
inputs: | |
release: | |
required: true | |
description: The version to generate | |
git-ref: | |
required: true | |
description: The git reference to checkout prior to running the docker build | |
force-latest: | |
required: true | |
type: choice | |
default: 'false' | |
description: Whether to force a latest tag on the release | |
options: | |
- true | |
- false | |
jobs: | |
config: | |
runs-on: "ubuntu-latest" | |
outputs: | |
has-secrets: ${{ steps.check.outputs.has-secrets }} | |
steps: | |
- name: "Check for secrets" | |
id: check | |
shell: bash | |
run: | | |
if [ -n "${{ (secrets.DOCKERHUB_USER != '' && secrets.DOCKERHUB_TOKEN != '') || '' }}" ]; then | |
echo "has-secrets=1" >> "$GITHUB_OUTPUT" | |
fi | |
docker-release: | |
needs: config | |
if: needs.config.outputs.has-secrets | |
name: docker-release | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
build_preset: ["dev", "lean", "py310", "websocket", "dockerize"] | |
platform: ["linux/amd64", "linux/arm64"] | |
exclude: | |
# disabling because slow! no python wheels for arm/py39 and | |
# QEMU is slow! | |
- build_preset: "dev" | |
platform: "linux/arm64" | |
- build_preset: "lean" | |
platform: "linux/arm64" | |
fail-fast: false | |
steps: | |
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
submodules: recursive | |
ref: ${{ github.ref }} | |
fetch-depth: 0 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker Image | |
env: | |
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
run: | | |
RELEASE="${{ github.event.release.tag_name }}" | |
FORCE_LATEST="" | |
EVENT="${{github.event_name}}" | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
# in the case of a manually-triggered run, read release from input | |
RELEASE="${{ github.event.inputs.release }}" | |
if [ "${{ github.event.inputs.force-latest }}" = "true" ]; then | |
FORCE_LATEST="--force-latest" | |
fi | |
# build_docker.py may not exist on that SHA, let's switcharoo to /tmp | |
cp ./scripts/build_docker.py /tmp | |
git checkout "${{ github.event.inputs.git-ref }}" | |
cp /tmp/build_docker.py scripts/ | |
EVENT="release" | |
fi | |
pip install click | |
./scripts/build_docker.py \ | |
${{ matrix.build_preset }} \ | |
"$EVENT" \ | |
--build_context_ref "$RELEASE" \ | |
--platform ${{ matrix.platform }} $FORCE_LATEST |