Skip to content

Commit 14ad8c4

Browse files
perlowjaclaude
andcommitted
ci(docker): publish multi-arch images to ghcr.io + Docker Hub on tag
Fires on v*.*.* tag push (also manual dispatch). Builds linux/amd64 + linux/arm64 via buildx. Pushes to ghcr.io/perlowja/mnemos always; pushes to jperlow/mnemos-os on Docker Hub only when DOCKERHUB_USERNAME repo variable is set (with DOCKERHUB_TOKEN secret). Tag cascade via docker/metadata-action@v5: :3.1.0 :3.1 :3 :latest :sha-<short> OCI labels declare Apache-2.0 licensing and link back to the repo. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Jason Perlow <jperlow@gmail.com>
1 parent dd2a0e0 commit 14ad8c4

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Publish Docker image (ghcr.io + Docker Hub)
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Tag to build (e.g. v3.1.0). Leave blank to build from the current ref.'
11+
required: false
12+
13+
jobs:
14+
build-and-publish:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
ref: ${{ github.event.inputs.tag || github.ref }}
24+
25+
- name: Set up QEMU (multi-arch)
26+
uses: docker/setup-qemu-action@v3
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Log in to GitHub Container Registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ghcr.io
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Log in to Docker Hub
39+
if: ${{ vars.DOCKERHUB_USERNAME != '' }}
40+
uses: docker/login-action@v3
41+
with:
42+
registry: docker.io
43+
username: ${{ secrets.DOCKERHUB_USERNAME }}
44+
password: ${{ secrets.DOCKERHUB_TOKEN }}
45+
46+
- name: Derive image tags
47+
id: meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: |
51+
ghcr.io/${{ github.repository_owner }}/mnemos
52+
${{ vars.DOCKERHUB_USERNAME != '' && format('docker.io/{0}/mnemos-os', vars.DOCKERHUB_USERNAME) || '' }}
53+
tags: |
54+
type=semver,pattern={{version}}
55+
type=semver,pattern={{major}}.{{minor}}
56+
type=semver,pattern={{major}}
57+
type=sha,format=short
58+
type=raw,value=latest,enable={{is_default_branch}}
59+
labels: |
60+
org.opencontainers.image.title=MNEMOS
61+
org.opencontainers.image.description=Memory operating system with GRAEAE reasoning, DAG versioning, and compression
62+
org.opencontainers.image.licenses=Apache-2.0
63+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
64+
org.opencontainers.image.url=https://github.com/${{ github.repository }}
65+
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/blob/master/README.md
66+
67+
- name: Build and push
68+
uses: docker/build-push-action@v5
69+
with:
70+
context: .
71+
file: ./Dockerfile
72+
platforms: linux/amd64,linux/arm64
73+
push: true
74+
tags: ${{ steps.meta.outputs.tags }}
75+
labels: ${{ steps.meta.outputs.labels }}
76+
cache-from: type=gha
77+
cache-to: type=gha,mode=max
78+
provenance: true
79+
sbom: true
80+
81+
- name: Summary
82+
run: |
83+
echo "### Published images" >> "$GITHUB_STEP_SUMMARY"
84+
echo '```' >> "$GITHUB_STEP_SUMMARY"
85+
echo "${{ steps.meta.outputs.tags }}" >> "$GITHUB_STEP_SUMMARY"
86+
echo '```' >> "$GITHUB_STEP_SUMMARY"
87+
echo "" >> "$GITHUB_STEP_SUMMARY"
88+
echo "### Labels" >> "$GITHUB_STEP_SUMMARY"
89+
echo '```' >> "$GITHUB_STEP_SUMMARY"
90+
echo "${{ steps.meta.outputs.labels }}" >> "$GITHUB_STEP_SUMMARY"
91+
echo '```' >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)