1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Docker Image
# Build and publish the `aletheiadb` container image to GitHub Container
# Registry. Triggers:
# - push to trunk -> `:trunk` and `:sha-<commit>`
# - semver tag vX.Y.Z -> `:vX.Y.Z`, `:X.Y`, `:latest`, and `:sha-<commit>`
# - manual workflow_dispatch (for rebuilding without a new commit/tag)
#
# Images are linux/amd64 for the first pass. linux/arm64 is easy to add to
# the platforms list once someone actually asks for it; it doubles build
# time without any current consumer, so we keep it off by default.
on:
push:
branches:
- trunk
tags:
- 'v*.*.*'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
name: Build and push Docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=sha-,format=short
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# BuildKit cache keyed on the GitHub Actions cache backend. Keeps
# Cargo's dependency compile cost (usearch, tokio, autumn, etc.)
# off the critical path for incremental builds.
cache-from: type=gha
cache-to: type=gha,mode=max