Skip to content

Use MIT License

Use MIT License #10

name: Build and Push Multi-Arch Images
on:
push:
branches:
- main
tags:
- 'v*'
env:
REGISTRY_IMAGE_SLAY3R: ghcr.io/lay3rlabs/layer-sdk
REGISTRY_IMAGE_GATEWAY: ghcr.io/lay3rlabs/gateway
jobs:
build_slay3r_amd64:
name: Build and Push layer-sdk AMD64 Image
runs-on: linux-8-core
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set IMAGE_TAG
shell: bash
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
IMAGE_TAG="latest"
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
IMAGE_TAG="${GITHUB_REF_NAME#v}"
IMAGE_TAG="${IMAGE_TAG//[^a-zA-Z0-9_.-]/-}"
else
echo "Not on main branch or a version tag, skipping build."
exit 1
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push layer-sdk AMD64 image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.slay3rd
push: true
tags: ${{ env.REGISTRY_IMAGE_SLAY3R }}:${{ env.IMAGE_TAG }}-amd64
platforms: linux/amd64
provenance: false
build_slay3r_arm64:
name: Build and Push layer-sdk ARM64 Image
runs-on: arm64-builder
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set IMAGE_TAG
shell: bash
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
IMAGE_TAG="latest"
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
IMAGE_TAG="${GITHUB_REF_NAME#v}"
IMAGE_TAG="${IMAGE_TAG//[^a-zA-Z0-9_.-]/-}"
else
echo "Not on main branch or a version tag, skipping build."
exit 1
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push layer-sdk ARM64 image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.slay3rd
push: true
tags: ${{ env.REGISTRY_IMAGE_SLAY3R }}:${{ env.IMAGE_TAG }}-arm64
platforms: linux/arm64
provenance: false
build_gateway_amd64:
name: Build and Push Gateway AMD64 Image
runs-on: linux-8-core
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set IMAGE_TAG
shell: bash
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
IMAGE_TAG="latest"
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
IMAGE_TAG="${GITHUB_REF_NAME#v}"
IMAGE_TAG="${IMAGE_TAG//[^a-zA-Z0-9_.-]/-}"
else
echo "Not on main branch or a version tag, skipping build."
exit 1
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Gateway AMD64 image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.gateway
push: true
tags: ${{ env.REGISTRY_IMAGE_GATEWAY }}:${{ env.IMAGE_TAG }}-amd64
platforms: linux/amd64
provenance: false
build_gateway_arm64:
name: Build and Push Gateway ARM64 Image
runs-on: arm64-builder
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set IMAGE_TAG
shell: bash
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
IMAGE_TAG="latest"
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
IMAGE_TAG="${GITHUB_REF_NAME#v}"
IMAGE_TAG="${IMAGE_TAG//[^a-zA-Z0-9_.-]/-}"
else
echo "Not on main branch or a version tag, skipping build."
exit 1
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Gateway ARM64 image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.gateway
push: true
tags: ${{ env.REGISTRY_IMAGE_GATEWAY }}:${{ env.IMAGE_TAG }}-arm64
platforms: linux/arm64
provenance: false
create_manifest_slay3r:
name: Create and Push layer-sdk Multi-Arch Manifest
runs-on: ubuntu-latest
needs: [build_slay3r_amd64, build_slay3r_arm64]
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set IMAGE_TAG
shell: bash
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
IMAGE_TAG="latest"
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
IMAGE_TAG="${GITHUB_REF_NAME#v}"
IMAGE_TAG="${IMAGE_TAG//[^a-zA-Z0-9_.-]/-}"
else
echo "Not on main branch or a version tag, skipping manifest creation."
exit 1
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push SLAY3R multi-arch manifest
run: |
docker buildx imagetools create \
--tag ${{ env.REGISTRY_IMAGE_SLAY3R }}:${{ env.IMAGE_TAG }} \
${{ env.REGISTRY_IMAGE_SLAY3R }}:${{ env.IMAGE_TAG }}-amd64 \
${{ env.REGISTRY_IMAGE_SLAY3R }}:${{ env.IMAGE_TAG }}-arm64
create_manifest_gateway:
name: Create and Push Gateway Multi-Arch Manifest
runs-on: ubuntu-latest
needs: [build_gateway_amd64, build_gateway_arm64]
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set IMAGE_TAG
shell: bash
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
IMAGE_TAG="latest"
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
IMAGE_TAG="${GITHUB_REF_NAME#v}"
IMAGE_TAG="${IMAGE_TAG//[^a-zA-Z0-9_.-]/-}"
else
echo "Not on main branch or a version tag, skipping manifest creation."
exit 1
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push Gateway multi-arch manifest
run: |
docker buildx imagetools create \
--tag ${{ env.REGISTRY_IMAGE_GATEWAY }}:${{ env.IMAGE_TAG }} \
${{ env.REGISTRY_IMAGE_GATEWAY }}:${{ env.IMAGE_TAG }}-amd64 \
${{ env.REGISTRY_IMAGE_GATEWAY }}:${{ env.IMAGE_TAG }}-arm64