2023-09-13 12:53:05 +00:00
|
|
|
name: Build and Publish
|
2021-02-06 20:52:20 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2021-05-21 12:46:49 +00:00
|
|
|
- master
|
2022-01-17 02:49:15 +00:00
|
|
|
- test/**
|
2021-02-06 20:52:20 +00:00
|
|
|
tags:
|
2021-05-21 12:39:59 +00:00
|
|
|
- "[0-9]+.[0-9]+.[0-9]+"
|
2021-05-01 22:39:35 +00:00
|
|
|
paths-ignore:
|
|
|
|
- "*.md"
|
2021-05-02 23:31:08 +00:00
|
|
|
- "docs/**"
|
|
|
|
- "examples/**"
|
2021-02-06 20:52:20 +00:00
|
|
|
|
|
|
|
jobs:
|
2021-12-05 00:42:03 +00:00
|
|
|
build:
|
2022-01-29 20:53:34 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
2023-01-13 14:44:13 +00:00
|
|
|
# NOTE: the "latest" variant is identified in the Docker meta step's 'latest' config
|
2022-01-29 20:53:34 +00:00
|
|
|
variant:
|
2023-10-07 20:19:01 +00:00
|
|
|
- java21-graalvm
|
2023-05-31 16:15:30 +00:00
|
|
|
- java20
|
|
|
|
- java20-alpine
|
2022-01-29 20:53:34 +00:00
|
|
|
- java17
|
2023-09-08 12:38:14 +00:00
|
|
|
- java17-graalvm
|
2022-03-05 21:53:00 +00:00
|
|
|
- java17-jdk
|
2022-01-29 20:53:34 +00:00
|
|
|
- java17-openj9
|
2022-02-12 03:00:24 +00:00
|
|
|
- java17-alpine
|
|
|
|
- java8
|
2022-07-16 15:11:11 +00:00
|
|
|
- java8-graalvm-ce
|
2022-01-29 20:53:34 +00:00
|
|
|
- java8-multiarch
|
|
|
|
- java8-openj9
|
2022-03-05 21:53:00 +00:00
|
|
|
- java8-jdk
|
2022-01-29 20:53:34 +00:00
|
|
|
- java11
|
|
|
|
- java11-openj9
|
2022-03-05 21:53:00 +00:00
|
|
|
- java11-jdk
|
2022-01-29 20:53:34 +00:00
|
|
|
include:
|
2023-10-07 19:07:24 +00:00
|
|
|
# JAVA 21:
|
|
|
|
- variant: java21-graalvm
|
|
|
|
baseImage: container-registry.oracle.com/graalvm/jdk:21-ol8
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
mcVersion: 1.20.2
|
2023-05-31 16:15:30 +00:00
|
|
|
# JAVA 20:
|
|
|
|
- variant: java20
|
|
|
|
baseImage: eclipse-temurin:20-jre
|
2023-05-31 18:14:05 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2023-01-13 14:44:13 +00:00
|
|
|
mcVersion: 1.19.3
|
2023-05-31 16:15:30 +00:00
|
|
|
- variant: java20-alpine
|
|
|
|
baseImage: eclipse-temurin:20-jre-alpine
|
|
|
|
platforms: linux/amd64
|
|
|
|
mcVersion: 1.19.3
|
2022-02-24 18:18:49 +00:00
|
|
|
# JAVA 17:
|
2022-01-29 20:53:34 +00:00
|
|
|
- variant: java17
|
2022-05-29 01:06:23 +00:00
|
|
|
# jammy doesn't work until minecraft updates to https://github.com/netty/netty/issues/12343
|
|
|
|
baseImage: eclipse-temurin:17-jre-focal
|
2022-02-24 18:18:49 +00:00
|
|
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
2022-06-08 16:12:49 +00:00
|
|
|
mcVersion: 1.18.2
|
2023-09-08 12:38:14 +00:00
|
|
|
- variant: java17-graalvm
|
|
|
|
baseImage: container-registry.oracle.com/graalvm/jdk:17-ol8
|
2022-07-16 15:11:11 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
mcVersion: 1.18.2
|
2022-02-24 18:18:49 +00:00
|
|
|
- variant: java17-jdk
|
2022-05-29 01:06:23 +00:00
|
|
|
baseImage: eclipse-temurin:17-focal
|
2022-01-29 20:53:34 +00:00
|
|
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
2022-06-08 16:12:49 +00:00
|
|
|
mcVersion: 1.18.2
|
2022-01-29 20:53:34 +00:00
|
|
|
- variant: java17-openj9
|
2022-02-24 18:18:49 +00:00
|
|
|
baseImage: ibm-semeru-runtimes:open-17-jre
|
2022-01-29 20:53:34 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2022-06-08 16:12:49 +00:00
|
|
|
mcVersion: 1.18.2
|
2022-02-12 03:00:24 +00:00
|
|
|
- variant: java17-alpine
|
2022-02-24 18:18:49 +00:00
|
|
|
baseImage: eclipse-temurin:17-jre-alpine
|
2022-02-12 03:00:24 +00:00
|
|
|
platforms: linux/amd64
|
2022-06-08 16:12:49 +00:00
|
|
|
mcVersion: 1.18.2
|
2022-02-24 18:18:49 +00:00
|
|
|
# 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
|
2022-02-24 22:47:22 +00:00
|
|
|
# JAVA 8: NOTE: Unable to go past 8u312 because of Forge dependencies
|
2022-02-12 03:00:24 +00:00
|
|
|
- variant: java8
|
2022-02-24 18:18:49 +00:00
|
|
|
baseImage: openjdk:8-jre-alpine3.9
|
2022-02-12 03:00:24 +00:00
|
|
|
platforms: linux/amd64
|
|
|
|
mcVersion: 1.12.2
|
2022-07-16 15:11:11 +00:00
|
|
|
- variant: java8-graalvm-ce
|
|
|
|
baseImage: ghcr.io/graalvm/graalvm-ce:java8
|
|
|
|
platforms: linux/amd64
|
|
|
|
mcVersion: 1.12.2
|
2022-01-29 20:53:34 +00:00
|
|
|
- variant: java8-multiarch
|
2022-05-29 01:06:23 +00:00
|
|
|
baseImage: eclipse-temurin:8u312-b07-jre-focal
|
2022-10-08 02:19:08 +00:00
|
|
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
2022-01-29 20:53:34 +00:00
|
|
|
mcVersion: 1.12.2
|
2022-02-24 18:18:49 +00:00
|
|
|
- variant: java8-jdk
|
2022-05-29 01:06:23 +00:00
|
|
|
baseImage: eclipse-temurin:8u312-b07-jdk-focal
|
2022-01-29 20:53:34 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
mcVersion: 1.12.2
|
2022-02-24 18:18:49 +00:00
|
|
|
- variant: java8-openj9
|
|
|
|
baseImage: ibm-semeru-runtimes:open-8u312-b07-jre
|
2022-01-29 20:53:34 +00:00
|
|
|
platforms: linux/amd64,linux/arm64
|
2022-02-24 18:18:49 +00:00
|
|
|
mcVersion: 1.12.2
|
2022-01-29 20:53:34 +00:00
|
|
|
env:
|
2022-02-12 03:00:24 +00:00
|
|
|
IMAGE_TO_TEST: ${{ github.repository_owner }}/minecraft-server:test-${{ matrix.variant }}-${{ github.run_id }}
|
2022-08-03 03:47:35 +00:00
|
|
|
HAS_IMAGE_REPO_ACCESS: ${{ secrets.DOCKER_USER != '' && secrets.DOCKER_PASSWORD != '' }}
|
2023-06-23 16:40:47 +00:00
|
|
|
MAIN_VARIANT: java17
|
2021-02-06 20:52:20 +00:00
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-10-24 13:42:01 +00:00
|
|
|
uses: actions/checkout@v4.1.1
|
2022-02-12 03:00:24 +00:00
|
|
|
with:
|
|
|
|
# for build-files step
|
|
|
|
fetch-depth: 0
|
2021-02-06 20:52:20 +00:00
|
|
|
|
2021-05-14 22:48:17 +00:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
2023-09-23 23:44:45 +00:00
|
|
|
uses: docker/metadata-action@v5.0.0
|
2021-05-14 22:48:17 +00:00
|
|
|
with:
|
2022-02-12 03:00:24 +00:00
|
|
|
# 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.
|
2021-05-14 22:48:17 +00:00
|
|
|
images: |
|
2022-02-12 03:00:24 +00:00
|
|
|
${{ github.repository_owner }}/minecraft-server
|
2023-04-09 15:39:26 +00:00
|
|
|
ghcr.io/${{ github.repository_owner }}/minecraft-server
|
2021-05-14 22:48:17 +00:00
|
|
|
tags: |
|
2023-06-23 16:40:47 +00:00
|
|
|
# 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
|
2022-02-05 22:02:27 +00:00
|
|
|
type=ref,event=tag,suffix=-${{ matrix.variant }}
|
2023-06-23 16:40:47 +00:00
|
|
|
# for building test/* branch images
|
2023-06-23 19:04:44 +00:00
|
|
|
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 }}
|
2023-01-13 14:44:13 +00:00
|
|
|
# NOTE this identifies which variant will be published as "latest", which isn't
|
|
|
|
# necessarily the newest version of Java
|
2021-05-22 04:00:27 +00:00
|
|
|
flavor: |
|
2023-06-23 19:04:44 +00:00
|
|
|
latest=${{ matrix.variant == env.MAIN_VARIANT && github.ref_name == github.event.repository.default_branch }}
|
2022-01-29 20:53:34 +00:00
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.authors=Geoff Bourne <itzgeoff@gmail.com>
|
2021-02-06 20:52:20 +00:00
|
|
|
|
|
|
|
- name: Setup Docker Buildx
|
2023-09-23 23:44:45 +00:00
|
|
|
uses: docker/setup-buildx-action@v3.0.0
|
2021-02-06 20:52:20 +00:00
|
|
|
|
|
|
|
- name: Set up QEMU
|
2023-09-23 23:44:45 +00:00
|
|
|
uses: docker/setup-qemu-action@v3.0.0
|
2021-02-06 20:52:20 +00:00
|
|
|
|
2021-12-05 00:42:03 +00:00
|
|
|
- name: Build for test
|
2023-09-23 23:44:45 +00:00
|
|
|
uses: docker/build-push-action@v5.0.0
|
2021-12-05 00:42:03 +00:00
|
|
|
with:
|
|
|
|
platforms: linux/amd64
|
|
|
|
tags: ${{ env.IMAGE_TO_TEST }}
|
|
|
|
# ensure latest base image is used
|
|
|
|
pull: true
|
2022-01-29 20:53:34 +00:00
|
|
|
# load into daemon for test usage in next step
|
2021-12-05 00:42:03 +00:00
|
|
|
load: true
|
|
|
|
push: false
|
2022-01-29 20:53:34 +00:00
|
|
|
build-args: |
|
|
|
|
BASE_IMAGE=${{ matrix.baseImage }}
|
|
|
|
cache-from: type=gha,scope=${{ matrix.variant }}
|
2021-12-11 02:50:40 +00:00
|
|
|
# no cache-to to avoid cross-cache update from next build step
|
2021-12-05 00:42:03 +00:00
|
|
|
|
|
|
|
- name: Run tests
|
2022-01-29 20:53:34 +00:00
|
|
|
env:
|
|
|
|
MINECRAFT_VERSION: ${{ matrix.mcVersion }}
|
2022-02-24 18:18:49 +00:00
|
|
|
VARIANT: ${{ matrix.variant }}
|
2023-08-06 20:12:29 +00:00
|
|
|
CF_API_KEY: ${{ secrets.CF_API_KEY }}
|
2021-12-05 00:42:03 +00:00
|
|
|
run: |
|
|
|
|
tests/test.sh
|
|
|
|
|
2022-07-21 01:24:05 +00:00
|
|
|
- name: Login to DockerHub
|
2023-09-23 23:44:45 +00:00
|
|
|
uses: docker/login-action@v3.0.0
|
2022-08-03 03:47:35 +00:00
|
|
|
if: env.HAS_IMAGE_REPO_ACCESS
|
2022-07-21 01:24:05 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
|
2023-04-09 15:39:26 +00:00
|
|
|
- name: Login to GHCR
|
2023-09-23 23:44:45 +00:00
|
|
|
uses: docker/login-action@v3.0.0
|
2023-04-09 15:39:26 +00:00
|
|
|
if: env.HAS_IMAGE_REPO_ACCESS
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ github.token }}
|
|
|
|
|
2021-02-06 20:52:20 +00:00
|
|
|
- name: Build and push
|
2023-09-23 23:44:45 +00:00
|
|
|
uses: docker/build-push-action@v5.0.0
|
2022-08-03 03:47:35 +00:00
|
|
|
if: github.actor == github.repository_owner
|
2021-02-06 20:52:20 +00:00
|
|
|
with:
|
2022-01-29 20:53:34 +00:00
|
|
|
platforms: ${{ matrix.platforms }}
|
2022-07-21 01:24:05 +00:00
|
|
|
push: >
|
|
|
|
${{
|
|
|
|
github.ref_type == 'tag'
|
2023-06-23 19:04:44 +00:00
|
|
|
|| github.ref_name == github.event.repository.default_branch
|
2023-04-09 15:39:26 +00:00
|
|
|
|| startsWith(github.ref_name, 'test/')
|
2022-08-03 03:47:35 +00:00
|
|
|
|| ( github.event_name == 'pull_request'
|
|
|
|
&& env.HAS_IMAGE_REPO_ACCESS
|
|
|
|
&& contains(github.event.pull_request.labels.*.name, 'ci/push-image')
|
|
|
|
)
|
2022-07-21 01:24:05 +00:00
|
|
|
}}
|
2021-05-14 22:48:17 +00:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
2021-02-09 03:27:25 +00:00
|
|
|
# ensure latest base image is used
|
|
|
|
pull: true
|
2021-05-14 22:48:17 +00:00
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
2023-01-24 14:02:21 +00:00
|
|
|
# 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
|
2022-01-29 20:53:34 +00:00
|
|
|
build-args: |
|
|
|
|
BASE_IMAGE=${{ matrix.baseImage }}
|
2022-02-12 03:00:24 +00:00
|
|
|
BUILD_FILES_REV=${{ steps.build-files-rev.outputs.REV }}
|
2022-01-29 20:53:34 +00:00
|
|
|
cache-from: type=gha,scope=${{ matrix.variant }}
|
|
|
|
cache-to: type=gha,mode=max,scope=${{ matrix.variant }}
|