-
-
Notifications
You must be signed in to change notification settings - Fork 7
200 lines (196 loc) · 6.01 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: build
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'master'
- 'releases/*'
tags:
- '*'
paths-ignore:
- '**.md'
pull_request:
branches:
- 'master'
- 'releases/*'
paths-ignore:
- '**.md'
env:
DOCKERHUB_SLUG: crazymax/alpine-s6
GHCR_SLUG: ghcr.io/crazy-max/alpine-s6
DOCKERHUB_DIST_SLUG: crazymax/alpine-s6-dist
GHCR_DIST_SLUG: ghcr.io/crazy-max/alpine-s6-dist
ALPINE_LATEST: '3.20'
jobs:
build:
strategy:
fail-fast: false
matrix:
alpine_version:
- '3.15'
- '3.16'
- '3.17'
- '3.18'
- '3.19'
- '3.20'
- 'edge'
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Prepare
run: |
NL=$'\n'
ALPINE_VERSION=${{ matrix.alpine_version }}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
TAG=${GITHUB_REF#refs/tags/}
VERSION=${TAG%-r*}
fi
IMAGE_TAGS=""
if [[ $ALPINE_VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3} ]]; then
IMAGE_TAGS="${IMAGE_TAGS}${ALPINE_VERSION}-${VERSION}${NL}"
if [ "$ALPINE_VERSION" = "${{ env.ALPINE_LATEST }}" ]; then
IMAGE_TAGS="${IMAGE_TAGS}latest-${VERSION}${NL}"
fi
else
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3} ]]; then
IMAGE_TAGS="${IMAGE_TAGS}${ALPINE_VERSION}-${VERSION}${NL}"
else
IMAGE_TAGS="${IMAGE_TAGS}${VERSION}${NL}"
fi
fi
if [ "$VERSION" != "edge" ]; then
IMAGE_TAGS="${IMAGE_TAGS}${ALPINE_VERSION}${NL}"
if [ "$ALPINE_VERSION" = "${{ env.ALPINE_LATEST }}" ]; then
IMAGE_TAGS="${IMAGE_TAGS}latest${NL}"
fi
fi
echo "IMAGE_TAGS<<EOF" >> $GITHUB_ENV
echo -e "$IMAGE_TAGS" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKERHUB_SLUG }}
${{ env.GHCR_SLUG }}
tags: ${{ env.IMAGE_TAGS }}
labels: |
org.opencontainers.image.title=alpine-s6
org.opencontainers.image.description=Alpine Linux with s6 overlay
org.opencontainers.image.vendor=CrazyMax
-
name: Docker meta dist
id: meta_dist
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKERHUB_DIST_SLUG }}
${{ env.GHCR_DIST_SLUG }}
tags: ${{ env.IMAGE_TAGS }}
labels: |
org.opencontainers.image.title=alpine-s6-dist
org.opencontainers.image.description=s6 overlay
org.opencontainers.image.vendor=CrazyMax
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-config-inline: |
[worker.oci]
max-parallelism = 4
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build artifacts
uses: docker/bake-action@v5
with:
targets: artifact-all
pull: true
provenance: false
env:
ALPINE_VERSION: ${{ matrix.alpine_version }}
-
name: Move artifacts
if: matrix.alpine_version == env.ALPINE_LATEST
run: |
mv ./dist/**/* ./dist/
-
name: Upload artifacts
if: matrix.alpine_version == env.ALPINE_LATEST
uses: actions/upload-artifact@v3
with:
name: s6-overlay
path: ./dist/*
if-no-files-found: error
-
name: Build image
uses: docker/bake-action@v5
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: image-all
push: ${{ github.event_name != 'pull_request' }}
env:
ALPINE_VERSION: ${{ matrix.alpine_version }}
-
name: Build dist
uses: docker/bake-action@v5
with:
files: |
./docker-bake.hcl
${{ steps.meta_dist.outputs.bake-file }}
targets: image-dist-all
pull: true
push: ${{ github.event_name != 'pull_request' }}
env:
ALPINE_VERSION: ${{ matrix.alpine_version }}
-
name: GitHub Release
uses: softprops/action-gh-release@v2
if: matrix.alpine_version == env.ALPINE_LATEST && startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: |
dist/*.tar.gz
dist/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Check manifest
if: github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.meta.outputs.version }}
docker buildx imagetools inspect ${{ env.GHCR_SLUG }}:${{ steps.meta.outputs.version }}
-
name: Check pull
if: github.event_name != 'pull_request'
run: |
docker pull ${{ env.DOCKERHUB_SLUG }}:${{ steps.meta.outputs.version }}
docker image inspect ${{ env.DOCKERHUB_SLUG }}:${{ steps.meta.outputs.version }}
docker pull ${{ env.GHCR_SLUG }}:${{ steps.meta.outputs.version }}
docker image inspect ${{ env.GHCR_SLUG }}:${{ steps.meta.outputs.version }}