Skip to content

Commit

Permalink
feat: create multiplatform manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Jan 20, 2025
1 parent e2cb88f commit c4051fe
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
47 changes: 42 additions & 5 deletions .github/workflows/build-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- { host: 'ubuntu-22.04', platform: linux/amd64, suffix: 'x64', suffix2: 'amd64' }
- { host: 'ubuntu-22.04-arm', platform: linux/arm64, suffix: 'arm64', suffix2: 'arm64' }

outputs:
tags: ${{ steps.meta.outputs.tags }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -68,7 +71,7 @@ jobs:
type=semver,pattern={{major}}.{{minor}}-${{ matrix.architecture.suffix2 }},enable=${{ github.event_name != 'workflow_run' }}
type=semver,pattern={{major}}-${{ matrix.architecture.suffix2 }},value=${{ env.VERSION }},enable=${{ github.event_name == 'workflow_run' }}
type=semver,pattern={{major}}-${{ matrix.architecture.suffix2 }},enable=${{ github.event_name != 'workflow_run' }}
type=sha-${{ matrix.architecture.suffix2 }}
type=sha,suffix=-${{ matrix.architecture.suffix2 }}
labels: |
org.opencontainers.image.vendor=Ribose Inc.
org.opencontainers.image.licenses=BSD-2-Clause
Expand All @@ -84,7 +87,7 @@ jobs:
with:
context: .
file: ./${{ matrix.container }}.Dockerfile
push: ${{ contains(github.ref, 'refs/tags/v') || github.event_name == 'workflow_run' }}
push: ${{ contains(github.ref, 'refs/tags/v') || github.event_name == 'workflow_run' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
Expand All @@ -96,16 +99,50 @@ jobs:
continue-on-error: true
uses: actions/delete-package-versions@v5
with:
package-name: tebako-${{ matrix.container }}-amd64
package-name: amd64-tebako-${{ matrix.container }}
package-type: container
min-versions-to-keep: 0
delete-only-untagged-versions: false

create-manifests:
name: Create manifest for ghcr.io/tamatebako/tebako-${{ matrix.container }}
if: contains(github.ref, 'refs/tags/v') || github.event_name == 'workflow_run'
runs-on: ubuntu-22.04
needs: build-containers
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
container:
- 'ubuntu-20.04'
- 'alpine-3.17'
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: tamatebako
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create SHA manifest and push
run: |
for tag in $(echo "${{ needs.build-containers.outputs.tags }}" | tr ',' '\n'); do
base_tag=$(echo $tag | sed -E 's/.*:(.*)-(amd64|arm64)/\1/')
echo "Processing $tag, using base tag $base_tag"
docker manifest create \
ghcr.io/tamatebako/tebako-${{ matrix.container }}:$base_tag \
--amend ghcr.io/tamatebako/tebako-${{ matrix.container }}:$base_tag-amd64 \
--amend ghcr.io/tamatebako/tebako-${{ matrix.container }}:$base_tag-arm64
docker manifest push ghcr.io/tamatebako/tebako-${{ matrix.container }}:$base_tag
done
test-packaging-in-container:
name: Package ${{ matrix.gem }} in ${{ matrix.container }} ${{ matrix.architecture.platform }} with Ruby ${{ matrix.package_ruby_ver }}
if: contains(github.ref, 'refs/tags/v') || github.event_name == 'workflow_run'
runs-on: ${{ matrix.architecture.host }}
needs: build-containers
needs: create-manifests
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -141,7 +178,7 @@ jobs:
name: Package ${{ matrix.gem }} by ${{ matrix.container }} ${{ matrix.architecture.platform }} container with Ruby ${{ matrix.package_ruby_ver }}
if: contains(github.ref, 'refs/tags/v') || github.event_name == 'workflow_run'
runs-on: ${{ matrix.architecture.host }}
needs: build-containers
needs: create-manifests
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion tools/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set -o errexit -o pipefail -o noclobber -o nounset

: "${LOCAL_BUILDS:=/tmp/tebako}"
: "${CMAKE_VERSION:=3.24.4-1}"
: "${RUBY_VERSION:=3.1.6}"
: "${RUBY_VERSION:=3.2.6}"
: "${RUBY_INSTALL_VERSION:=0.9.3}"
: "${ARCH:=x64}"

Expand Down

0 comments on commit c4051fe

Please sign in to comment.