Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/dependencies.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
4241c14a7727c34feea6507ec801318a3d4a90f070e4525681079fb94ee4c593 libs/gson-2.10.1.jar
b7156eab567772f9fdac0bf696b209111790c3f69149ab9a742e3dd030ec4b10 libs/spigot-api.jar
bf19510145178df82cd3bd37edd514c13f411531ec5545299fd3abcbc98fe7c2 libs/joml-1.10.8.jar
575aa30aee8ef723ad36229eb6c4223bca6e4037d271ddccc8f23cf6faa69747 libs/MythicMobs-5.8.0-SNAPSHOT.jar
ee2e7ab9b5386f2d103081c4d108e61b1035df2ca692b53d6e2409fb1f5caccf libs/ProtocolLib.jar
11 changes: 11 additions & 0 deletions .github/scripts/prepare-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
: "${GH_TOKEN:?Set DEPS_TOKEN with Contents read access to TF-Minecraft/ServerAssets}"
ref=726208728d6b3b66d09e5efcdfab9a63b8e39228
mkdir -p libs
curl --fail --location --silent --show-error --retry 3 -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github.raw+json" "https://api.github.com/repos/TF-Minecraft/ServerAssets/contents/jars/4241c14a7727/gson-2.10.1.jar?ref=$ref" > "libs/gson-2.10.1.jar"
curl --fail --location --silent --show-error --retry 3 -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github.raw+json" "https://api.github.com/repos/TF-Minecraft/ServerAssets/contents/jars/b7156eab5677/spigot-api.jar?ref=$ref" > "libs/spigot-api.jar"
curl --fail --location --silent --show-error --retry 3 -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github.raw+json" "https://api.github.com/repos/TF-Minecraft/ServerAssets/contents/jars/bf1951014517/joml-1.10.8.jar?ref=$ref" > "libs/joml-1.10.8.jar"
curl --fail --location --silent --show-error --retry 3 -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github.raw+json" "https://api.github.com/repos/TF-Minecraft/ServerAssets/contents/jars/575aa30aee8e/MythicMobs-5.8.0-SNAPSHOT.jar?ref=$ref" > "libs/MythicMobs-5.8.0-SNAPSHOT.jar"
curl --fail --location --silent --show-error --retry 3 -H "Authorization: Bearer $GH_TOKEN" -H "Accept: application/vnd.github.raw+json" "https://api.github.com/repos/TF-Minecraft/ServerAssets/contents/runtime/plugins/ProtocolLib.jar?ref=$ref" > "libs/ProtocolLib.jar"
sha256sum --check .github/dependencies.sha256
60 changes: 60 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '25'
- name: Install pinned TLibs in Maven
uses: TF-Minecraft/TLibs/.github/actions/setup@905a196217471252b96be5ecf8eeb16c9e85e41d
with:
token: ${{ secrets.DEPS_TOKEN }}

- name: Prepare pinned dependencies
env:
GH_TOKEN: ${{ secrets.DEPS_TOKEN }}
run: bash .github/scripts/prepare-release.sh
- name: Set dated development version
id: dev
shell: bash
run: |
dev_version="DEV-$(date -u +%Y%m%d-%H%M)"
mvn -B --no-transfer-progress org.codehaus.mojo:versions-maven-plugin:2.22.0:set \
-DnewVersion="$dev_version" -DgenerateBackupPoms=false
mvn -B --no-transfer-progress help:evaluate \
-Dexpression=project.build.finalName -Doutput="$RUNNER_TEMP/final-name"
final_name=$(cat "$RUNNER_TEMP/final-name")
echo "name=$final_name" >> "$GITHUB_OUTPUT"
echo "jar=target/$final_name.jar" >> "$GITHUB_OUTPUT"
- name: Run unit tests and build
run: mvn -B --no-transfer-progress clean verify -DskipTests=false -Dmaven.test.skip=false
- uses: actions/upload-artifact@v7
with:
name: ${{ steps.dev.outputs.name }}-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ steps.dev.outputs.jar }}
if-no-files-found: error

- name: Upload unit test reports
if: ${{ !cancelled() && hashFiles('target/surefire-reports/*.xml') != '' }}
uses: actions/upload-artifact@v7
with:
name: unit-test-reports-${{ github.run_id }}-${{ github.run_attempt }}
path: target/surefire-reports/
if-no-files-found: error
140 changes: 140 additions & 0 deletions .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Maven plugin release

on:
workflow_call:
inputs:
java-version:
required: true
type: string
artifact-path:
description: Exact deployable JAR path, with optional {version} placeholder
required: true
type: string
secrets:
DEPS_TOKEN:
required: false

permissions:
contents: read

concurrency:
group: plugin-release-${{ github.repository }}-${{ github.ref }}
cancel-in-progress: false

defaults:
run:
shell: bash

jobs:
build:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false

- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: ${{ inputs.java-version }}

- name: Validate release version
env:
TAG: ${{ github.ref_name }}
run: |
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-[0-9A-Za-z]+([.-][0-9A-Za-z]+)*)?$ ]] || {
echo '::error::Expected vMAJOR.MINOR or vMAJOR.MINOR.PATCH, with an optional prerelease suffix.'
exit 1
}
[[ "${TAG^^}" != *SNAPSHOT* ]] || exit 1
- name: Install pinned TLibs in Maven
uses: TF-Minecraft/TLibs/.github/actions/setup@905a196217471252b96be5ecf8eeb16c9e85e41d
with:
token: ${{ secrets.DEPS_TOKEN }}

