-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (138 loc) · 5.1 KB
/
build.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
name: build
on:
push:
env:
OWNER: ${{ github.repository_owner }}
FILE: watchtower
IMAGE: ghcr.io/${{ github.repository_owner }}/watchtower
BUILDKIT_PROGRESS: plain
BUILDX_NO_DEFAULT_ATTESTATIONS: true
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
windows:
runs-on: windows-${{ matrix.os }}
timeout-minutes: 60
strategy:
matrix:
os: [2019,2022]
env:
BASE: ${{ matrix.os }}
TAG: windows-${{ matrix.os }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Init
run: ./bin/init.sh
shell: bash
# ignore not yet existing images
- name: Fetch the docker images
run: |
docker pull ${{ env.IMAGE }}
docker pull ${{ env.IMAGE }}:${{ env.TAG }}
docker pull ${{ env.IMAGE }}:${{ env.VERSION }}-${{ env.TAG }}
continue-on-error: true
- name: Build the docker image
run: |
docker build \
-t ${{ env.IMAGE }}:${{ env.TAG }} \
-t ${{ env.IMAGE }}:${{ env.VERSION }}-${{ env.TAG }} \
--cache-from ${{ env.IMAGE }} \
--cache-from ${{ env.IMAGE }}:${{ env.TAG }} \
--cache-from ${{ env.IMAGE }}:${{ env.VERSION }}-${{ env.TAG }} \
-f Dockerfile.${{ env.BASE }} \
.
working-directory: ./windows
shell: bash
- name: Test run
run: docker compose --file docker-compose.test.yml run sut
working-directory: ./windows
env:
IMAGE: ${{ env.IMAGE }}:${{ env.TAG }}
- name: Log into registry
if: github.ref == 'refs/heads/main'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: Publish the docker images
if: github.ref == 'refs/heads/main'
run: |
docker push ${{ env.IMAGE }}:${{ env.TAG }}
docker push ${{ env.IMAGE }}:${{ env.VERSION }}-${{ env.TAG }}
linux:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
TAG: linux-amd64
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Init
run: ./bin/init.sh
shell: bash
- name: docker-config
uses: containerbase/internal-tools@85061d6ea57790418fdf4e2672560b82654478de # v3.4.12
with:
command: docker-config
- name: Build the Docker image
run: docker buildx bake test
- name: Test run
run: docker compose --file docker-compose.test.yml run sut
working-directory: ./linux
env:
IMAGE: ${{ env.IMAGE }}:${{ env.TAG }}
- name: Log into registry
if: github.ref == 'refs/heads/main'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: Publish the Docker image
if: github.ref == 'refs/heads/main'
run: docker buildx bake build
multi-arch:
needs: [linux, windows]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
timeout-minutes: 30
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: docker-config
uses: containerbase/internal-tools@85061d6ea57790418fdf4e2672560b82654478de # v3.4.12
with:
command: docker-config
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
- name: Init
run: ./bin/init.sh
- name: Build the Docker multiarch manifest
run: |
docker manifest create ${{ env.IMAGE }} \
${{ env.IMAGE }}:linux-amd64 \
${{ env.IMAGE }}:windows-2019 \
${{ env.IMAGE }}:windows-2022
docker manifest create ${{ env.IMAGE }}:${{ env.VERSION }} \
${{ env.IMAGE }}:${{ env.VERSION }}-linux-amd64 \
${{ env.IMAGE }}:${{ env.VERSION }}-windows-2019 \
${{ env.IMAGE }}:${{ env.VERSION }}-windows-2022
- name: Publish the Docker multiarch manifest
run: |
docker manifest push ${{ env.IMAGE }}
docker manifest push ${{ env.IMAGE }}:${{ env.VERSION }}
- name: Inspect the Docker multiarch manifest
run: docker manifest inspect ${{ env.IMAGE }}
release:
needs: multi-arch
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Init
run: ./bin/init.sh
- uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
with:
allowUpdates: true
body: See https://github.com/containrrr/watchtower/releases/tag/v${{ env.VERSION }} for more changes
commit: ${{ github.sha }}
name: ${{ env.VERSION }}
tag: v${{ env.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}