-
Notifications
You must be signed in to change notification settings - Fork 4
134 lines (131 loc) · 5.43 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
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"]
manifest: ["tcp", "ssh", "tcp-ccache", "ssh-ccache"]
name: ${{ matrix.arch }}:${{ matrix.manifest }} image
runs-on: ubuntu-latest
continue-on-error: true
outputs:
manifests: ${{ steps.output.outputs.manifests }}
steps:
- name: Check out code
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- name: Prepare build variables
id: prep
run: |
{
echo "base=$(echo "${{ matrix.manifest }}" | sed 's/^\(tcp\|ssh\)/distcc/')"
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.manifest }}"
echo "target=distcc-$(echo "${{ matrix.manifest }}" | cut -d '-' -f 1)"
} >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
if: matrix.arch != 'amd64'
with:
platforms: ${{ steps.prep.outputs.qemu_platform }}
- name: Set up buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3
- name: Define Docker metadata
id: docker-metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5
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 <[email protected]>
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@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6
with:
build-args: |
BASE=${{ steps.prep.outputs.base }}
context: .
labels: ${{ steps.docker-metadata.outputs.labels }}
tags: ${{ steps.docker-metadata.outputs.tags }}
platforms: linux/${{ matrix.arch }}
target: ${{ steps.prep.outputs.target }}
load: true
- name: Inspect image
run: |
docker image inspect ${{ steps.build.outputs.imageid }}
- name: Test distcc
env:
DOCKER_DEFAULT_PLATFORM: linux/${{ matrix.arch }}
run: |
docker compose --ansi always -f docker-compose.test.yml -p test up \
--exit-code-from distcc-${{ matrix.manifest }}-client \
distcc-${{ matrix.manifest }}-client distcc-${{ matrix.manifest }}-server
- name: Log in to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
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 --arg tag_prefix "${{ steps.prep.outputs.tag }}" 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@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- name: Log in to Docker Hub
if: matrix.manifest.registry == 'docker.io'
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
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@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
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