perf: build binary packages #1325
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: build | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
env: | |
DOCKERHUB_REPOSITORY: ksmanis/gentoo-distcc | |
DOCKERHUB_USERNAME: ksmanis | |
jobs: | |
images: | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: ["386", "amd64", "arm/v6", "arm/v7", "arm64", "ppc64le"] | |
target: ["tcp", "ssh"] | |
name: ${{ matrix.arch }}:${{ matrix.target }} image | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
outputs: | |
manifests: ${{ steps.output.outputs.manifests }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Prepare build variables | |
id: prep | |
run: | | |
{ | |
echo "qemu_platform=$(echo "${{ matrix.arch }}" | cut -d '/' -f 1)" | |
echo "stage3_version=$(sed -n 's#^FROM ksmanis/stage3:\(\S\+\).*#\1#p' Dockerfile)" | |
echo "tag=$(echo "${{ matrix.arch }}" | tr -d '/')-${{ matrix.target }}" | |
} >> "$GITHUB_OUTPUT" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
if: matrix.arch != '386' && matrix.arch != 'amd64' | |
with: | |
platforms: ${{ steps.prep.outputs.qemu_platform }} | |
- name: Set up buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Define Docker metadata | |
id: docker-metadata | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
docker.io/${{ env.DOCKERHUB_REPOSITORY }} | |
ghcr.io/${{ env.DOCKERHUB_REPOSITORY }} | |
flavor: | | |
latest=false | |
labels: | | |
org.opencontainers.image.title=gentoo-distcc | |
org.opencontainers.image.authors=Konstantinos Smanis <konstantinos.smanis@gmail.com> | |
tags: | | |
type=ref,event=branch,prefix=${{ steps.prep.outputs.tag }}-,suffix=-{{sha}} | |
type=ref,event=branch,prefix=${{ steps.prep.outputs.tag }}- | |
type=ref,event=pr,prefix=${{ steps.prep.outputs.tag }}-pr-,suffix=-{{sha}} | |
type=ref,event=pr,prefix=${{ steps.prep.outputs.tag }}-pr- | |
type=raw,value=${{ steps.prep.outputs.tag }}-${{ steps.prep.outputs.stage3_version }},enable={{is_default_branch}} | |
type=raw,value=${{ steps.prep.outputs.tag }},enable={{is_default_branch}} | |
- name: Build image | |
id: build | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
labels: ${{ steps.docker-metadata.outputs.labels }} | |
tags: ${{ steps.docker-metadata.outputs.tags }} | |
platforms: linux/${{ matrix.arch }} | |
target: distcc-${{ matrix.target }} | |
load: true | |
- name: Inspect image | |
run: | | |
docker image inspect ${{ steps.build.outputs.imageid }} | |
- name: Build test image | |
id: build-test | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/${{ matrix.arch }} | |
target: distcc-${{ matrix.target }}-test | |
load: true | |
- name: Test distcc | |
env: | |
DOCKER_DEFAULT_PLATFORM: linux/${{ matrix.arch }} | |
IMAGE: ${{ steps.build.outputs.imageid }} | |
TEST_IMAGE: ${{ steps.build-test.outputs.imageid }} | |
run: | | |
docker compose -f docker-compose.test.yml -p test up \ | |
--exit-code-from distcc-${{ matrix.target }}-client \ | |
distcc-${{ matrix.target }}-client distcc-${{ matrix.target }}-server | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Log in to GitHub Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push image | |
run: | | |
docker push --all-tags "docker.io/${DOCKERHUB_REPOSITORY}" | |
docker push --all-tags "ghcr.io/${DOCKERHUB_REPOSITORY}" | |
- name: Prepare outputs | |
id: output | |
run: | | |
echo "manifests=$(echo "${DOCKER_METADATA_OUTPUT_JSON}" | jq -cf manifests.jq)" >> "$GITHUB_OUTPUT" | |
manifests: | |
needs: images | |
strategy: | |
fail-fast: false | |
matrix: | |
manifest: ${{ fromJson(needs.images.outputs.manifests) }} | |
name: ${{ matrix.manifest.registry }}:${{ matrix.manifest.tag }} manifest | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Log in to Docker Hub | |
if: matrix.manifest.registry == 'docker.io' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Log in to GitHub Container registry | |
if: matrix.manifest.registry == 'ghcr.io' | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push manifest list | |
env: | |
REPO: ${{ matrix.manifest.repo }} | |
TAG: ${{ matrix.manifest.tag }} | |
run: | | |
./build-manifest.sh |