Skip to content

Github Container Registry #149

Github Container Registry

Github Container Registry #149

Workflow file for this run

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
name: Github Container Registry
on: # yamllint disable-line rule:truthy
push:
branches:
- main
tags:
- rel/*
schedule:
- cron: '5 12 * * 6' # UTC
workflow_dispatch:
jobs:
build:
# Uses native ARM hardware to avoid QEMU segmentation faults
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm64' }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
permissions:
contents: read
packages: write
steps:
- name: checkout
# yamllint disable-line rule:line-length
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: src
fetch-depth: 0
- name: Set up Docker Buildx
# yamllint disable-line rule:line-length
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to GHCR
# yamllint disable-line rule:line-length
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Platform-Specific Image
env:
DOCKER_REPO: ghcr.io/${{ github.repository }}
FORCE_PLATFORM: linux/${{ matrix.arch }}
# No more 'latest'—just use the branch or tag name directly
RAW_TAG: ${{ github.ref_name }}
run: |
# 1. Strip rel/ prefix (e.g., rel/0.15.0 -> 0.15.0)
CLEAN_TAG=${RAW_TAG/rel\//}
# 2. Export the architecture-suffixed tag for hooks/build
export DOCKER_TAG="${CLEAN_TAG}-${{ matrix.arch }}"
cd src
hooks/build
merge:
runs-on: ubuntu-latest
needs: build
permissions:
packages: write
steps:
- name: Login to GHCR
# yamllint disable-line rule:line-length
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create Multi-Arch Manifests
env:
DOCKER_REPO: ghcr.io/${{ github.repository }}
RAW_TAG: ${{ github.ref_name }}
run: |
TAG=${RAW_TAG/rel\//}
# This creates 'ghcr.io/...:main' pointing to '-amd64' and '-arm64'
docker manifest create ${DOCKER_REPO}-base:${TAG} \
--amend ${DOCKER_REPO}-base:${TAG}-amd64 \
--amend ${DOCKER_REPO}-base:${TAG}-arm64
docker manifest push ${DOCKER_REPO}-base:${TAG}
docker manifest create ${DOCKER_REPO}:${TAG} \
--amend ${DOCKER_REPO}:${TAG}-amd64 \
--amend ${DOCKER_REPO}:${TAG}-arm64
docker manifest push ${DOCKER_REPO}:${TAG}