-
Notifications
You must be signed in to change notification settings - Fork 10
180 lines (160 loc) · 7.17 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
179
180
name: Publish Regular multi-arch Docker images
on:
push:
tags:
- "release/*"
- "feature/*"
- "daily/*"
- "v*" # release
- "f*" # feature
- "d*" # daily
jobs:
release:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
base: [ stable ]
build_mode: [ std, sf, r2 ]
binary_mode: [ full, pulse, alsa, alsa-bt ]
exclude:
- base: stable
build_mode: r2
binary_mode: full
- base: stable
build_mode: r2
binary_mode: pulse
- base: stable
build_mode: r2
binary_mode: alsa-bt
- base: stable
build_mode: sf
binary_mode: alsa-bt
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare for docker build
id: prepare
run: |
image_name=${{secrets.DOCKER_USERNAME}}/squeezelite
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"]"
build_platforms="linux/amd64,linux/arm64/v8,linux/arm/v7"
if [[ ${{ matrix.build_mode }} = "std" ]] || [[ ${{ matrix.build_mode }} = "r2" ]]; then
build_platforms="${build_platforms},linux/arm/v5"
fi
declare -A base_image_from_matrix
base_image_from_matrix[sid]=debian:sid-slim
base_image_from_matrix[trixie]=debian:trixie-slim
base_image_from_matrix[bookworm]=debian:bookworm-slim
select_base_image=${base_image_from_matrix[${{ matrix.base }}]}
if [ -z "${select_base_image}" ]; then
select_base_image=debian:stable-slim
fi
echo "Select Base Image [" $select_base_image "]"
declare -A sl_versions
sl_versions[stable]=current
declare -A special_tags
special_tags[stable-std-full]="${image_name}:latest,${image_name}:stable"
special_tags[stable-std-alsa]="${image_name}:latest-alsa,${image_name}:stable-alsa"
special_tags[stable-std-pulse]="${image_name}:latest-pulse,${image_name}:stable-pulse"
special_tags[stable-sf-full]="${image_name}:sourceforge-latest,${image_name}:sourceforge-stable"
special_tags[stable-sf-alsa]="${image_name}:sourceforge-latest-alsa,${image_name}:sourceforge-stable-alsa"
special_tags[stable-sf-pulse]="${image_name}:sourceforge-latest-pulse,${image_name}:sourceforge-stable-pulse"
special_tags[stable-r2-alsa]="${image_name}:r2-latest-alsa,${image_name}:r2-stable-alsa"
declare -A distro_friendly_name_dict
distro_friendly_name_dict[stable]=debian
distro_friendly_name=${{ matrix.base }}
binary_mode=${{ matrix.binary_mode }}
lookup_distro_name=${distro_friendly_name_dict[${{ matrix.base }}]}
if [ -n "${lookup_distro_name}" ]; then
distro_friendly_name=$lookup_distro_name
fi
squeezelite_version_str=""
if [ ${{ matrix.build_mode }} = "sf" ]; then
squeezelite_version_str="squeezelite-current-sourceforge"
elif [ ${{ matrix.build_mode }} = "r2" ]; then
squeezelite_version_str="squeezelite-1.8.4-r2"
else
select_squeezelite_version=unknown
select_squeezelite_version=${sl_versions[${{ matrix.base }}]}
if [ -z "${select_squeezelite_version}" ]; then
select_squeezelite_version=version-unknown
fi
echo "Version from dictionary: "$select_squeezelite_version" from ["${{ matrix.base }}"]"
squeezelite_version_str="squeezelite-"$select_squeezelite_version
fi
tags=""
if [ "${ref_type}" = "tag" ]; then
echo "tag mode"
echo "tag is ["${ref_name}"]"
if [[ "${ref_name}" = *"/"* ]]; then
tag_type=$(echo ${ref_name} | cut -d '/' -f 1)
tag_name=$(echo ${ref_name} | cut -d '/' -f 2)
else
if [[ "${ref_name}" = "v"* || "${ref_name}" = "f"* || "${ref_name}" = "d"* ]]; then
tag_type=${ref_name:0:1}
tag_name=${ref_name:1}
fi
fi
echo "tag_type=[$tag_type]"
echo "tag_name=[$tag_name]"
if [[ "${tag_type}" == "release" || "${tag_type}" == "v" ]]; then
echo "release tag"
tags="$image_name:${distro_friendly_name}-${binary_mode}-${squeezelite_version_str}"
tags="$tags,$image_name:${distro_friendly_name}-${binary_mode}-${squeezelite_version_str}-${tag_name}"
special_tag_lookup="${{ matrix.base }}-${{ matrix.build_mode }}-${{ matrix.binary_mode }}"
select_special_tags=${special_tags["${special_tag_lookup}"]}
building_now="${distro_friendly_name}-${binary_mode}-${{ matrix.build_mode }}"
echo "Building now: ["$building_now"]"
if [[ -n "${select_special_tags}" ]]; then
echo "Found special tags for ["${building_now}"]=["${select_special_tags}"]"
tags="$tags,${select_special_tags}"
else
echo "No special tags found for ["${building_now}"]"
fi
elif [[ "${tag_type}" == "feature" || "${tag_type}" == "f" ]]; then
echo "feature tag"
tags="${image_name}:feature-${tag_name}-${distro_friendly_name}-${binary_mode}-${squeezelite_version_str}"
elif [[ "${tag_type}" = "daily" || "${tag_type}" = "d" ]]; then
echo "daily build"
if [ ${{ matrix.build_mode }} = "N" ]; then
tags="${tags},${image_name}:daily-${distro_friendly_name}-${binary_mode}"
else
tags="${tags},${image_name}:daily-${distro_friendly_name}-${binary_mode}-sourceforge"
fi
tags="${tags},${image_name}:daily-${distro_friendly_name}-${binary_mode}-${squeezelite_version_str}"
fi
fi
echo "Building tags: ["${tags}"]"
echo "RELEASE_TAGS=${tags}" >> $GITHUB_OUTPUT
echo "BASE_IMAGE=${select_base_image}" >> $GITHUB_OUTPUT
echo "BUILD_MODE=${{ matrix.build_mode }}" >> $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 }}
BUILD_MODE=${{ matrix.build_mode }}
BINARY_MODE=${{ matrix.binary_mode }}
platforms: ${{ steps.prepare.outputs.BUILD_PLATFORMS }}
push: true
tags: ${{ steps.prepare.outputs.RELEASE_TAGS }}