-
-
Notifications
You must be signed in to change notification settings - Fork 2
236 lines (214 loc) · 9.22 KB
/
publish.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: Publish release artifacts and Docker image
permissions:
contents: read
on:
release:
types:
- published
jobs:
build-image:
name: Build the Docker image on Docker Hub
environment:
name: "docker-hub"
url: https://hub.docker.com/r/wdes/mail-autodiscover-autoconfig
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 4
matrix:
include:
- { platform: "linux/arm/v6", internal-tag: "armv6" }
- { platform: "linux/arm/v7", internal-tag: "armv7" }
# Does not finish building
#- { platform: "linux/arm64/v8", internal-tag: "arm64v8" }
- { platform: "linux/386", internal-tag: "386" }
# Does not finish building
#- { platform: "linux/ppc64le", internal-tag: "ppc64le" }
- { platform: "linux/amd64", internal-tag: "amd64" }
steps:
- name: Checkout repository
uses: actions/checkout@v4
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to the registry
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push image
run: make docker-build
env:
DOCKER_BUILDKIT: 1
BUILDKIT_MULTI_PLATFORM: "false"
PLATFORM: ${{ matrix.platform }}
IMAGE_TAG: "docker.io/wdes/mail-autodiscover-autoconfig:${{ matrix.internal-tag }}-latest"
ACTION: push
# Disable provenance to remove the attestation from the pushed image
# See: https://github.com/docker/buildx/issues/1509
# It makes: docker.io/wdes/mail-autodiscover-autoconfig:<arch>-latest a manifest list
# And docker manifest create does not like that
EXTRA_ARGS: "--provenance=false"
create-final-image:
environment:
name: "docker-hub"
url: https://hub.docker.com/r/wdes/mail-autodiscover-autoconfig
runs-on: ubuntu-latest
needs: build-image
name: Create the image manifest
steps:
- name: Login to the registry
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Create the manifest
# docker.io/wdes/mail-autodiscover-autoconfig:arm64v8-latest \
# docker.io/wdes/mail-autodiscover-autoconfig:ppc64le-latest \
run: |
docker manifest create docker.io/wdes/mail-autodiscover-autoconfig:latest \
docker.io/wdes/mail-autodiscover-autoconfig:armv6-latest \
docker.io/wdes/mail-autodiscover-autoconfig:armv7-latest \
docker.io/wdes/mail-autodiscover-autoconfig:386-latest \
docker.io/wdes/mail-autodiscover-autoconfig:amd64-latest \
--amend
- name: Push the manifest
run: docker manifest push docker.io/wdes/mail-autodiscover-autoconfig:latest
- name: Inspect the manifest
run: docker manifest inspect docker.io/wdes/mail-autodiscover-autoconfig:latest
tags-cleanup:
environment:
name: "docker-hub"
url: https://hub.docker.com/r/wdes/mail-autodiscover-autoconfig
runs-on: ubuntu-latest
needs: create-final-image
name: Cleanup build tags
strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
- { platform: "linux/arm/v6", internal-tag: "armv6" }
- { platform: "linux/arm/v7", internal-tag: "armv7" }
# Does not finish building
#- { platform: "linux/arm64/v8", internal-tag: "arm64v8" }
- { platform: "linux/386", internal-tag: "386" }
# Does not finish building
#- { platform: "linux/ppc64le", internal-tag: "ppc64le" }
- { platform: "linux/amd64", internal-tag: "amd64" }
steps:
- name: Install Docker hub-tool
run: |
curl -sL https://github.com/docker/hub-tool/releases/download/v0.4.5/hub-tool-linux-amd64.tar.gz -o hub-tool-linux.tar.gz
tar --strip-components=1 -xzf ./hub-tool-linux.tar.gz
./hub-tool --version
- name: Login hub-tool
run: |
# Fool the login command (https://github.com/docker/hub-tool/pull/198)
# ./hub-tool login
# Token commands thank to https://stackoverflow.com/a/59334315/5155484
HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"$DOCKER_USERNAME\", \"password\": \"$DOCKER_PASSWORD\"}" https://hub.docker.com/v2/users/login/ | jq -r .token)
USERNAME="$(printf '%s:' "$DOCKER_USERNAME" | base64 -w0)"
USER_PASS="$(printf '%s:%s' "$DOCKER_USERNAME" "$DOCKER_PASSWORD" | base64 -w0)"
mkdir -p ~/.docker/
printf '{"auths": {"hub-tool": {"auth": "%s"}, "hub-tool-refresh-token": {"auth": "%s"}, "hub-tool-token": { "auth": "%s", "identitytoken": "%s"}}}' \
"$USER_PASS" "$USERNAME" \
"$USERNAME" "$HUB_TOKEN" \
> ~/.docker/config.json
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Remove PR container image via hub-tool
run: |
./hub-tool tag rm --verbose --force docker.io/wdes/mail-autodiscover-autoconfig:${{ matrix.internal-tag }}-latest || true
./hub-tool tag ls --verbose ocker.io/wdes/mail-autodiscover-autoconfig
- name: Logout hub-tool
if: always()
run: rm ~/.docker/config.json
publish-binaries:
name: Publish multi arch binaries on the release draft (${{ matrix.arch }}-${{ matrix.variant }}) for ${{ matrix.os }}
runs-on: ubuntu-latest
permissions:
contents: write # Edit release artifacts
strategy:
fail-fast: false
max-parallel: 4
matrix:
include:
- { os: linux, arch: x86_64, variant: gnu }
- { os: linux, arch: x86_64, variant: musl }
- { os: linux, arch: aarch64, variant: gnu }
- { os: linux, arch: aarch64, variant: musl }
- { os: linux, arch: riscv64gc, variant: gnu }
- { os: linux, arch: arm, variant: gnueabi }
- { os: linux, arch: arm, variant: gnueabihf }
- { os: linux, arch: arm, variant: musleabi }
- { os: linux, arch: arm, variant: musleabihf }
- { os: linux, arch: armv7, variant: gnueabi }
- { os: linux, arch: armv7, variant: gnueabihf }
- { os: linux, arch: armv7, variant: musleabi }
- { os: linux, arch: armv7, variant: musleabihf }
- { os: linux, arch: s390x, variant: gnu }
- { os: linux, arch: armv5te, variant: gnueabi }
- { os: linux, arch: armv5te, variant: musleabi }
- { os: linux, arch: i586, variant: gnu }
- { os: linux, arch: i586, variant: musl }
- { os: linux, arch: i686, variant: gnu }
- { os: linux, arch: powerpc, variant: gnu }
- { os: linux, arch: powerpc64, variant: gnu }
- { os: linux, arch: powerpc64le, variant: gnu }
- { os: linux, arch: sparc64, variant: gnu }
steps:
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.72
override: true
target: ${{ matrix.arch }}-unknown-${{ matrix.os }}-${{ matrix.variant }}
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --locked --target ${{ matrix.arch }}-unknown-${{ matrix.os }}-${{ matrix.variant }}
- name: Create builds folder
run: mkdir ./builds
- name: Rename file
run: mv ./target/${{ matrix.arch }}-unknown-${{ matrix.os }}-${{ matrix.variant }}/release/mail-autodiscover-autoconfig ./builds/mail-autodiscover-autoconfig_${{ matrix.arch }}-unknown-${{ matrix.os }}-${{ matrix.variant }}
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: mail-autodiscover-autoconfig_${{ matrix.arch }}-unknown-${{ matrix.os }}-${{ matrix.variant }}.tgz
path: ./builds/*
if-no-files-found: error
retention-days: 1
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: builds/*
file_glob: true
tag: ${{ github.ref }}