docker-minecraft-server/.github/workflows/build-multiarch.yml

210 lines
8.2 KiB
YAML
Raw Normal View History

name: Build and Publish
on:
push:
branches:
- master
- test/**
tags:
- "[0-9]+.[0-9]+.[0-9]+"
paths-ignore:
- "*.md"
- "docs/**"
- "examples/**"
- "notes/**"
jobs:
2021-12-05 00:42:03 +00:00
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
2023-09-08 12:38:14 +00:00
- java17-graalvm
2022-03-05 21:53:00 +00:00
- java17-jdk
- java17-openj9
- java17-alpine
- java8
2022-07-16 15:11:11 +00:00
- java8-graalvm-ce
- java8-openj9
2022-03-05 21:53:00 +00:00
- java8-jdk
- java8-alpine
- java11
include:
# JAVA 21:
- variant: java21-graalvm
baseImage: container-registry.oracle.com/graalvm/jdk:21-ol8
platforms: linux/amd64,linux/arm64
mcVersion: latest
- variant: java21
baseImage: eclipse-temurin:21-jre
platforms: linux/amd64,linux/arm64
mcVersion: latest
- variant: java21-alpine
baseImage: eclipse-temurin:21-jre-alpine
platforms: linux/amd64
mcVersion: latest
# 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: latest
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: latest
- variant: java17-jdk
baseImage: eclipse-temurin:17-focal
platforms: linux/amd64,linux/arm/v7,linux/arm64
mcVersion: latest
- variant: java17-openj9
baseImage: ibm-semeru-runtimes:open-17-jre
platforms: linux/amd64,linux/arm64
mcVersion: latest
- variant: java17-alpine
baseImage: eclipse-temurin:17-jre-alpine
platforms: linux/amd64
mcVersion: latest
# JAVA 11:
- variant: java11
baseImage: adoptopenjdk:11-jre-hotspot
platforms: linux/amd64,linux/arm/v7,linux/arm64
mcVersion: 1.16.5
# JAVA 8: NOTE: Unable to go past 8u312 because of Forge dependencies
- variant: java8
baseImage: eclipse-temurin:8u312-b07-jre-focal
platforms: linux/amd64,linux/arm/v7,linux/arm64
mcVersion: 1.12.2
- variant: java8-alpine
baseImage: openjdk:8-jre-alpine3.9
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
- 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: java21
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
with:
# for build-files step
fetch-depth: 0
2021-05-14 22:48:17 +00:00
- name: Docker meta
id: meta
uses: docker/metadata-action@v5.5.1
2021-05-14 22:48:17 +00:00
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.
2021-05-14 22:48:17 +00:00
images: |
${{ github.repository_owner }}/minecraft-server
ghcr.io/${{ github.repository_owner }}/minecraft-server
2021-05-14 22:48:17 +00:00
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
2022-02-05 22:02:27 +00:00
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 }}
# for backward compatibility with users referencing java8-multiarch, this will set an extra label on java8
type=raw,value=java8-multiarch,enable=${{ matrix.variant == 'java8' && 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
2021-05-22 04:00:27 +00:00
flavor: |
latest=${{ matrix.variant == env.MAIN_VARIANT && github.ref_name == github.event.repository.default_branch }}
labels: |
org.opencontainers.image.authors=Geoff Bourne <itzgeoff@gmail.com>
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.3.0
- name: Set up QEMU
build: update various github actions (#2397) * build(deps): bump the patches group in /docs with 2 updates Bumps the patches group in /docs with 2 updates: [mkdocs-literate-nav](https://github.com/oprypin/mkdocs-literate-nav) and [mkdocs-static-i18n](https://github.com/ultrabug/mkdocs-static-i18n). Updates `mkdocs-literate-nav` from 0.6.0 to 0.6.1 - [Release notes](https://github.com/oprypin/mkdocs-literate-nav/releases) - [Commits](https://github.com/oprypin/mkdocs-literate-nav/compare/v0.6.0...v0.6.1) Updates `mkdocs-static-i18n` from 1.0.2 to 1.0.3 - [Changelog](https://github.com/ultrabug/mkdocs-static-i18n/blob/main/docs/changelog.md) - [Commits](https://github.com/ultrabug/mkdocs-static-i18n/compare/1.0.2...1.0.3) --- updated-dependencies: - dependency-name: mkdocs-literate-nav dependency-type: direct:production update-type: version-update:semver-patch dependency-group: patches - dependency-name: mkdocs-static-i18n dependency-type: direct:production update-type: version-update:semver-patch dependency-group: patches ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump mkdocs-material from 9.2.7 to 9.3.1 in /docs Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.2.7 to 9.3.1. - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.2.7...9.3.1) --- updated-dependencies: - dependency-name: mkdocs-material dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump docker/setup-qemu-action from 2.2.0 to 3.0.0 Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2.2.0 to 3.0.0. - [Release notes](https://github.com/docker/setup-qemu-action/releases) - [Commits](https://github.com/docker/setup-qemu-action/compare/v2.2.0...v3.0.0) --- updated-dependencies: - dependency-name: docker/setup-qemu-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump docker/build-push-action from 4.2.1 to 5.0.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4.2.1 to 5.0.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v4.2.1...v5.0.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump docker/setup-buildx-action from 2 to 3 Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump docker/metadata-action from 4 to 5 Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4 to 5. - [Release notes](https://github.com/docker/metadata-action/releases) - [Upgrade guide](https://github.com/docker/metadata-action/blob/master/UPGRADE.md) - [Commits](https://github.com/docker/metadata-action/compare/v4...v5) --- updated-dependencies: - dependency-name: docker/metadata-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump docker/login-action from 2 to 3 Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * build: update various github actions --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-23 23:44:45 +00:00
uses: docker/setup-qemu-action@v3.0.0
2021-12-05 00:42:03 +00:00
- name: Build for test
uses: docker/build-push-action@v5.3.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
# load into daemon for test usage in next step
2021-12-05 00:42:03 +00:00
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
2021-12-05 00:42:03 +00:00
- name: Run tests
env:
MINECRAFT_VERSION: ${{ matrix.mcVersion }}
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
- name: Login to DockerHub
uses: docker/login-action@v3.1.0
if: env.HAS_IMAGE_REPO_ACCESS
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v3.1.0
if: env.HAS_IMAGE_REPO_ACCESS
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push
uses: docker/build-push-action@v5.3.0
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')
)
}}
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 }}
# 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 }}