Skip to content

Docker Images

Docker Images #56

name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version tag (e.g. 1.2.3)"
required: true
env:
REGISTRY: ghcr.io
IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }}/quadtrix
jobs:
build-binaries:
name: Binary (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-14]
include:
- os: ubuntu-22.04
artifact_name: quadtrix-linux-x64
binary: quadtrix
- os: macos-14
artifact_name: quadtrix-macos-arm64
binary: quadtrix
steps:
- uses: actions/checkout@v4
- name: Compile (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update && sudo apt-get install -y g++
g++ -std=c++17 -O3 -march=native \
-I. -Iinclude \
-o ${{ matrix.binary }} main.cpp
strip ${{ matrix.binary }}
- name: Compile (macOS)
if: runner.os == 'macOS'
run: |
g++ -std=c++17 -O3 -march=native \
-I. -Iinclude \
-o ${{ matrix.binary }} main.cpp
- name: Package
run: |
mkdir dist
cp ${{ matrix.binary }} dist/
cp README.md LICENSE dist/
tar -czf ${{ matrix.artifact_name }}.tar.gz -C dist .
- name: Upload to Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ github.event.inputs.version }}
files: ${{ matrix.artifact_name }}.tar.gz
generate_release_notes: true
publish-images:
name: Publish Docker images
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Parse tag
id: tag
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
- name: Build & push backend
uses: docker/build-push-action@v6
with:
context: .
file: .devops/Dockerfile.backend
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE_PREFIX }}-backend:latest
${{ env.IMAGE_PREFIX }}-backend:${{ steps.tag.outputs.VERSION }}
cache-from: type=gha,scope=backend
cache-to: type=gha,mode=max,scope=backend
- name: Build & push frontend
uses: docker/build-push-action@v6
with:
context: .
file: .devops/Dockerfile.frontend
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE_PREFIX }}-frontend:latest
${{ env.IMAGE_PREFIX }}-frontend:${{ steps.tag.outputs.VERSION }}
cache-from: type=gha,scope=frontend
cache-to: type=gha,mode=max,scope=frontend
- name: Build & push cpp
uses: docker/build-push-action@v6
with:
context: .
file: .devops/Dockerfile.cpp
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.IMAGE_PREFIX }}-cpp:latest
${{ env.IMAGE_PREFIX }}-cpp:${{ steps.tag.outputs.VERSION }}
cache-from: type=gha,scope=cpp
cache-to: type=gha,mode=max,scope=cpp
- name: Create Release summary
run: |
echo "## Docker images published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Image | Tags |" >> $GITHUB_STEP_SUMMARY
echo "|-------|------|" >> $GITHUB_STEP_SUMMARY
echo "| \`quadtrix-backend\` | \`latest\`, \`${{ steps.tag.outputs.VERSION }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| \`quadtrix-frontend\` | \`latest\`, \`${{ steps.tag.outputs.VERSION }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| \`quadtrix-cpp\` | \`latest\`, \`${{ steps.tag.outputs.VERSION }}\` |" >> $GITHUB_STEP_SUMMARY