- name: Prepare pinned dependencies
env:
GH_TOKEN: ${{ secrets.DEPS_TOKEN }}
run: |
if [[ -f .github/scripts/prepare-release.sh ]]; then
bash .github/scripts/prepare-release.sh
fi
- name: Check Maven version and build
env:
TAG: ${{ github.ref_name }}
run: |
version_file="$RUNNER_TEMP/maven-release-version"
mvn -B --no-transfer-progress -P'!deploy-live' help:evaluate \
-Dexpression=project.version -Doutput="$version_file"
[[ "$(cat "$version_file")" == "${TAG#v}" ]] || {
echo '::error::The tag must match project.version exactly.'
exit 1
}
mvn -B --no-transfer-progress -P'!deploy-live' clean verify
- name: Stage only the release JAR
env:
ARTIFACT_PATH: ${{ inputs.artifact-path }}
TAG: ${{ github.ref_name }}
run: |
python3 - <<'PY'
import hashlib, json, os, pathlib, shutil, zipfile
root = pathlib.Path.cwd().resolve()
source = (root / os.environ['ARTIFACT_PATH'].replace('{version}', os.environ['TAG'][1:])).resolve()
if not source.is_relative_to(root / 'target') or not source.is_file() or source.suffix != '.jar':
raise SystemExit('Expected one existing JAR inside target/')
with zipfile.ZipFile(source) as jar:
if not {'plugin.yml', 'paper-plugin.yml'}.intersection(jar.namelist()):
raise SystemExit('Release JAR has no plugin descriptor')
if jar.testzip() is not None:
raise SystemExit('Release JAR is corrupt')
dest = pathlib.Path(os.environ['RUNNER_TEMP']) / 'plugin-release'
dest.mkdir()
shutil.copyfile(source, dest / source.name)
digest = hashlib.sha256((dest / source.name).read_bytes()).hexdigest()
(dest / 'SHA256SUMS').write_text(f'{digest} {source.name}\n')
(dest / 'build.json').write_text(json.dumps({
'repository': os.environ['GITHUB_REPOSITORY'],
'commit': os.environ['GITHUB_SHA'],
'tag': os.environ['TAG'],
'run': f"{os.environ['GITHUB_SERVER_URL']}/{os.environ['GITHUB_REPOSITORY']}/actions/runs/{os.environ['GITHUB_RUN_ID']}",
'artifact': source.name,
'sha256': digest,
}, indent=2) + '\n')
PY
- uses: actions/upload-artifact@v7
with:
name: plugin-release-${{ github.sha }}
path: ${{ runner.temp }}/plugin-release/
if-no-files-found: error
retention-days: 30

publish:
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: write
steps:
- uses: actions/download-artifact@v8
with:
name: plugin-release-${{ github.sha }}
path: release

- name: Create draft release
working-directory: release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
run: |
sha256sum --check SHA256SUMS
flags=()
if [[ "$TAG" == *-* ]]; then flags+=(--prerelease); fi
gh release create "$TAG" ./*.jar SHA256SUMS build.json \
--verify-tag --draft --title "$TAG" --generate-notes "${flags[@]}"
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release

on:
push:
tags: ['v*']

permissions:
contents: read

jobs:
release:
permissions:
contents: write
uses: ./.github/workflows/maven-release.yml
with:
java-version: '25'
# Exact path, not a glob. {version} is replaced with the tag without v.
artifact-path: target/interactiblefurniture-{version}.jar
secrets:
DEPS_TOKEN: ${{ secrets.DEPS_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ Thumbs.db

# Logs
*.log

# Downloaded build dependencies
/libs/*.jar
43 changes: 17 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
<tlibs.version>1.1.0</tlibs.version>
<maven.compiler.release>25</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tfmc.refs>D:/Dokumenter/My Plugins/Reference Libs</tfmc.refs>
<tfmc.builds>D:/Dokumenter/My Plugins/TFMC/InteractibleFurniture</tfmc.builds>

</properties>

<dependencies>
Expand All @@ -23,14 +20,14 @@
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>system</scope>
<systemPath>${tfmc.refs}/gson-2.10.1.jar</systemPath>
<systemPath>${project.basedir}/libs/gson-2.10.1.jar</systemPath>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>spigot-api</artifactId>
<version>1.21.8</version>
<scope>system</scope>
<systemPath>${tfmc.refs}/spigot-api.jar</systemPath>
<systemPath>${project.basedir}/libs/spigot-api.jar</systemPath>
</dependency>
<dependency>
<groupId>me.plugins</groupId>
Expand All @@ -47,49 +44,43 @@
<artifactId>joml</artifactId>
<version>1.10.8</version>
<scope>system</scope>
<systemPath>${tfmc.refs}/joml-1.10.8.jar</systemPath>
<systemPath>${project.basedir}/libs/joml-1.10.8.jar</systemPath>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>MythicMobs</artifactId>
<version>5.8.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${tfmc.refs}/MythicMobs-5.8.0-SNAPSHOT.jar</systemPath>
<systemPath>${project.basedir}/libs/MythicMobs-5.8.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>ProtocolLib</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${tfmc.refs}/ProtocolLib.jar</systemPath>
<systemPath>${project.basedir}/libs/ProtocolLib.jar</systemPath>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes><include>plugin.yml</include></includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes><exclude>plugin.yml</exclude></excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>run</goal></goals>
<configuration>
<target>
<mkdir dir="${tfmc.builds}"/>
<copy file="${project.build.directory}/${project.build.finalName}.jar"
tofile="${tfmc.builds}/${project.build.finalName}.jar"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
main: net.tfminecraft.InteractibleFurniture
api-version: 1.20
name: InteractibleFurniture
version: 1.0
version: ${project.version}
author: Drefvelin

depend: [TLibs, MythicMobs]
Expand Down