Skip to content

Commit

Permalink
feat: initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyPorthouse committed Nov 4, 2023
0 parents commit 180a2a6
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write
packages: write

name: Create Release

jobs:
release-please:
runs-on: ubuntu-latest

outputs:
releases_created: ${{ steps.release-please.outputs.releases_created }}
tag_name: ${{ steps.release-please.outputs.tag_name }}
major: ${{ steps.release-please.outputs.major }}
minor: ${{ steps.release-please.outputs.minor }}
patch: ${{ steps.release-please.outputs.patch }}
sha: ${{ steps.release-please.outputs.sha }}

steps:
- uses: google-github-actions/release-please-action@v3
id: release-please
with:
release-type: simple
package-name: fabric-server

build:
runs-on: ubuntu-latest
needs: release-please
if: ${{ needs.release-please.outputs.releases_created }}

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/anthonyporthouse/fabric-server
tags: |
type=raw,value=latest
type=raw,value=${{needs.release-please.outputs.major}}.${{needs.release-please.outputs.minor}}.${{needs.release-please.outputs.patch}}
type=raw,value=${{needs.release-please.outputs.major}}.${{needs.release-please.outputs.minor}}
type=raw,value=${{needs.release-please.outputs.major}}
type=sha
- name: Build
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: |
linux/amd64
linux/arm64
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ARG JAVA_VERSION=17

FROM eclipse-temurin:${JAVA_VERSION}

RUN apt update \
&& apt install -y jq \
&& rm -rf /var/lib/apt/lists/*

EXPOSE 25565

WORKDIR /minecraft

ENV MINECRAFT_VERSION=1.20.2

ENV JAVA_OPTS="-Xms1G -Xmx2G"

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
21 changes: 21 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /usr/bin/env bash
set -e

JAR_NAME="server-${MINECRAFT_VERSION}.jar"

if [ ! -f "$JAR_NAME" ]; then
echo "Downloading Minecraft";

manifest=$(curl -s 'https://launchermeta.mojang.com/mc/game/version_manifest.json')
version=$(jq -c ".versions[] | select( .id == \"$MINECRAFT_VERSION\" )" <<< "$manifest")
version_manifest=$(curl -s "$(jq -r ".url" <<< "$version")")

server_url=$(jq -r '.downloads.server.url' <<< "$version_manifest")

curl -o "$JAR_NAME" -J "$server_url"
fi

echo "Accepting EULA"
echo "eula=true" > eula.txt

java ${JAVA_OPTS} -jar "$JAR_NAME" nogui

0 comments on commit 180a2a6

Please sign in to comment.