-
Notifications
You must be signed in to change notification settings - Fork 7
178 lines (151 loc) · 6.72 KB
/
docker-multi-arch.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Publish multi-arch Docker images
on:
push:
tags:
- "release/*"
- "main/*"
- "devel/*"
- "feature/*"
- "daily/*"
jobs:
release:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
base: ["bookworm", "vanilla-bookworm", "noble", "vanilla-noble"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare for docker build
id: prepare
run: |
ref_type=${{ github.ref_type }}
echo "REF_TYPE: ["$ref_type"]"
ref_name=${{ github.ref_name }}
echo "REF_NAME: ["$ref_name"]"
ref=${{ github.ref }}
echo "REF: ["$ref"]"
distro_id=${{ matrix.base }}
image_name=${{secrets.DOCKER_USERNAME}}/mpd-alsa
declare -A vanilla_dict
vanilla_dict[bookworm]="no"
vanilla_dict[vanilla-bookworm]="yes"
vanilla_dict[noble]="no"
vanilla_dict[vanilla-noble]="yes"
is_vanilla=${vanilla_dict[${{ matrix.base }}]}
declare -A allows_amdv5_dict
allows_amdv5_dict[bookworm]="yes"
allows_amdv5_dict[vanilla-bookworm]="yes"
allows_amdv5_dict[noble]="no"
allows_amdv5_dict[vanilla-noble]="no"
armv5_allowed=${allows_amdv5_dict[${{ matrix.base }}]}
build_platforms="linux/amd64,linux/arm64/v8,linux/arm/v7"
if [ "${armv5_allowed}" = "yes" ]; then
build_platforms="${build_platforms},linux/arm/v5"
fi
declare -A base_images_dict
base_images_dict[bookworm]="giof71/mpd-compiler:bookworm"
base_images_dict[vanilla-bookworm]="debian:bookworm-slim"
base_images_dict[noble]="giof71/mpd-compiler:noble"
base_images_dict[vanilla-noble]="ubuntu:noble"
declare -A integer_upsampling_dict
integer_upsampling_dict[bookworm]="yes"
integer_upsampling_dict[vanilla-bookworm]="no"
integer_upsampling_dict[noble]="yes"
integer_upsampling_dict[vanilla-noble]="no"
integer_upsampling_support=${integer_upsampling_dict[${{ matrix.base }}]}
select_base_image=${base_images_dict[${{ matrix.base }}]}
declare -A upstream_image_from_matrix
upstream_image_from_matrix[bookworm]=debian:bookworm-slim
upstream_image_from_matrix[vanilla-bookworm]=debian:bookworm-slim
upstream_image_from_matrix[noble]=ubuntu:noble
upstream_image_from_matrix[vanilla-noble]=ubuntu:noble
declare -A special_tags
special_tags[bookworm]="${image_name}:stable,${image_name}:latest"
special_tags[vanilla-bookworm]="${image_name}:vanilla-stable,${image_name}:vanilla-latest,${image_name}:vanilla"
special_tags[noble]="${image_name}:ubuntu-current"
special_tags[vanilla-noble]="${image_name}:vanilla-ubuntu-current"
declare -A mpd_version_dict
mpd_version_dict[bookworm]=0.23.16
mpd_version_dict[vanilla-bookworm]=0.23.12
mpd_version_dict[noble]=0.23.16
mpd_version_dict[vanilla-noble]=0.23.14
# select mpd version
mpd_version=${mpd_version_dict["${distro_id}"]};
tags=""
if [ "${ref_type}" = "branch" ]; then
echo "branch mode";
if [ "${ref_name}" = "main" ]; then
echo "main branch";
tags="${image_name}:main-${distro_id}";
tags="$tags,${image_name}:main-${distro_id}-${mpd_version}";
elif [ "${ref_name}" = "devel" ]; then
echo "devel branch";
tags="${image_name}:devel-${distro_id}-${mpd_version}"
else
echo "other branch ["${ref_name}"]";
tags="${image_name}:branch-${ref_name}-${distro_id}-${mpd_version}";
fi
elif [ "${ref_type}" = "tag" ]; then
echo "tag mode";
echo "tag is ["${ref_name}"]";
tag_type=$(echo ${ref_name} | cut -d '/' -f 1)
tag_name=$(echo ${ref_name} | cut -d '/' -f 2)
if [ "${tag_type}" = "release" ]; then
echo "release tag";
echo "Building now: ["$distro_id"]";
tags="${tags},$image_name:${distro_id}";
tags="${tags},$image_name:${distro_id}-${mpd_version}"
tags="$tags,$image_name:${distro_id}-${mpd_version}-${tag_name}"
select_special_tags=${special_tags["${distro_id}"]};
if [[ -n "${select_special_tags}" ]]; then
echo "Found special tags for ["${distro_id}"]=["${select_special_tags}"]";
tags="$tags,${select_special_tags}";
else
echo "No special tag found for ["${distro_id}"]";
fi
elif [ "${tag_type}" = "main" ]; then
echo "main tag";
tags="${image_name}:main-${tag_name}-${distro_id}-${mpd_version}";
elif [ "${tag_type}" = "devel" ]; then
echo "devel tag";
tags="${image_name}:devel-${tag_name}-${distro_id}-${mpd_version}";
elif [ "${tag_type}" = "feature" ]; then
echo "feature tag";
tags="${image_name}:feature-${tag_name}-${distro_id}-${mpd_version}";
elif [ "${tag_type}" = "daily" ]; then
echo "daily build";
tags="${tags},${image_name}:daily-${distro_id}";
tags="${tags},${image_name}:daily-${distro_id}-${mpd_version}";
fi
fi
echo "Building tags: ["${tags}"]"
echo "RELEASE_TAGS=${tags}" >> $GITHUB_OUTPUT
echo "BASE_IMAGE=${select_base_image}" >> $GITHUB_OUTPUT
echo "IS_VANILLA=${is_vanilla}" >> $GITHUB_OUTPUT
echo "INTEGER_UPSAMPLING_SUPPORT=${integer_upsampling_support}" >> $GITHUB_OUTPUT
echo "BUILD_PLATFORMS=${build_platforms}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
build-args: |
BASE_IMAGE=${{ steps.prepare.outputs.BASE_IMAGE }}
INTEGER_UPSAMPLING_SUPPORT=${{ steps.prepare.outputs.INTEGER_UPSAMPLING_SUPPORT }}
IS_VANILLA=${{ steps.prepare.outputs.IS_VANILLA }}
platforms: ${{ steps.prepare.outputs.BUILD_PLATFORMS }}
push: true
tags: ${{ steps.prepare.outputs.RELEASE_TAGS }}