-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
216 lines (207 loc) · 8.29 KB
/
build-multiarch.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
name: Build and Publish
on:
push:
branches:
- master
- test/**
tags:
- "[0-9]+.[0-9]+.[0-9]+"
paths-ignore:
- "*.md"
- "docs/**"
- "examples/**"
jobs:
build:
strategy:
fail-fast: false
matrix:
# NOTE: the "latest" variant is identified in the Docker meta step's 'latest' config
variant:
- java21-graalvm
- java21
- java21-alpine
- java17
- java17-graalvm
- java17-jdk
- java17-openj9
- java17-alpine
- java8
- java8-graalvm-ce
- java8-multiarch
- java8-openj9
- java8-jdk
- java11
- java11-openj9
- java11-jdk
include:
# JAVA 21:
- variant: java21-graalvm
baseImage: container-registry.oracle.com/graalvm/jdk:21-ol8
platforms: linux/amd64,linux/arm64
mcVersion: 1.20.2
- variant: java21
baseImage: eclipse-temurin:21-jre
platforms: linux/amd64,linux/arm64
mcVersion: 1.19.3
- variant: java21-alpine
baseImage: eclipse-temurin:21-jre-alpine
platforms: linux/amd64
mcVersion: 1.19.3
# JAVA 17:
- variant: java17
# jammy doesn't work until minecraft updates to https://github.com/netty/netty/issues/12343
baseImage: eclipse-temurin:17-jre-focal
platforms: linux/amd64,linux/arm/v7,linux/arm64
mcVersion: 1.18.2
- variant: java17-graalvm
baseImage: container-registry.oracle.com/graalvm/jdk:17-ol8
platforms: linux/amd64,linux/arm64
mcVersion: 1.18.2
- variant: java17-jdk
baseImage: eclipse-temurin:17-focal
platforms: linux/amd64,linux/arm/v7,linux/arm64
mcVersion: 1.18.2
- variant: java17-openj9
baseImage: ibm-semeru-runtimes:open-17-jre
platforms: linux/amd64,linux/arm64
mcVersion: 1.18.2
- variant: java17-alpine
baseImage: eclipse-temurin:17-jre-alpine
platforms: linux/amd64
mcVersion: 1.18.2
# JAVA 11:
- variant: java11
baseImage: adoptopenjdk:11-jre-hotspot
platforms: linux/amd64,linux/arm/v7,linux/arm64
mcVersion: 1.16.5
- variant: java11-jdk
baseImage: adoptopenjdk:11-jdk-hotspot
platforms: linux/amd64,linux/arm/v7,linux/arm64
mcVersion: 1.16.5
- variant: java11-openj9
baseImage: ibm-semeru-runtimes:open-11-jre
platforms: linux/amd64,linux/arm64
mcVersion: 1.16.5
# JAVA 8: NOTE: Unable to go past 8u312 because of Forge dependencies
- variant: java8
baseImage: openjdk:8-jre-alpine3.9
platforms: linux/amd64
mcVersion: 1.12.2
- variant: java8-graalvm-ce
baseImage: ghcr.io/graalvm/graalvm-ce:java8
platforms: linux/amd64
mcVersion: 1.12.2
- variant: java8-multiarch
baseImage: eclipse-temurin:8u312-b07-jre-focal
platforms: linux/amd64,linux/arm/v7,linux/arm64
mcVersion: 1.12.2
- variant: java8-jdk
baseImage: eclipse-temurin:8u312-b07-jdk-focal
platforms: linux/amd64,linux/arm64
mcVersion: 1.12.2
- variant: java8-openj9
baseImage: ibm-semeru-runtimes:open-8u312-b07-jre
platforms: linux/amd64,linux/arm64
mcVersion: 1.12.2
env:
IMAGE_TO_TEST: ${{ github.repository_owner }}/minecraft-server:test-${{ matrix.variant }}-${{ github.run_id }}
HAS_IMAGE_REPO_ACCESS: ${{ secrets.DOCKER_USER != '' && secrets.DOCKER_PASSWORD != '' }}
MAIN_VARIANT: java17
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/[email protected]
with:
# for build-files step
fetch-depth: 0
- name: Docker meta
id: meta
uses: docker/[email protected]
with:
# NOTE for forks: if your Docker Hub organization doesn't match your Github repo's,
# then the use of ${{ github.repository_owner }} will need to be replaced.
images: |
${{ github.repository_owner }}/minecraft-server
ghcr.io/${{ github.repository_owner }}/minecraft-server
tags: |
# For the "main" variant, it gets the tag as-is, without suffix
type=ref,event=tag,enable=${{ matrix.variant == env.MAIN_VARIANT }}
# and each variant (including main one) gets the tag with the variant suffix, such as 2023.1.1-java17
type=ref,event=tag,suffix=-${{ matrix.variant }}
# for building test/* branch images
type=ref,event=branch,suffix=-${{ matrix.variant }},enable=${{ github.ref_name != github.event.repository.default_branch }}
# latest repo tag gets a moving 'stable' image tag applied to the main variant
type=raw,value=stable,enable=${{ github.ref_type == 'tag' && matrix.variant == env.MAIN_VARIANT }}
# apply the variant as a moving tag for most recent commit per variant
type=raw,value=${{ matrix.variant }},enable=${{ github.ref_name == github.event.repository.default_branch }}
# NOTE this identifies which variant will be published as "latest", which isn't
# necessarily the newest version of Java
flavor: |
latest=${{ matrix.variant == env.MAIN_VARIANT && github.ref_name == github.event.repository.default_branch }}
labels: |
org.opencontainers.image.authors=Geoff Bourne <[email protected]>
- name: Setup Docker Buildx
uses: docker/[email protected]
- name: Set up QEMU
uses: docker/[email protected]
- name: Build for test
uses: docker/[email protected]
with:
platforms: linux/amd64
tags: ${{ env.IMAGE_TO_TEST }}
# ensure latest base image is used
pull: true
# load into daemon for test usage in next step
load: true
push: false
build-args: |
BASE_IMAGE=${{ matrix.baseImage }}
cache-from: type=gha,scope=${{ matrix.variant }}
# no cache-to to avoid cross-cache update from next build step
- name: Run tests
env:
MINECRAFT_VERSION: ${{ matrix.mcVersion }}
VARIANT: ${{ matrix.variant }}
CF_API_KEY: ${{ secrets.CF_API_KEY }}
run: |
tests/test.sh
- name: Login to DockerHub
uses: docker/[email protected]
if: env.HAS_IMAGE_REPO_ACCESS
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
uses: docker/[email protected]
if: env.HAS_IMAGE_REPO_ACCESS
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push
uses: docker/[email protected]
if: github.actor == github.repository_owner
with:
platforms: ${{ matrix.platforms }}
push: >
${{
github.ref_type == 'tag'
|| github.ref_name == github.event.repository.default_branch
|| startsWith(github.ref_name, 'test/')
|| ( github.event_name == 'pull_request'
&& env.HAS_IMAGE_REPO_ACCESS
&& contains(github.event.pull_request.labels.*.name, 'ci/push-image')
)
}}
tags: ${{ steps.meta.outputs.tags }}
# ensure latest base image is used
pull: true
labels: ${{ steps.meta.outputs.labels }}
# Since some consumers, like Watchtower are broken https://github.com/containrrr/watchtower/discussions/1529
# Also refer to https://github.com/docker/build-push-action/releases/tag/v3.3.0
provenance: false
build-args: |
BASE_IMAGE=${{ matrix.baseImage }}
BUILD_FILES_REV=${{ steps.build-files-rev.outputs.REV }}
cache-from: type=gha,scope=${{ matrix.variant }}
cache-to: type=gha,mode=max,scope=${{ matrix.variant }}