Skip to content

Commit ed3f28c

Browse files
committed
Add workflows to build linux based on docker buildx
1 parent 6bede80 commit ed3f28c

3 files changed

Lines changed: 182 additions & 1 deletion

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
name: Build Linux Images
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
dry_run:
8+
description: 'Dry run: build images but do not push to Docker Hub or create manifest lists'
9+
type: boolean
10+
default: true
11+
12+
permissions:
13+
contents: read
14+
15+
env:
16+
SRCML_BAKE_REGISTRY: ""
17+
18+
jobs:
19+
bake:
20+
name: bake-${{ matrix.arch }}
21+
if: ${{ github.repository == 'srcML/srcML' }}
22+
environment: build
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- arch: amd64
28+
runner: ubuntu-24.04
29+
- arch: arm64
30+
runner: ubuntu-24.04-arm
31+
runs-on: ${{ matrix.runner }}
32+
steps:
33+
- name: Checkout Repository
34+
uses: actions/checkout@v4
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
39+
- name: Log in to Docker Hub
40+
if: ${{ !inputs.dry_run }}
41+
uses: docker/login-action@v3
42+
with:
43+
username: ${{ secrets.DOCKERHUB_USERNAME }}
44+
password: ${{ secrets.DOCKERHUB_TOKEN }}
45+
46+
- name: Bake images for ${{ matrix.arch }}${{ inputs.dry_run && ' (dry run)' || '' }}
47+
run: |
48+
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
49+
docker buildx bake \
50+
--set "*.output=type=cacheonly" \
51+
--metadata-file metadata-${{ matrix.arch }}.json
52+
else
53+
docker buildx bake \
54+
--set "*.output=type=image,push-by-digest=true,name-canonical=true,push=true" \
55+
--metadata-file metadata-${{ matrix.arch }}.json
56+
fi
57+
env:
58+
SRCML_BAKE_ARCHITECTURE: linux/${{ matrix.arch }}
59+
60+
- name: Upload bake metadata
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: bake-metadata-${{ matrix.arch }}
64+
path: metadata-${{ matrix.arch }}.json
65+
if-no-files-found: error
66+
67+
merge:
68+
name: merge-manifests
69+
needs: bake
70+
if: ${{ !inputs.dry_run && github.repository == 'srcML/srcML' }}
71+
environment: build
72+
runs-on: ubuntu-24.04
73+
steps:
74+
- name: Checkout Repository
75+
uses: actions/checkout@v4
76+
77+
- name: Set up Docker Buildx
78+
uses: docker/setup-buildx-action@v3
79+
80+
- name: Log in to Docker Hub
81+
uses: docker/login-action@v3
82+
with:
83+
username: ${{ secrets.DOCKERHUB_USERNAME }}
84+
password: ${{ secrets.DOCKERHUB_TOKEN }}
85+
86+
- name: Download all bake metadata
87+
uses: actions/download-artifact@v4
88+
with:
89+
pattern: bake-metadata-*
90+
merge-multiple: true
91+
92+
- name: Create multi-arch manifest lists
93+
run: |
94+
docker buildx bake --print > bake-plan.json
95+
jq -r '
96+
.target | to_entries[] |
97+
.key as $target |
98+
.value.tags[] |
99+
. as $tag |
100+
split(":")[0] as $repo |
101+
"\($tag) \($repo) \($target)"
102+
' bake-plan.json | while read -r tag repo target; do
103+
amd64_digest=$(jq -r --arg t "$target" '.[$t]."containerimage.digest" // empty' metadata-amd64.json)
104+
arm64_digest=$(jq -r --arg t "$target" '.[$t]."containerimage.digest" // empty' metadata-arm64.json)
105+
if [[ -z "$amd64_digest" || -z "$arm64_digest" ]]; then
106+
echo "Missing digest for target $target (amd64='$amd64_digest' arm64='$arm64_digest')" >&2
107+
exit 1
108+
fi
109+
echo "Creating manifest $tag from $repo@$amd64_digest + $repo@$arm64_digest"
110+
docker buildx imagetools create -t "$tag" \
111+
"${repo}@${amd64_digest}" \
112+
"${repo}@${arm64_digest}"
113+
done
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: Build Linux Installers
3+
4+
on:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
bake:
12+
name: bake-${{ matrix.family }}-${{ matrix.arch }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- family: ubuntu
18+
arch: amd64
19+
runner: ubuntu-24.04
20+
- family: ubuntu
21+
arch: arm64
22+
runner: ubuntu-24.04-arm
23+
- family: fedora
24+
arch: amd64
25+
runner: ubuntu-24.04
26+
- family: fedora
27+
arch: arm64
28+
runner: ubuntu-24.04-arm
29+
- family: opensuse
30+
arch: amd64
31+
runner: ubuntu-24.04
32+
- family: opensuse
33+
arch: arm64
34+
runner: ubuntu-24.04-arm
35+
runs-on: ${{ matrix.runner }}
36+
steps:
37+
- name: Checkout Repository
38+
uses: actions/checkout@v4
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Bake ${{ matrix.family }} package targets
44+
run: |
45+
docker buildx bake \
46+
--set "*.push=false" \
47+
${{ matrix.family }}_package
48+
env:
49+
SRCML_BAKE_ARCHITECTURE: linux/${{ matrix.arch }}
50+
51+
- name: Upload installers
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: linux-installers-${{ matrix.family }}-${{ matrix.arch }}
55+
path: |
56+
dist_packages/*.deb
57+
dist_packages/*.rpm
58+
dist_packages/*.tar.gz
59+
dist_packages/*.bz2
60+
if-no-files-found: error

‎docker-bake.override.hcl‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ variable "distributions" {
4444
{ id = "opensuse", version_id = "15.2", java_version_id="15.6", name = "OpenSUSE 15.2", workflow = "rpm", opensuse="leap" },
4545
{ id = "opensuse", version_id = "15.1", java_version_id="15.6", name = "OpenSUSE 15.1", workflow = "rpm", opensuse="leap", tag = "earliest" },
4646
{ id = "opensuse", version_id = "15", java_version_id="15.6", name = "OpenSUSE 15", workflow = "rpm", opensuse="leap" },
47-
{ id = "opensuse", version_id = "latest", java_version_id="latest", name = "OpenSUSE Tumbleweed", workflow = "rpm", opensuse="tumbleweed", tag = "latest" }
47+
{ id = "opensuse", version_id = "latest", java_version_id="latest", name = "OpenSUSE Tumbleweed", workflow = "rpm", opensuse="tumbleweed", tag = "tumbleweed" }
4848
]
4949
}
5050

@@ -98,6 +98,14 @@ group "ubuntu_image" { targets = categoryDistributionTarget("ubuntu", "image") }
9898
# Example target name: ubuntu_24_04_package Example tag: srcml/ubuntu_package:24.04
9999
group "ubuntu_package" { targets = categoryDistributionTarget("ubuntu", "package") }
100100

101+
# Fedora package files
102+
# Example target name: fedora_42_package Example tag: srcml/fedora_package:42
103+
group "fedora_package" { targets = categoryDistributionTarget("fedora", "package") }
104+
105+
# OpenSUSE package files
106+
# Example target name: opensuse_15_6_package Example tag: srcml/opensuse_package:15.6
107+
group "opensuse_package" { targets = categoryDistributionTarget("opensuse", "package") }
108+
101109
# Ubuntu log images
102110
# Example target name: ubuntu_24_04_log Example tag: srcml/ubuntu_log:24.04
103111
group "ubuntu_log" { targets = categoryDistributionTarget("ubuntu", "log") }

0 commit comments

Comments
 (0)