-
Notifications
You must be signed in to change notification settings - Fork 4
146 lines (123 loc) · 4.67 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
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: ["jammy"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare for Docker Build
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"]"
declare -A base_images
base_images[kinetic]=ubuntu:kinetic
base_images[jammy]=ubuntu:jammy
base_images[focal]=ubuntu:focal
base_images[bionic]=ubuntu:bionic
stable="jammy"
latest="jammy"
tag_stable="stable"
tag_latest="latest"
declare -A upmpdcli_versions
upmpdcli_versions[jammy]=1.8.1
upmpdcli_versions[focal]=1.8.1
declare -A libupnpp7_versions
libupnpp7_versions[jammy]=0.23.0
libupnpp7_versions[focal]=0.23.0
base=${{ matrix.base }}
select_base_image=${base_images[$base]}
echo "select_base_image=["$select_base_image"]"
select_upmpdcli_version=${upmpdcli_versions[$base]}
select_libupnp_version=${libupnpp7_versions[$base]}
upmpdcli_version="upmpdcli-$select_upmpdcli_version-libupnpp-$select_libupnp_version"
image_name="${{secrets.DOCKER_USERNAME}}/upmpdcli"
echo "image_name=["$image_name"]"
echo "upmpdcli_version=["$upmpdcli_version"]"
tags=""
if [ "${ref_type}" = "branch" ]; then
echo "branch mode";
if [ "${ref_name}" = "main" ]; then
echo "main branch";
tags="${image_name}:main-${base}";
tags="$tags,${image_name}:main-${base}-${upmpdcli_version}";
elif [ "${ref_name}" = "devel" ]; then
echo "devel branch";
devel_timestamp=$(TZ=Europe/Rome date '+%Y-%m-%d-%H-%M-%S')
tags="${image_name}:devel-${base},${image_name}:devel-${base}-${devel_timestamp}";
else
echo "other branch ["${ref_name}"]";
tags="${image_name}:${ref_name}-${base}";
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)
release=${tag_name}
if [ "${tag_type}" = "release" ]; then
echo "release tag";
tags="${image_name}:${base}";
tags="$tags,${image_name}:${base}-${release}";
tags="$tags,${image_name}:${base}-${upmpdcli_version}";
tags="$tags,${image_name}:${base}-${upmpdcli_version}-${release}";
if [ "${base}" = "${latest}" ]; then
tags="$tags,${image_name}:${tag_latest}";
fi
if [ "${base}" = "${stable}" ]; then
tags="$tags,${image_name}:${tag_stable}";
fi
elif [ "${tag_type}" = "main" ]; then
echo "main tag";
tags="${image_name}:main-${tag_name}-${base}";
elif [ "${tag_type}" = "devel" ]; then
echo "devel tag";
tags="${image_name}:devel-${tag_name}-${base}";
elif [ "${tag_type}" = "feature" ]; then
echo "feature tag";
tags="${image_name}:feature-${tag_name}-${base}";
elif [ "${tag_type}" = "daily" ]; then
echo "daily build";
tags="${tags},${image_name}:daily-${base}";
fi
fi
echo "Building tags: ["${tags}"]"
echo "RELEASE_TAGS=${tags}" >> $GITHUB_ENV
echo "BASE_IMAGE=${select_base_image}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
build-args: |
USE_APT_PROXY=N
BASE_IMAGE=${{ env.BASE_IMAGE }}
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
push: true
tags: ${{ env.RELEASE_TAGS }}