Switch to using native ARM64 builders
The workflow code is inspired by https://github.com/matrix-org/matrix-hookshot/pull/1007 Ref: https://github.blog/news-insights/product-news/arm64-on-github-actions-powering-faster-more-efficient-build-systems/ This decreases build times from ~40 minutes (on powerful self-hosted runners) to ~8 minutes (on public runners).
This commit is contained in:
83
.github/workflows/workflow.yml
vendored
83
.github/workflows/workflow.yml
vendored
@@ -3,13 +3,14 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
tags: [ "v*" ]
|
tags: [ "v*" ]
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * 1'
|
|
||||||
permissions:
|
permissions:
|
||||||
checks: write
|
checks: write
|
||||||
contents: write
|
contents: write
|
||||||
packages: write
|
packages: write
|
||||||
pull-requests: read
|
pull-requests: read
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: false
|
||||||
jobs:
|
jobs:
|
||||||
test-and-clippy:
|
test-and-clippy:
|
||||||
name: Unit testing and linting
|
name: Unit testing and linting
|
||||||
@@ -22,17 +23,41 @@ jobs:
|
|||||||
- run: cargo test --all-features
|
- run: cargo test --all-features
|
||||||
- run: cargo clippy
|
- run: cargo clippy
|
||||||
|
|
||||||
build-publish:
|
docker-clean-metadata:
|
||||||
name: Build and Publish
|
runs-on: ubuntu-latest
|
||||||
runs-on: self-hosted
|
outputs:
|
||||||
|
json: ${{ steps.meta.outputs.json }}
|
||||||
steps:
|
steps:
|
||||||
- name: Set up QEMU
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
uses: docker/setup-qemu-action@v3
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
platforms: arm64
|
images: |
|
||||||
- name: Set up Docker Buildx
|
ghcr.io/${{ github.repository }}
|
||||||
uses: docker/setup-buildx-action@v1
|
tags: |
|
||||||
- name: Login to ghcr.io
|
type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
|
||||||
|
type=semver,pattern={{raw}}
|
||||||
|
|
||||||
|
docker-build:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
arch: amd64
|
||||||
|
- os: ubuntu-24.04-arm
|
||||||
|
arch: arm64
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Log in to the GitHub Container registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
@@ -42,17 +67,41 @@ jobs:
|
|||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
|
||||||
ghcr.io/${{ github.repository }}
|
|
||||||
registry.etke.cc/${{ github.repository }}
|
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
|
type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
|
||||||
type=semver,pattern={{raw}}
|
type=semver,pattern={{raw}}
|
||||||
- name: Build and push
|
flavor: |
|
||||||
|
latest=auto
|
||||||
|
suffix=-${{ matrix.arch }},onlatest=true
|
||||||
|
images: |
|
||||||
|
ghcr.io/${{ github.repository }}
|
||||||
|
|
||||||
|
- name: Build and push Docker images
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
file: Dockerfile.ci
|
|
||||||
|
docker-manifest:
|
||||||
|
needs:
|
||||||
|
- docker-build
|
||||||
|
- docker-clean-metadata
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
image: ${{ fromJson(needs.docker-clean-metadata.outputs.json).tags }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Log in to the GitHub Container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Create and push manifest
|
||||||
|
run: |
|
||||||
|
docker manifest create ${{ matrix.image }} ${{ matrix.image }}-amd64 ${{ matrix.image }}-arm64
|
||||||
|
docker manifest push ${{ matrix.image }}
|
||||||
|
|||||||
Reference in New Issue
Block a user